Skip to content

Instantly share code, notes, and snippets.

@minodisk
Created August 21, 2011 10:02
Show Gist options
  • Save minodisk/1160416 to your computer and use it in GitHub Desktop.
Save minodisk/1160416 to your computer and use it in GitHub Desktop.
BitmapDataを綺麗にリサイズ
public function resizeLowQuality(src:BitmapData, width:Number, height:Number):BitmapData {
var matrix:Matrix = new Matrix();
matrix.scale(width / src.width, height / src.height);
var dst:BitmapData = new BitmapData(width, height, true, 0);
dst.draw(src, matrix, null, null, null, true);
return dst;
}
public function resizeHighQuality(src:BitmapData, width:Number, height:Number):BitmapData {
var bitmap:Bitmap = new Bitmap(src, 'auto', true);
bitmap.width = width;
bitmap.height = height;
var tmp:Sprite = new Sprite();
tmp.addChild(bitmap);
var dst:BitmapData = new BitmapData(width, height, true, 0);
dst.draw(tmp, null, null, null, null, true);
return dst;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment