I've loaded a JPG with dimensions 3264x2448 into a开发者_如何学Go Sprite. How can I resize it proprtionally to allow meto draw the Sprite into a BitmapData object (which in CS3/Flash Player 9 is limited to 2880 height or width). My goal is to use the Soulwire [DisplayUtils][1] to create a thumbnail. Here is the code that works fine with other, smaller, Sprites:
var bmpd:BitmapData = new BitmapData(jpgSprite.width, jpgSprite.height, true, 0x00FFFFFF);
bmpd.draw( jpgSprite );
var thumb:Bitmap = DisplayUtils.createThumb( bmpd, 100, 100, Alignment.MIDDLE, true);
addChild( thumb );
thanks for your suggestions.
I guess using a matrix to scale it down might do the trick. I haven't tested the code though.
var w:Number = 3264;
var h:Number = 2448;
var scale:Number = w / 2880;
var bmpd:BitmapData = new BitmapData(2880, h / scale, true, 0x00FFFFFF);
var matrix:Matrix = new Matrix();
matrix.createBox(scale, scale)
bmpd.draw(jpgSprite, matrix);
精彩评论