Flash 8 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > BitmapData (flash.display.BitmapData) > 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
x:Number - The x position of the pixel.
y:Number - The y position of the pixel.
Number - A number that represents an RGB pixel value. If the (x, y) coordinates are outside the bounds of the image, 0 is returned.
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);
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());
trace("0x" + myBitmapData.getPixel(0, 0).toString(16)); // 0xcccccc
getPixel32 (BitmapData.getPixel32 method)
Version 8
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/8/main/00001955.html