Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top