What's interesting in the original code, is that the closer you get to the bottom left hand corner the slower it gets. At a resolution of 1920*1080, and removing the mouse check so it is continual sampling, I get as low as 30fps in the bottom right most corner, but nearly 1000fps in the top left most. The original solution is completely fine if you only need it to function when the mouse is pressed though.
It did occur to me though that the basic function will work just as well without a shader with some tweaking, so here is a non shader version based on the original code that still gives about 1000-1100 fps at 1920*1080
// Project: Color Picker
// Created: 2020-04-05
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Color Picker" )
SetWindowSize( 1920, 1080, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1920, 1080 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 0, 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
red = MakeColor(255,0,0)
green = MakeColor(0, 255, 0)
blue = MakeColor(0,0,255)
black = MakeColor(0,0,0)
bluegreen = MakeColor(0,255,255)
rend_img=createrenderimage(1920,1080,0,0) // this renders your screen
output_img=CreateRenderImage(1,1,0,0) // this is the color source
sample=createsprite(0)
setspritesize(sample,250,250)
setspritedepth(sample,5)
setspriteposition(sample,1920-250,0)
do
DrawBox(100,300,120,320,red,red,red,red,1)
DrawBox(200,400,220,420,green,green,green,green,1)
DrawBox(100,500,120,520,blue,blue,blue,blue,1)
DrawBox(200,500,220,520,bluegreen,bluegreen,bluegreen,bluegreen,1)
r=0
g=0
b=0
//if GetPointerstate()=1
// render the image to the buffer to capture the colour image to be sampled
setrendertoimage(rend_img,-1)
clearscreen()
DrawBox(100,300,120,320,red,red,red,red,1)
DrawBox(200,400,220,420,green,green,green,green,1)
DrawBox(100,500,120,520,blue,blue,blue,blue,1)
DrawBox(200,500,220,520,bluegreen,bluegreen,bluegreen,bluegreen,1)
// get the mouse coords
xm=getrawmousex()
ym=getrawmousey()
// create s sprite from the rendered image, and set it's offset to the mouse coords
rend_sprite=createsprite(rend_img)
setspriteoffset(rend_sprite,xm,ym)
// render the single pixel output source
setrendertoimage(output_img,-1)
setvirtualresolution(1,1)
clearscreen()
SetSpritePositionByOffset(rend_sprite,0,0)
drawsprite(rend_sprite)
setrendertoscreen()
setvirtualresolution(1920,1080)
deletesprite(rend_sprite)
setspriteimage(sample,output_img)
// convert to a memblock to get the values
mem=CreateMemblockFromImage(output_img)
r=getmemblockbyte(mem,12)
g=getmemblockbyte(mem,13)
b=getmemblockbyte(mem,14)
//endif
Print( ScreenFPS() )
Print("Red: " + Str(r))
Print("Green: " + Str(g))
Print("Blue: " + Str(b))
Sync()
loop