User Guide

Chapter 7222
Controlling bitmap images with Lingo
Lingo lets you control bitmap images in two ways. First, you can perform simple operations that
affect the content of entire image cast members. These operations include changing the
background and foreground colors as well as switching the image that appears in a specific cast
member with that of another cast member. Each of these operations manipulates a property of the
entire image cast member.
Second, you can use Lingo to perform fine manipulations of the pixels of an image or to create
entirely new images. When you use Lingo you can be extremely flexible about which images you
display. You can create images based on dynamic information, such as user input, or based on any
other factors you want to include. To perform this kind of image operation, Lingo works with
image objects. See “Creating image objects” on page 222.
To change the image assigned to a bitmap cast member:
Set the picture cast member property. See picture (cast member property) in the
Lingo Dictionary.
To specify the background or foreground of a bitmap sprite:
Set the backColor or foreColor sprite property. See backColor and foreColor in the
Lingo Dictionary.
To capture the current graphic contents of the Stage:
Set a bitmaps picture cast member property to the Stages picture property. See picture
(cast member property) in the Lingo Dictionary.
For example, the
member("Archive").picture = (the stage).picture statement makes
the current image of the Stage the image for the bitmap cast member Archive.
Creating image objects
An image object can be either a self-contained set of image data or a reference to the image data of
a cast member or of the Stage. If an image object is created by referring to a cast member, the
object contains a reference to the image of the member. The following statement creates an image
object that contains a reference to the image of the cast member called Boat.
myImage = member(“Boat”).image
Because the image object myImage contains a reference to the cast member Boat, any changes you
make to the object are reflected in the cast member. These changes are also reflected in any sprites
made from that cast member.
You can also create an image object that contains a reference to the graphic contents of the Stage:
myImage = (the stage).image
Any changes to this image object are reflected on the Stage.
To create an image object that is a self-contained set of image data instead of a reference to a cast
member, you must tell Lingo what kind of image you want to create. You must provide the
parameters that describe the size and bit depth of the image you are creating.
The following statement creates an image object that contains a 640 x 480 pixel, 16-bit image:
myImage = image(640, 480, 16)