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 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:

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.

Calls to any method or property of a BitmapData object fail if the BitmapData object is invalid (for example, if it has height == 0 and width == 0), and upon failing those properties and methods that return Number values return -1.

Availability: ActionScript 1.0; Flash Player 8

See also

attachBitmap (MovieClip.attachBitmap method), beginBitmapFill (MovieClip.beginBitmapFill method)

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:Number [read-only]

The width of the bitmap image in pixels.

Properties inherited from class Object

constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property)


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(sourceBitmap:BitmapData, sourceRect:Rectangle, destPoint:Point, filter:BitmapFilter) : Number

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

 

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.

 

compare(otherBitmapData:BitmapData) : Object

Compares two BitmapData objects.

 

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 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(sourceRect:Rectangle, filter:BitmapFilter) : Rectangle

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

 

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(randomSeed:Number, [low:Number], [high:Number], [channelOptions:Number], [grayScale:Boolean]) : Void

Fills an image with pixels representing random noise.

 

paletteMap(sourceBitmap:BitmapData, sourceRect:Rectangle, destPoint:Point, [redArray:Array], [greenArray:Array], [blueArray:Array], [alphaArray:Array]) : Void

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

 

perlinNoise(baseX:Number, baseY:Number, numOctaves:Number, randomSeed:Number, stitch:Boolean, fractalNoise:Boolean, [channelOptions:Number], [grayScale:Boolean], [offsets:Object]) : Void

Generates a Perlin noise image.

 

pixelDissolve(sourceBitmap:BitmapData, sourceRect:Rectangle, destPoint:Point, [randomSeed:Number], [numberOfPixels:Number], [fillColor:Number]) : Number

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

 

scroll(x:Number, y:Number) : Void

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

 

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(sourceBitmap:BitmapData, sourceRect:Rectangle, destPoint:Point, operation:String, threshold:Number, [color:Number], [mask:Number], [copySource:Boolean]) : Number

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

Methods inherited from class Object

addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.toString method), unwatch (Object.unwatch method), valueOf (Object.valueOf method), watch (Object.watch method)



Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00001393.html