无锯齿缩放图片【缩放时对位图进行平滑处理】

无锯齿缩放图片【缩放时对位图进行平滑处理】

catfly 2010年02月28日,星期天

在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));
}

猫抓鱼
原文地址:https://www.cnblogs.com/niuniu502/p/1831259.html