Working with images when uploading in Adobe Flex
I'm beginner with Flex and I already have a hard task to develop, so I could use some help! :)
What I have to do is upload some images to a server, which is OK, but开发者_开发问答 before uploading I must downsize this images by reducing their quality and width/height. I've found many information about the class JPGEncoder, but I couldn't make it work.
Could anyone help me with that?
Thanks! Rafael.
you can use encodeByteArray() method of JPEGEncoder. link
some good article for image uploading to server is available at 1. insideRIA 2. http://henryjones.us/articles/using-the-as3-jpeg-encoder 3. http://blog.pigdev.com/?p=137
Here is a little sample:
farg. this code editor leaves a little to be desired...
import mx.graphics.codec.JPEGEncoder;
private function btnClick(e:Event):void
{
var encoder:JPEGEncoder = new JPEGEncoder(0); // Terrible quality
picNew.source = encoder.encode( Bitmap(picOrig.content).bitmapData );
}
<mx:Image id="picOrig" x="10" y="10" source="image1.png"/>
<mx:Image id="picNew" x="200" y="10" />
<mx:Button x="100" y="300" label="Button" click="btnClick(event);"/>
精彩评论