Here is a little something for you if you ever need in your apps
// Project: magnifyer
// Created: 2017-12-22
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "magnifyer" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
picturemem = LoadImage("\media\test.png")
pic = CreateMemblockFromImage(picturemem)
picsize#=GetMemblockSize(pic)
picture = CreateSprite(picturemem)
picwidth# = GetMemblockint(pic,0)
picheight# = GetMemblockInt(pic,4)
// *************************
// Chnage this value depending on size of magnifer - the larger the more fps is will swallow - so use this wisely
magnifiersize#=80
magnifierimg = createmagifier(magnifiersize#)
// *************************
mag = CreateMemblockFromImage(magnifierimg)
orginalmag = CreateMemblockFromImage(magnifierimg)
imgsize# = GetMemblockSize(mag)
magnifier = CreateSprite(magnifierimg)
do
// magnify from the centre of the magnifier to the position on the screen
wherex=getpointerx()-magnifiersize# / 2
wherey=getpointery()-magnifiersize# / 2
if wherex<0 then wherex=0
if wherey<0 then wherey=0
if wherex>picwidth# then wherex=picwidth#
if wherey>picheight#-magnifiersize#*2 then wherey=picheight#-magnifiersize#*2
SetSpritePosition(magnifier, wherex,wherey)
SetSpriteAngle(magnifier,angle#)
// change this to rotate the magnifier (cool effect)
angle#=angle#+0
C=4
//loop round the size of the magifier
for a=0 to (magnifiersize# * 2)-1
for b=0 to (magnifiersize#*2)-1
offset=12 + ((((wherey+a) * picwidth#) + wherex+b) *4)-4
if offset>imgsize#-12
newr=GetMemblockInt(pic, offset)
newg=GetMemblockInt(pic, offset+1)
newb=GetMemblockInt(pic, offset+2)
newa=GetMemblockInt(pic, offset+3)
endif
newoffset=12 + ((((a * (magnifiersize#*2)) + b) * 4))-4
if c + newoffset<imgsize#-12
grabr = GetMemblockInt(orginalmag,c+newoffset)
if grabr>3
SetMemblockInt(mag, c+newoffset, newr)
else
SetMemblockInt(mag, c+newoffset+3, grabr)
endif
endif
if c + newoffset + 1<Imgsize#-12
grabg = GetMemblockInt(orginalmag,c+newoffset+1)
if grabg>3
SetMemblockInt(mag, c+newoffset+1, newg)
else
SetMemblockInt(mag, c+newoffset+3, grabg)
endif
endif
if c + newoffset +2 <imgsize#-12
grabb = GetMemblockInt(orginalmag,c+newoffset+2)
if grabb>3
SetMemblockInt(mag, c+newoffset+2, newb)
else
SetMemblockInt(mag, c+newoffset+3, grabb)
endif
endif
if c+newoffset+3< imgsize#-12
graba = GetMemblockInt(orginalmag,c+newoffset+3)
if graba>3
SetMemblockInt(mag, c+newoffset+3, newa)
else
SetMemblockInt(mag, c+newoffset+3, graba)
endif
endif
inc c, 4
next
next
img = CreateImageFromMemblock(mag)
SetSpriteImage(magnifier, img)
Print( ScreenFPS() )
Render2DFront()
Sync()
loop
function createmagifier(size#)
render()
DrawBox(size#,size#,size#*2+(size#+100),size#+10,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
DrawBox(size#,size#,size#*2+(size#+100),size#+9,MakeColor(255,255,255),MakeColor(255,255,255),MakeColor(255,255,255),MakeColor(255,255,255),0)
for a=1 to 5
DrawEllipse(size#,size#,size#-a,size#-a,MakeColor(0,0,0),MakeColor(0,0,0),0)
DrawEllipse(size#,size#,(size#-5)-a,(size#-5)-a,MakeColor(255,255,255),MakeColor(255,255,255),0)
next
DrawEllipse(size#,size#,size#-10,size#-10,MakeColor(3,3,3),MakeColor(3,3,3),1)
swap()
img = GetImage(0,0,size#*2,size#*2)
endfunction img
You will need the test.png -or make your own and call it test.png (of course can change that bit code to suit your 1024x768 picture
Enjoy