Editing image objects
After you create an image object, its data can be edited with a variety of Lingo commands that are
designed to manipulate the pixels of the image. You can crop images, draw new pixels on them,
copy sections of them, and work with mask and alpha channel information. For more
information, see the individual commands in the Lingo Dictionary.
To draw a line on an image object:
•
Use the
draw()
line's color.
The following statement draws a line on the previously created 640 x 480 image object
running from 20 pixels inside the upper left corner to 20 pixels inside the lower right corner, and
colors it blue:
myImage.draw(20, 20, 620, 460, rgb(0, 0, 255))
To draw a rectangle on an image object:
•
Use the
fill()
Director draws a rectangle instead of a line.
The following statement draws a red 40 x 40 pixel rectangle near the upper left corner of the
image object
myImage
myImage.fill(rect(20, 20, 60, 60), rgb(255, 0, 0))
To determine the color of an individual pixel of an image object or set that pixel's color:
•
Use the
getPixel
To copy part or all of an image object into a different image object:
•
Use the
copyPixels()
copying, the rectangle to which you are copying the pixels, and the rectangle from which to
copy the pixels in the source image.
The following statement copies a 40 x 40 rectangle from the upper left area of the image object
and puts the pixels into a 40 x 40 rectangle at the lower right of the 300 x 300 pixel
myImage
object called
myNewImage
myNewImage.copyPixels(myImage, rect(260, 260, 300, 300), rect(0, 0, 40, 40))
When using
copyPixels()
pixels you are copying before drawing them into the destination rectangle. You can apply blends
and inks, change the foreground or background colors, specify masking operations, and more.
You specify these operations by adding a property list at the end of the
The following statement performs the same operation as the previous example and tells Lingo to
use the Reverse ink when rendering the pixels into the destination rectangle:
myNewImage.copyPixels(myImage, rect(260, 260, 300, 300), rect(0, 0, 40, 40),
[#ink: #reverse])
command. You must specify the locations of each end of the line as well as the
command. You provide the same information as for the
:
or
command.
setPixel
command, which requires you to specify the image from which you are
:
, you can specify optional parameters that tell Lingo to modify the
myImage
command, but
draw
command.
copyPixels()
Bitmaps 223
,
Need help?
Do you have a question about the DIRECTOR MX-USING DIRECTOR MX and is the answer not in the manual?
Questions and answers