January 1, 2005

WinTask - GetPixel

'
' GetPixel - get the pixel at a particular point on the screen
'
' Author: Joe Strazzere
'

dim ptr as unsigned
dim ptr2 as unsigned
ptr=allocate(16)
ptr2=ptr+0
pokeinteger(ptr2,0,4)
ptr2=ptr+4
pokeinteger(ptr2,0,4)
ptr2=ptr+8
pokeinteger(ptr2,640,4)
ptr2=ptr+12
pokeinteger(ptr2,32,4)
hdc=External("gdi32","CreateDCA","DISPLAY",0,0,0)
x=1279
y=1023
pixel=External("gdi32", "GetPixel", hdc, x, y)
   
External("gdi32","DeleteDC")
blue = pixel / 65536
green = (pixel - (blue * 65536)) / 256
red = pixel - (blue * 65536) - (green * 256)
msgbox("Pixel value of ("+str$(x)+","+str$(y)+") = "+str$(pixel)+crlf+crlf+"Red = "+str$(red)+crlf+"Green = "+str$(green)+crlf+"Blue = "+str$(blue),,"GetPixel")