User Guide
BitmapData (flash.display.BitmapData) 313
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());
myBitmapData.fillRect(new Rectangle(0, 0, 50, 40), 0x00FF0000);
mc.onPress = function() {
var colorBoundsRect:Rectangle =
myBitmapData.getColorBoundsRect(0x00FFFFFF, 0x00FF0000, true);
trace(colorBoundsRect); // (x=0, y=0, w=50, h=40)
}
getPixel (BitmapData.getPixel method)
public 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). The
getPixel() method returns an unmultiplied pixel value. No alpha
information is returned.
All pixels in a BitmapData object are stored as premultiplied color values. A premultiplied
image pixel has the red, green, and blue color channel values already multiplied by the alpha
data. For example, if the alpha value is 0, the values for the RGB channels are also 0,
independent of their unmultiplied values.
This loss of data can cause some problems when you are performing operations. All Flash
Player methods take and return unmultiplied values. The internal pixel representation is
unmultiplied before it is returned as a value. During a set operation, the pixel value is
premultiplied before setting the raw image pixel.
Availability: ActionScript 1.0; Flash Player 8
Parameters
x:Number - The x position of the pixel.
y:Number - The y position of the pixel.
Returns
Number - A number that represents an RGB pixel value. If the (x, y) coordinates are outside
the bounds of the image, 0 is returned.
Example
The following example uses the
getPixel() method to retrieve the RGB value of a pixel at a
specific x and y position.
import flash.display.BitmapData;
var myBitmapData:BitmapData = new BitmapData(100, 80, false, 0x00CCCCCC);