To crop the image into a selected size by drawing rectangle over it. It should be done in ActionScript 3.0 and Flex 3.0
warm rgds,
To crop the image into a selected size by drawing rectangle over it. It should be done in ActionScript 3.0 and Flex 3.0
warm rgds,
You can use BitmapData.copyPixels()
for this.
//create a rectangle
var cropRect:Rectangle = new Rectangle(left, top, width, height);
//create new bitmap data - because BitmapData's width/height are read only
var bmpData:BitmapData = new BitmapData(cropRect.width, cropRect.height, true);
bmpData.copyPixels(image.bitmapData, cropRect, new Point(0, 0));
//assign the cropped bitmap data to the image.
image.bitmapData = bmpData;
copyPixels()
method
public function copyPixels(sourceBitmapData:BitmapData, sourceRect:Rectangle,
destPoint:Point, alphaBitmapData:BitmapData = null, alphaPoint:Point = null,
mergeAlpha:Boolean = false):void
Provides a fast routine to perform pixel manipulation between images with no stretching, rotation, or color effects. This method copies a rectangular area of a source image to a rectangular area of the same size at the destination point of the destination BitmapData object.