Thursday, November 29, 2007

放大 Bitmap 的時候(或是內含Bitmap 的 DisplayObject) 可提昇Display 品質的參數



// 設定了 smoothing, pixelSnapping 後就好很多

var tempBitmapData:BitmapData;
var tempBitmap:Bitmap;
var temp_mc:MovieClip;
temp_mc = new MovieClip();

function mc2Bitmap(mc1:MovieClip):BitmapData {
var myBitmap:BitmapData = new BitmapData(mc1.width, mc1.height, true, 0);
myBitmap.draw(mc1);
return myBitmap;
}


tempBitmapData = mc2Bitmap( new WhiteBackBoy1());
// WhiteBackBoy1 : 有內容的 MovieClip (自這裡是把他的內容"印"成 BitmapData )

tempBitmap = new Bitmap( tempBitmapData );
tempBitmap.pixelSnapping = PixelSnapping.AUTO;
tempBitmap.smoothing = true;

temp_mc.addChild( tempBitmap );
addChild( temp_mc );

stage.addEventListener( KeyboardEvent.KEY_DOWN , KeyDownEventHandler);


function KeyDownEventHandler(event:KeyboardEvent) {
if (event.keyCode == Keyboard.UP) {
trace("Keyboard.UP");
temp_mc.scaleX *= 1.1;
temp_mc.scaleY *= 1.1;
} else if (event.keyCode == Keyboard.DOWN) {
trace("Keyboard.DOWN");
temp_mc.scaleX /= 1.1;
temp_mc.scaleY /= 1.1;
}
}



No comments: