BitmapData (flash.display.BitmapData)

Object 
    | 
    +-flash.display.BitmapData 
 
public class BitmapData 
extends Object

The BitmapData class lets you create arbitrarily sized transparent or opaque bitmap images and manipulate them in various ways at runtime.

This class lets you separate bitmap rendering operations from the Flash Lite player internal display updating routines. By manipulating a BitmapData object directly, you can create very complex images without incurring the per-frame overhead of constantly redrawing the content from vector data.

The methods of the BitmapData class support a variety of effects that are not available through the generic filter interface.

A BitmapData object contains an array of pixel data. This data can represent either a fully opaque bitmap or a transparent bitmap that contains alpha channel data. Either type of BitmapData object is stored as a buffer of 32-bit integers. Each 32-bit integer determines the properties of a single pixel in the bitmap.

Each 32-bit integer is a combination of four 8-bit channel values (from 0 to 255) that describe the alpha transparency and the red, green, and blue (ARGB) values of the pixel.

The four channels (red, green, blue, and alpha) are represented as numbers when you use them with the BitmapData.copyChannel() method or the DisplacementMapFilter.componentX and DisplacementMapFilter.componentY properties, as follows:

  • 1 (red)

  • 2 (green)

  • 4 (blue)

  • 8 (alpha)

You can attach BitmapData objects to a MovieClip object by using the MovieClip.attachBitmap() method.

You can use a BitmapData object to fill an area in a movie clip by using the MovieClip.beginBitmapFill() method.

The maximum width and maximum height of a BitmapData object is 2880 pixels.

Availability

Flash Lite 3.1

Property summary

Modifiers

Property

Description

 

height:Number [read-only]

The height of the bitmap image in pixels.

 

rectangle:Rectangle [read-only]

The rectangle that defines the size and location of the bitmap image.

 

transparent:Boolean [read-only]

Defines whether the bitmap image supports per-pixel transparency.

 

width:Boolean [read-only]

The width of the bitmap image in pixels.

Constructor summary

Signature

Description

BitmapData(width:Number, height:Number,[transparent:Boolean], [fillColor:Number])

Creates a BitmapData object with a specified width and height.

Method summary

Modifiers

Signature

Description

 

applyFilter

Takes a source image and a filter object and generates the filtered image.

Flash Lite 3.1 does not support filters, so this method is not supported.

 

clone(): BitmapData

Returns a new BitmapData object that is a clone of the original instance with an exact copy of the contained bitmap.

 

colorTransform(rect:Rectangle, colorTransform:ColorTransform) : Void

Adjusts the color values in a specified area of a bitmap image by using a ColorTransform object.

 

copyChannel(sourceBitmap:BitmapData, sourceRect: Rectangle, destPoint:Point, sourceChannel:Number, destChannel: Number: Void

Transfers data from one channel of another BitmapData object or the current BitmapData object into a channel of the current BitmapData object.

 

copyPixels(sourceBitmap:BitmapData, sourceRect :Rectangle, destPoint:Point, [alphaBitmap:BitmapData] , [alphaPoint:Point, [mergeAlpha:Boolean] ) : Void

Provides a fast routine to perform pixel manipulation between images with no stretching, rotation, or color effects.

 

dispose() : Void

Frees memory that is used to store the BitmapData object.

 

draw(source:Object, [matrix:Matrix],[colorTransform:ColorTransform],[blendMode:Object],[cliprect:Rectangle],[smooth:Boolean]) : Void

Draws a source image or movie clip onto a destination image, using the Flash Lite player vector renderer.

 

fillRect(rect:Rectangle,color:Number) : Void

Fills a rectangular area of pixels with a specified ARGB color.

 

floodFill(x:Number, y:Number, color:Number) : Void

Performs a flood fill operation on an image starting at an (x, y) coordinate and filling with a certain color.

 

generateFilterRect

Determines the destination rectangle that the applyFilter() method call affects, given a BitmapData object, a source rectangle, and a filter object.

Flash Lite does not support this method.

 

getColorBoundsRect(mask:Number, color:Number, [findColor:Boolean] ) :Rectangle

Determines a rectangular region that fully encloses all pixels of a specified color within the bitmap image.

 

getPixel(x:Number, y:Number) : Number

Returns an integer that represents an RGB pixel value from a BitmapData object at a specific point (x, y).

 

getPixel32(x:Number, y:Number) : Number

Returns an ARGB color value that contains alpha channel data and RGB data.

 

hitTest(firstPoint:Point, firstAlphaThreshold:Number, secondObject:Object, [secondBitmapPoint:Point] ,[secondAlphaThreshold:Number] ) :Boolean

Performs pixel-level hit detection between one bitmap image and a point, rectangle or other bitmap image.

static

loadBitmap(id:String): BitmapData

Returns a new BitmapData object that contains a bitmap image representation of the symbol that is identified by a specified linkage ID in the library.

 

merge(sourceBitmap:BitmapData, sourceRect:Rectangle, destPoint:Point, redMult:Number, greenMult:Number, blueMult:Number, alphaMult:Number) : Void

Performs per-channel blending from a source image to a destination image.

 

noise

Fills an image with pixels representing random noise.

Flash Lite does not support this method.

 

paletteMap

Remaps the color channel values in an image that has up to four arrays of color palette data, one for each channel.

Flash Lite does not support this method.

 

perlinNoise

Generates a Perlin noise image.

Flash Lite does not support this method.

 

pixelDissolve

Performs a pixel dissolve either from a source image to a destination image or by using the same image.

Flash Lite does not support this method.

 

scroll

Scrolls an image by a certain (x, y) pixel amount.

Flash Lite does not support this method.

 

setPixel(x:Number, y:Number, color:Number) : Void

Sets the color of a single pixel of a BitmapData object.

 

setPixel32(x:Number, y:Number, color:Number) : Void

Sets the color and alpha transparency values of a single pixel of a BitmapData object.

 

threshold

Tests pixel values in an image against a specified threshold and sets pixels that pass the test to new color values.

Flash Lite does not support this method.