문제

I'm trying to draw PNGs onto BitmapData that is transparent.

I create my BitmapData like this (using ARGB for the color):

new BitmapData(width, height, true, 0x00000000);

And clean it by using the same ARGB value:

bitmapData.fillRect(bitmapData.rect, 0x00000000);

When I use copyPixels() to draw graphics onto the cleaned BitmapData, I get this result:

enter image description here

If I don't use ARGB for the BitmapData color, it works fine:

enter image description here

But I have to specify a solid fillColor, meaning I can't render what's behind the Bitmap.

How can I make my BitmapData transparent, but not have the above occur?

도움이 되었습니까?

해결책

From the documentation on BitmapData::CopyPixels():

"The mergeAlpha property controls whether or not the alpha channel is used when a transparent image is copied onto another transparent image. To copy pixels with the alpha channel data, set the mergeAlpha property to true. By default, the mergeAlpha property is false."

For once the Adobe documentation actually speaks the truth.

copyPixels(myPNG, rect, point, null, null, true);

... should fix it (and did). Guessing it's turned off by default for performance reasons, because I can't really think of a place where it'd be useful to have it off.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top