【发布时间】:2011-05-20 15:41:34
【问题描述】:
我有一个填充 Shape,以及一个与 Shape 的边界框宽度和高度相同的 BitmapData。
我需要从 BitmapData 中剪切形状(基本上将 BitmapData 绘制到形状上......)[像这样:http://imgur.com/uwE5F.png]
我使用了相当老套的方法:
public static function cutPoly(img:BitmapData, s:Shape, bounds:Bounds):BitmapData {
var temp:BitmapData = new BitmapData(bounds.width, bounds.height, true);
Main.inst.stageQuality("low"); //hack to kill anti-aliasing
temp.draw(s,new Matrix());
Main.inst.stageQuality("high"); // end hack
//0xFF00FF00 is the color of the shape
makeColTrans(temp,0xFF00FF00); //makes the color transparent :P
//return temp;
img.draw(temp);
//img.draw(temp);
temp.dispose();
makeColTrans(img, 0xFFFFFFFF);
return img;
}
我想知道是否有更好的方法...不仅仅是一种 hack。
【问题讨论】:
标签: flash actionscript-3 actionscript bitmap bitmapdata