03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example<br />

The following example shows how to determine a rectangular region that fully encloses all<br />

pixels of a specified color within the bitmap image:<br />

import flash.display.BitmapData;<br />

import flash.geom.Rectangle;<br />

var myBitmapData:BitmapData = new BitmapData(100, 80, false, 0x00CCCCCC);<br />

var mc:MovieClip = this.createEmptyMovieClip("mc",<br />

this.getNextHighestDepth());<br />

mc.attachBitmap(myBitmapData, this.getNextHighestDepth());<br />

myBitmapData.fillRect(new Rectangle(0, 0, 50, 40), 0x00FF0000);<br />

mc.onPress = function() {<br />

var colorBoundsRect:Rectangle =<br />

myBitmapData.getColorBoundsRect(0x00FFFFFF, 0x00FF0000, true);<br />

trace(colorBoundsRect); // (x=0, y=0, w=50, h=40)<br />

}<br />

getPixel (BitmapData.getPixel method)<br />

public getPixel(x:Number, y:Number) : Number<br />

Returns an integer that represents an RGB pixel value from a BitmapData object at a specific<br />

point (x, y). The getPixel() method returns an unmultiplied pixel value. No alpha<br />

information is returned.<br />

All pixels in a BitmapData object are stored as premultiplied color values. A premultiplied<br />

image pixel has the red, green, <strong>and</strong> blue color channel values already multiplied by the alpha<br />

data. For example, if the alpha value is 0, the values for the RGB channels are also 0,<br />

independent of their unmultiplied values.<br />

This loss of data can cause some problems when you are performing operations. All Flash<br />

Player methods take <strong>and</strong> return unmultiplied values. The internal pixel representation is<br />

unmultiplied before it is returned as a value. During a set operation, the pixel value is<br />

premultiplied before setting the raw image pixel.<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 8<br />

Parameters<br />

x:Number - The x position of the pixel.<br />

y:Number - The y position of the pixel.<br />

BitmapData (flash.display.BitmapData) 321

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!