Created
August 21, 2011 10:02
-
-
Save minodisk/1160416 to your computer and use it in GitHub Desktop.
BitmapDataを綺麗にリサイズ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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