GLBasic User Manual

Main sections

GETPIXEL()

col% = GETPIXEL(x%, y%)



Returns a color value for the pixel at x%, y%.
<B>Warning:</B> The color returned can differ up to 13% from the actual value for the pixel. 16 bit colored pixels are especially likely to return incorrect information. The reason for this is that some platforms have 16 bit displays - 24 bits of color information is converted down to 16 bits resulting in a loss of accuracy.
<B>Warning:</B> This command reads from APG memory and thus is extremely slow.

// --------------------------------- //
// Project: GetPixel
// IDE Version: 2.50316

LOADSPRITE "bubble.bmp", 0
WHILE TRUE
MOUSESTATE mx, my, b1, b2
DRAWSPRITE 0, 0, 0
FOR x=0 TO 31
FOR y=0 TO 31
DRAWRECT x*8+160, y*8, 8, 8, GETPIXEL(x+mx,y+my)
NEXT
NEXT
ALPHAMODE .1
DRAWRECT mx, my, 32, 32, RGB(255,255,255)
ALPHAMODE 0
SHOWSCREEN
WEND

See also...