Lingo Dictionary > G-K > getPixel() |
![]() ![]() ![]() |
getPixel()
Syntax
imageObject
.getPixel(
x
,y
{,
#integer
})
imageObject
.getPixel(point(x
,y
){,
#integer
})
Description
This function returns the color value of the pixel at the specified point in the given image object. This value is normally returned as an indexed or RGB color object, depending on the bit depth of the image.
If you include the optional parameter value #integer
, however, it's returned as a raw number. If you're setting a lot pixels to the color of another pixel, it's faster to set them as raw numbers. Raw integer color values are also useful because they contain alpha layer information as well as color when the image is 32-bit. The alpha channel information can be extracted from the raw integer by dividing the integer by 2^8+8+8.
GetPixel()
returns 0 if the given pixel is outside the specified image object.
Example
These statements get the color of the pixel at point (90, 20) in member Happy and set sprite 2 to that color.
myColor=member("Happy").image.getPixel(90, 20) sprite(2).color=myColor
Example
This statement sets the variable alpha to the alpha channel value of the point (25, 33) in the 32-bit image object myImage.
alpha = myImage.getPixel(25, 33, #integer) / power(2, 8+8+8)
See also
depth, color(), setPixel(), power()
![]() ![]() ![]() |