Season's Greetings to everyone- whatever your timezone!
And in the Northern Hemisphere our days start getting longer again. Can't be bad..
This is just an illustration of getting screen pixel values. It seemed suitable seasonal!
The challenge was to space the dots that replace the b&w values AND do so irregularly rather than on a fixed grid. I'm quite pleased by the result, although I may play further!
Note the image name and size are fixed at 800x600 and I posterised the image first- 'tho I could call ImageMagick to resize and do this pre-processing automatically. Bear that in mind in trying the code below!
Have a great New Year everyone, and special thoughts to those who haven't been having an easy time.
open "Display" for graphics_nsb as #w
#w "trapclose quit"
handleg =hwnd( #w)
calldll #user32, "GetDC", handleg as ulong, hDC as ulong
loadbmp "scr", "tenoch.bmp"
#w "down ; drawbmp scr 20 20 ; backcolor white ; flush"
x = 20 +int( 800 *rnd( 1))
y = 20 +int( 600 *rnd( 1))
calldll #gdi32, "GetPixel", hDC as ulong, x as long, y as long, pixcol as ulong
if pixcol <>255 and pixcol <> 2^24 -1 then
bl = int( pixcol /( 256*256)): gr = int( (pixcol -bl *256*256) / 256): re = int( pixcol -bl *256*256 -gr *256)
grey =int( ( bl +gr +re) /3 /32)
print x, y, re, gr, bl, grey
#w "color white"
#w "place "; x; " "; y
#w "circlefilled "; grey -2
#w "size "; 4
#w "color red"
#w "set "; x; " "; y
'call timeout 100
sub quit h$
callDll #user32, "ReleaseDC", handleg as ulong, hDC as ulong, result as ushort
sub timeout t
timer t, [j]