Retrieving the Color of a Region of Pixels
package{
import flash.display.*;
import flash.geom.*;
import flash.utils.ByteArray;
public class Main extends Sprite{
public function Main(){
var blueSquare:BitmapData = new BitmapData(20, 20, false, 0xFF0000FF);
var greenSquare:BitmapData = new BitmapData(30, 30, false, 0xFF00FF00);
var rectRegion:Rectangle = new Rectangle(5, 5, 10, 10);
var greenPixels:ByteArray = greenSquare.getPixels(rectRegion);
greenPixels.position = 0;
blueSquare.setPixels(rectRegion, greenPixels);
var blueBmp:Bitmap = new Bitmap(blueSquare);
var greenBmp:Bitmap = new Bitmap(greenSquare);
addChild(blueBmp);
addChild(greenBmp);
greenBmp.x = 40;
}
}
}
Related examples in the same category