简体   繁体   English

通过使用ActionScript3.0和Flex3.0选择图像的一部分来裁剪图像

[英]to crop a image by selecting part of imageusing ActionScript3.0 and Flex3.0

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 应该在ActionScript 3.0和Flex 3.0中完成

warm rgds, 温暖的rgds,

You can use BitmapData.copyPixels() for this. 您可以为此使用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;

copyPixels() method copyPixels() 方法

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. 此方法将源图像的矩形区域复制到目标BitmapData对象的目标点处相同大小的矩形区域。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM