What is the best way to resize a BitmapData object?

Iain picture Iain · Jun 8, 2009 · Viewed 52.4k times · Source

Say I have a BitmapData of 600x600 and I want to scale it down to 100x100.

Answer

Iain picture Iain · Jun 8, 2009

This works:

var scale:Number = 1.0/6.0;
var matrix:Matrix = new Matrix();
matrix.scale(scale, scale);

var smallBMD:BitmapData = new BitmapData(bigBMD.width * scale, bigBMD.height * scale, true, 0x000000);
smallBMD.draw(bigBMD, matrix, null, null, null, true);

var bitmap:Bitmap = new Bitmap(smallBMD, PixelSnapping.NEVER, true);