开发者

Flipping a PNG with Matrix

I'm having an issue flipping a png in AS3. The issue I'm having is that when I flip the image it is not keeping its transparency开发者_JS百科.

preApply = new BitmapData (Canvas.Bmp.width, Canvas.Bmp.height,true);
preApply.draw(Canvas.Bmp,myMatrix, null, null, null, true);

Any suggestions? The flip works its just it gives it a white background. I was able to run filters on the same image and that doesn't seem to give it a white background.

Update: Something strange I just found if I set the color for the BitmapData it keeps the transparency.

preApply = new BitmapData (Canvas.Bmp.width, Canvas.Bmp.height,true,0x0000FFFF);

Now my question kind of changes any idea why this might work?


That's easy, the default value for the fourth parameter of a bitmapData is what you want it to be initially filled with. So when you don't specify it as transparent (which is 0x000000FF or apparently 0x0000FFFF in this case also works) then it defaults to white, and when you draw your already transparent image onto this new opaque, white-filled image the alpha channel is overwritten by the white. This is because the draw command does not overwrite whatever is in the existing bitmapData with alpha channel information, only RGB values.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜