views:

278

answers:

2

Hi there!

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.

A: 

Hi

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

Chinmay
Hi Chinmay,Thanks for your reply. So far, I've got this:private function uploadImage():void{ _netConnection = new NetConnection(); _netConnection.connect('http://192.168.1.254/teste2.php'); var res:Responder = new Responder(onDataResult, onDataError); _netConnection.call("",res,_imageByteArray);}And my PHP "teste2.php" simply opens an file with "w+" permission and implodes the $obj array passed by the above function. But all the script does is create a O bytes .jpg file.Could you please help e again with that?Thanks!
Rafael
A: 

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);"/>
Jon.Stromer.Galley