无锯齿缩放图片【缩放时对位图进行平滑处理】
即时获得麻球游戏开发的最新消息,关注游戏开发者热门讨论,请各位开发者申请加入麻球官方群:121304476
也可以follow catfly围脖:t.sina.com.cn/iscat

在as3中,可以通过设置Bitmap的smoothing参数或属性值为true来实现在缩放时对位图进行平滑处理。
那么从外部加载的图片,如何获得图片的bitmapData对象?
可以这样,在图片加载完成的函数中:e.target.loader.content["bitmapData"]
下图是有无锯齿的对比效果:


设置bitmap的smoothing属性


var picLoad:Loader = new Loader();
picLoad.load(new URLRequest(picUrl));
picLoad.contentLoaderInfo.addEventListener(Event.COMPLETE,newLoadedFun);
private function newLoadedFun(e:Event):void{
	var bt:Bitmap = new Bitmap(e.target.loader.content["bitmapData"]);
	bt.smoothing = true;
	picContent.addChild(bt);
}

在创建Bitmap时参数中设置:
new Bitmap(e.target.loader.content["bitmapData"],”auto”,true)


var picLoad:Loader = new Loader();
picLoad.load(new URLRequest(picUrl));
picLoad.contentLoaderInfo.addEventListener(Event.COMPLETE,newLoadedFun);
private function newLoadedFun(e:Event):void{
	picContent.addChild(new Bitmap(e.target.loader.content["bitmapData"],"auto",true));
}

猫抓鱼

One Response to “无锯齿缩放图片【缩放时对位图进行平滑处理】”

Leave a Reply