View comments | RSS feed

BitmapData constructor

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

Creates a BitmapData object with a specified width and height. If you specify a value for the fillColor parameter, every pixel in the bitmap is set to that color.

By default, the bitmap is created as opaque, unless you pass the value true for the transparent parameter. Once you create an opaque bitmap, you cannot change it to a transparent bitmap. Every pixel in an opaque bitmap uses only 24 bits of color channel information. If you define the bitmap as transparent, every pixel uses 32 bits of color channel information, including an alpha transparency channel.

The maximum width and maximum height of a BitmapData object is 2880 pixels. If you specify a width or height value that is greater than 2880, a new instance is not created.

Availability: ActionScript 1.0; Flash Player 8

Parameters

width:Number - The width of the bitmap image in pixels.

height:Number - The height of the bitmap image in pixels.

transparent:Boolean [optional] - Specifies whether the bitmap image supports per-pixel transparency. The default value is true (transparent). To create a fully transparent bitmap set the value of the transparent parameter to true and the value of the fillColor parameter to 0x00000000 (or to 0).

fillColor:Number [optional] - A 32-bit ARGB color value that you use to fill the bitmap image area. The default value is 0xFFFFFFFF (solid white).

Example

The following example creates a new BitmapData object. The values in this example are the default values for the transparent and fillColor parameters; you could call the constructor without these parameters and get the same result.

import flash.display.BitmapData;

var width:Number = 100;
var height:Number = 80;
var transparent:Boolean = true;
var fillColor:Number = 0xFFFFFFFF;

var bitmap_1:BitmapData = new BitmapData(width, height, transparent, fillColor);

trace(bitmap_1.width); // 100
trace(bitmap_1.height); // 80
trace(bitmap_1.transparent); // true

var bitmap_2:BitmapData = new BitmapData(width, height);

trace(bitmap_2.width); // 100
trace(bitmap_2.height); // 80
trace(bitmap_2.transparent); // true

Version 8

Comments


shimi2 said on Sep 21, 2005 at 4:40 PM :
This line is incorrect:
By default, the bitmap is created as opaque, unless you pass the value true for the transparent parameter.
It should read: "By default, the bitmap is created as transparent, unless you pass the value false for the transparent parameter."
William_Donelson said on Sep 27, 2006 at 4:47 AM :
How do you capture a bitmap version of a movieClip or of the entire Stage?

 

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/00001944.html