Flex 이미지 압축, 업로드

1300 단어 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);
			}

좋은 웹페이지 즐겨찾기