1 apache-flex flex3 actionscript-3
通过在其上绘制矩形将图像裁剪为选定的大小.它应该在ActionScript 3.0和Flex 3.0中完成
温暖的rgds,
你可以用BitmapData.copyPixels()它.
//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;
Run Code Online (Sandbox Code Playgroud)
copyPixels() 方法
public function copyPixels(sourceBitmapData:BitmapData, sourceRect:Rectangle,
destPoint:Point, alphaBitmapData:BitmapData = null, alphaPoint:Point = null,
mergeAlpha:Boolean = false):void
Run Code Online (Sandbox Code Playgroud)
提供快速例程,在没有拉伸,旋转或颜色效果的图像之间执行像素操作.此方法会复制源图像的矩形区域,以在目标BitmapData对象的目标点的相同尺寸的矩形区域.