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

转自:http://www.xncat.com/2010/02/catflash/875.html 在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)); }

你可能感兴趣的:(html)