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()
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
- The x position of the pixel.
x:Number
- The y position of the pixel.
y:Number
Returns
- A number that represents an RGB pixel value. If the (x, y) coordinates are outside
Number
the bounds of the image, 0 is returned.
Example
The following example uses the
specific x and y position.
import flash.display.BitmapData;
var myBitmapData:BitmapData = new BitmapData(100, 80, false, 0x00CCCCCC);
method returns an unmultiplied pixel value. No alpha
method to retrieve the RGB value of a pixel at a
getPixel()
BitmapData (flash.display.BitmapData)
313
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?