TrimWhiteSpace

From Director Online Wiki
Jump to: navigation, search
importFileInto
Type: bitmap member property and Imaging Lingo method
Version: 8.0
Language: Lingo, JavaScript
Dependencies: none
Links/Related
importFileInto, crop

In the online help and the Director MX 2004 Director Scripting Reference, trimWhiteSpace is defined only as a property of bitmap cast members. trimWhiteSpace() can also be used as an Imaging Lingo method. It returns an image where all white or fully transparent pixels are trimmed from the source image.

Syntax

from MX 2004 Documentation

 -- Lingo syntax
 memberObjRef.trimWhiteSpace
 // JavaScript syntax
 memberObjRef.trimWhiteSpace;

Description

Cast member property. Determines whether the white pixels around the edge of a bitmap cast member are removed or left in place. This property is set when the member is imported. It can be changed in Lingo or in the Bitmap tab of the Property inspector.

Undocumented Syntax

Director 8.0:

 vOutputImage = vInputImage.trimWhiteSpace()

Example

Try the following test in the Message window:

-- Create a 64 x 64 pixel image, and draw two concentric squares in it

 vImage = image(64, 64, 8, #grayScale)
 vImage.draw(0, 0, 64, 64, rgb("#000000"), [#shapeType: #rect])
 vImage.draw(16, 16, 48, 48, rgb("#000000"), [#shapeType: #rect])
 new(#bitmap).image = vImage
 -- In the cast window, you should see a new bitmap member with the
 -- image you have created. Now let's remove the outer square, using
 -- the crop() method:
 vImage = vImage.crop(rect(1, 1, 63, 63))
 put vImage.rect
 -- rect(0, 0, 62, 62)
 new(#bitmap).image = vImage
 -- A new bitmap member is created with a white border.  The
 -- .trimWhiteSpace property of this new member is set to FALSE.
 -- Let's use the trimWhiteSpace() method on the image to remove
 -- the white border
 vImage = vImage.trimWhiteSpace()
 put vImage.rect
 -- rect(0, 0, 32, 32)
 new(#bitmap).image = vImage
 -- You should now see a 32 x 32 pixel bitmap member with no border
 -- around the smaller black square