首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

Flex 图片压缩、下传

2013-02-18 
Flex图片压缩、上传Flex? 图片压缩private function imgCompression(bytes:ByteArray):void{var loader:Loa

Flex 图片压缩、上传

Flex? 图片压缩

private function imgCompression(bytes:ByteArray):void{var loader:Loader = new Loader();loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function():void{var bm:Bitmap=loader.content as Bitmap;var bmd:BitmapData;if((bm.width>=bm.height)&&bm.width>maxSize){var rateW:Number=maxSize/bm.width;var h:Number=rateW*bm.height;bmd=new BitmapData(maxSize,h,true,0);bmd.draw(bm.bitmapData,new Matrix(rateW,0,0,rateW),null,null,null,true);bm=new Bitmap(bmd,PixelSnapping.ALWAYS,true);bmd = bm.bitmapData;}else if(bm.height>bm.width&&bm.height>maxSize){var rateH:Number=maxSize/bm.height;var w:Number=rateH*bm.width;bmd=new BitmapData(w,maxSize,true,0);bmd.draw(bm.bitmapData,new Matrix(rateH,0,0,rateH),null,null,null,true);bm=new Bitmap(bmd,PixelSnapping.ALWAYS,true);bmd = bm.bitmapData;}else{bmd = bm.bitmapData;}imgTT.source = bmd;});loader.loadBytes(bytes);}

??

热点排行