View comments | RSS feed

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.

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, __proto__, prototype, __resolve


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.

 

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 reresents 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, hasOwnProperty, isPropertyEnumerable, isPrototypeOf, registerClass, toString, unwatch, valueOf, watch



Version 8

Comments


dubnet.co.uk said on Oct 9, 2005 at 3:34 PM :
is it possible to serialize the data stored in the BitmapData object?

it would then be possible to persist the data.
NZRoadKill said on Oct 14, 2005 at 2:27 PM :
You can serialize the data simply by iterating over the entire height and width of the bitmap using getPixel. Then saving all of the returned values to a file.
joeyinflorida said on Dec 14, 2005 at 11:15 AM :
how would you save the data from getPixel?
icktoofay said on Feb 10, 2006 at 10:04 PM :
Using a Backend PHP or ASP or whatever script.
Flash-Ripper.com said on Apr 11, 2006 at 7:48 AM :
Does anybody tried to print bitmapData? I have problems with printing it: there's only grey rectangles instead of pictures on paper. Any suggestions?
jaredly2 said on Nov 20, 2006 at 12:07 PM :
I'm also having problems printing BitmapData. On my Mac it prints perfectly but on a Windows XP machine it will print everything but the BitmapData. I'm using the built in PrintJob Class. This seams really strange to me.
rachan@adobe said on Dec 4, 2006 at 4:38 PM :
In property summary:
Only width, height, transparent and fillColor are properties.
"rectangle" is not the property for BitmapData.
Ɓukasz Grela said on Jan 8, 2007 at 3:00 PM :
I have problems with printing BitmapData object (movie clip which projects that object) but different than prev post I can see picture but with wrong colours, only purple ones, I've created this BitmapData obj like this:

canvas_bmp = new BitmapData(p_mcSource._width, p_mcSource._height, true, 0x00FFffFF);

any ideas?
fillcell Gerra said on May 14, 2007 at 2:22 PM :
I got a problem on merging transparent bitmaps, which seems a bit difficult to explain. Please take a look on it on our server, if you can. I've uploaded it with pictures, SWF, and some source.

http://www.fillcell.com/poster
webweber said on Jul 10, 2007 at 7:35 AM :
For printing Bitmapdata objects with the Printjob class, it is important to specify the 3rd argument of the Printjob.addPage() method:

my_pj.addPage(someClip, null, {printAsBitmap:true});

As many people have problems printing Bitmapdata, this point should be clarified in the docs - here and in the PrintJob class.
extol said on Jul 29, 2007 at 11:30 PM :
I have tried that and still get nothing
No screen name said on Aug 18, 2008 at 9:56 AM :
some next time

 

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

Current page: http://livedocs.adobe.com/flash/8/main/00001942.html