How to use Flash BitmapData to enlarge an image without losing quality?

I am trying to scale an image in Flash without making it pixelated, I know I will lose some quality by zooming in, but I am not trying to scale 6x or anything :)

I tried to use matrix and scale, but the quality is just bad ... are there any other ways to do this?


so here is my code,

var _bmpData:BitmapData = new BitmapData( stage.stageWidth, stage.stageHeight, true, 0x00000000 );
var _scale:Number = Math.max(stage.stageWidth/_imageLoad.contentAsBitmap.width, stage.stageHeight/_imageLoad.contentAsBitmap.height)
var _matrix:Matrix = new Matrix();
_matrix.scale(_scale, _scale);

_bmpData.draw( _imageLoad.contentAsBitmap, _matrix, null, null, null, true);

var _bmp:Bitmap = new Bitmap( _bmpData, 'always', true );

      

The thing is, if I don't use a matrix everything is fine and doesn't pixelate, but if I use a matrix to scale it gets pixelated .... is there a way to fix this? thank

+2


source to share


1 answer


var myBitmap : Bitmap = new Bitmap(myBitmapData);
myBitmap.smoothing = true;

      



You can also look at the draw method for the BitmapData class, which has an anti-aliasing parameter. Obviously this won't help with the inherent image enhancement issues, but it might mitigate them a bit.

+4


source







All Articles