开发者

Crop image under mask

I have this image over which i have 开发者_如何学运维a circular crop. The user can move the underlying image and when he is ok with the result hits the crop button. How can i crop only that part of the image which is under the mask?


Create a new BitmapData, then use its draw() function to draw the pixels from the masked object.

For example, say you have a srcImg and a destImg, both Images defined in MXML:

protected function cropImg():void {
    var bd:BitmapData = new BitmapData(maskObj.width, maskObj.height, true, 0);
    bd.draw(srcImg, new Matrix());
    var bmp:Bitmap = new Bitmap(bd);
    destImg.source = bmp;
}

HTH;

Amy

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜