0

I need to find a way to copy a masked bitmap. I have a bitmap on stage, and a user drawn sprite that acts as a mask. I need to capture/copy the masked area bitmap, maintaining the transparency created by the masking to eventually encode as a png.

I could find no documentation on how to accomplish this using copyPixels(), or any other directions.

Thanks in advance for any assistance -

b

4

1 回答 1

1

我做了一个似乎有效的简单测试:

var square:Sprite = new Sprite();
var circle:Sprite = new Sprite();
var holder:Sprite = new Sprite();

square.graphics.beginFill(0,.5);
square.graphics.drawRect(0,0,100,100);
square.graphics.endFill();

circle.graphics.beginFill(0);
circle.graphics.drawCircle(0,0,50);
circle.graphics.endFill();

addChild(holder);
holder.addChild(square);
holder.addChild(circle);
square.mask = circle;

var cloneData:BitmapData = new BitmapData(holder.width,holder.height,true,0x00FFFFFF);
cloneData.draw(holder);
var clone:Bitmap = new Bitmap(cloneData);
addChild(clone);
clone.x = 30;

我正在创建一个 BitmapData 并使用draw()方法进行克隆。关键似乎是 BitmapData 构造函数中的最后两个参数。在通过 holder.width 和 holder.height 后,我​​指定我希望 bitmapData 是透明的(真)并在ARGB(alpha-red-green-blue)中填充透明白色(0x00FFFFFF )

希望这可以帮助 :)

于 2010-01-07T00:21:33.177 回答