reading the color under the pointer

BlitzPlus Forums/BlitzPlus Programming/reading the color under the pointer

julianbury(Posted 2009) [#1]
Hi Guys :-)

I wish to read the color under the pointer.

Is there any way of doing this?

Thanks in antici...pation ;-)


blackgecko(Posted 2009) [#2]
You can use ReadPixel or ReadPixelfast for this.


GaryV(Posted 2009) [#3]
RTFM

GetColor x, y
Parameters:
x = x coordinate of pixel
y = y coordinate of pixel
Description:
This command works like a 'color picker' in your favorite paint program. By specifying
Example:
; GetColor Example

Graphics 320,200
SetBuffer BackBuffer()

For t = 1 To 1000
Color Rnd(255), Rnd(255), Rnd(255)
Rect Rnd(320),Rnd(200),10,10,1
Next

GetColor 100,100
Print "Box at 100,100 is RGB:" + ColorRed() + "," + ColorGreen() + "," + ColorBlue()  + "!"
Flip 
While Not KeyHit(1)
Wend 



blackgecko(Posted 2009) [#4]
GetColor is slow. I would use ReadPixel.


GaryV(Posted 2009) [#5]
You can also use native Windows API functions ;)


Martin W(Posted 2010) [#6]
Instead of GetColor 100, 100 in the above, why not GetColor MouseX(), MouseY() for the color under the mouse pointer. You could put this in a loop that changes the readout each time the mouse moves, until a mouse button is pressed, using While Not MouseDown() .. Wend.
Or use ReadPixel as suggested.