1
votes

I'm resizing a bitmapData the usual way, using a Matrix. The bitmapData has an alpha channel (it comes from a PNG), and the alpha channel is ignored...

var m:Matrix = new Matrix();
m.scale(.5, .5);

var bmp:BitmapData = new BitmapData(bitmapData.width * .5, bitmapData.height * .5,true);
bmp.draw(bitmapData,m);

var resizedBitmap = new Bitmap(bmp);

I've added the third parameter true to the BitmapData() constructor to support alpha channel, but I'm still loosing all the transparency after the draw() call. What's wrong?

1

1 Answers

4
votes

The solution to this problem comes from adding the fourth parameter (fillColor) to the BitmapData constructor.

var bmp:BitmapData = new BitmapData(bitmapData.width * .5, bitmapData.height * .5,true,0x00000000);

From the documentation:

To create a fully transparent bitmap, set the value of the transparent parameter to true and the value of the fillColor parameter to 0x00000000 (or to 0).