getPixel()
Usage
-- Lingo syntax
imageObjRef.getPixel(x, y {, #integer})
imageObjRef.getPixel(point(x, y) {, #integer})
// JavaScript syntax
imageObjRef.getPixel(x, y {, #integer});
imageObjRef.getPixel(point(x, y) {, #integer});
Description
Image method. Returns an indexed or RGB color of the pixel at a specified point in a given
image.
The index of the rows and columns of the returned image starts with 0. Therefore, in order to
access the top left pixel of an image, specify the location as
is
pixels high and
h
location as
(w,1)
This method returns a value of 0 if the specified pixel is outside the given image.
To set a lot of pixels to the color of another pixel, it is faster to set them as raw numbers (by using
the optional
#integer
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.
Parameters
Required if specifying a pixel using
x
coordinate of the pixel.
Required if specifying a pixel using
y
coordinate of the pixel.
Optional. A symbol that specifies the raw number of the returned color value.
#integer
Required if specifying a pixel using a point. A point that specifies the point of
point(x, y)
the pixel.
Example
These statements get the color of the pixel at point (90, 20) in member Happy and set sprite 2 to
that color:
This statement sets the variable alpha to the alpha channel value of the point (25, 33) in the
32-bit image object myImage:
See also
color(), image(), power(),
pixels wide, to access the bottom right pixel of the image, specify the
w
,
.
(h,1)
parameter). Raw integer color values are also useful because they contain
x
x
setPixel()
(0,0)
and
coordinates. An integer that specifies the
y
and
coordinates. An integer that specifies the
y
, and not
. If a given image
(1,1)
getPixel()
x
y
339
Need help?
Do you have a question about the DIRECTOR MX 2004-DIRECTOR SCRIPTING and is the answer not in the manual?
Questions and answers