0

I have two BitmapData objects with transparency enabled. One is a large red square, the other is a small blue circle.

If, for example, I position the blue circle over the red square. I would like to create an area of transparency in the red square's BitmapData where the blur circle is. Similar to how a mask works.

I have tried using getPixel32() operations but it is very slow (see below). Is there another way I can do this? Thanks

for(var x:int = 0; x < circleBitmapData.width; x++){
   for(var y:int = 0; y < circleBitmapData.width; y++){
       if(circleBitmapData.getPixel32(x,y) != 0x00000000){
           squareBitmapData.setPixel(x,y,0x00000000);
        }
   }
}

EDIT - I have one possible solution, but it's not ideal. I can merge the two bitmaps, then use the threshold method to turn pixels above a certain value to transparent. So I could set all blue pixels to transparent. However, I get a thin ring of blue around the transparent area

4

1 回答 1

0

查看 bitmapData 的阈值方法。它应该返回一个带有相交区域的 bitmapData。这样,您就不必再获取和设置像素了。此外, getPixel32 应该有 setPixel32 :P

于 2013-08-13T20:54:17.100 回答