I am editing an air application for a client, and he wants the images that you import to be scaled to 650x650 when you save them by using the code below. I tried changing the values but when the image is exported some part is missing:
function menuItemClick1(event:Event):void{
var mat:Matrix = new Matrix();
mat.scale(2.0,2.0);
var bmpData:BitmapData = new BitmapData(this.template_mc.width * 2, this.template_mc.height * 2, false, 0xFFFFFF);
bmpData.draw(this.template_mc, mat);
var _bmp:Bitmap = new Bitmap(bmpData);
_bmp.smoothing = true;
//
imgBytes = PNGEncoder.encode(_bmp.bitmapData);
fs = new FileStream();
targetFile = File.desktopDirectory.resolvePath("icons/image.png");
targetFile.browseForSave("Save Your File");
targetFile.addEventListener(Event.SELECT, onSaveSelect);
}
I tried changing to this with no luck:
mat.scale(1.0,1.0);
var bmpData:BitmapData = new BitmapData(650,650, false, 0xFFFFFF);
Calculate matrix scale ratio this way:
var mat:Matrix = new Matrix();
var ratio:Number =Math.min(650/this.template_mc.width,650/this.template_mc.height);
mat.scale(ratio,ratio);
var bmpData:BitmapData = new BitmapData(650, 650, false, 0xFFFFFF);
bmpData.draw(this.template_mc, mat);