Get the color of a pixel (:get_color)
Declaration
color, alpha = img:get_color(x, y)
Parameters
- x, y
Integer. Coordinates of the pixel in the current image
Returns
- color
Integer. Color value of the pixel. Note: if alpha is not 255, the RGB value should consider division by opacity (alpha/255) - alpha
Integer. Opacity of the pixel, range 0~255
Description
Get the color of a pixel in an image. Unlike screen sampling, image pixels also have an alpha channel
Example
local img = image.load_file("/var/mobile/1.png")
local clr = img:get_color(100, 100)
sys.alert(string.format("Color at (100, 100): 0x%06x", clr))