Flash 8 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > BitmapData (flash.display.BitmapData) > getPixel32 (BitmapData.getPixel32 method) | |||
public getPixel32(x:Number, y:Number) : Number
Returns an ARGB color value that contains alpha channel data and RGB data. This method is similar to the getPixel() method, which returns an RGB color without alpha channel data.
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 represent an ARGB pixel value. If the (x, y) coordinates are outside the bounds of the image, 0 is returned. If the bitmap was created as an opaque bitmap and not a transparent one, then this method will return an error code of -1.
The following example uses the getPixel32() method to retrieve the ARGB value of a pixel at a specific x and y position:
import flash.display.BitmapData;
var myBitmapData:BitmapData = new BitmapData(100, 80, true, 0xFFAACCEE);
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());
var alpha:String = (myBitmapData.getPixel32(0, 0) >> 24 & 0xFF).toString(16);
trace(">> alpha: " + alpha); // ff
var red:String = (myBitmapData.getPixel32(0, 0) >> 16 & 0xFF).toString(16);
trace(">> red: " + red); // aa
var green:String = (myBitmapData.getPixel32(0, 0) >> 8 & 0xFF).toString(16);
trace(">> green: " + green); // cc
var blue:String = (myBitmapData.getPixel32(0, 0) & 0xFF).toString(16);
trace(">> blue: " + blue); // ee
trace("0x" + alpha + red + green + blue); // 0xffaaccee
getPixel (BitmapData.getPixel method)
Version 8
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/00001956.html
Comments
katopz@sleepydesign.com said on Mar 31, 2006 at 1:12 AM : panell said on Sep 27, 2006 at 7:25 AM : evanwingerden said on Nov 16, 2006 at 1:02 PM :