`
sopestar
  • 浏览: 21390 次
  • 性别: Icon_minigender_1
  • 来自: 山东曹县
社区版块
存档分类
最新评论

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

阅读更多
转自: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)); }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics