views:

41

answers:

3
var is:ImageSnapshot = myImagesnapshot;
var str:String = ImageSnapshot.encodeImageAsBase64(is);

As of now, I am sending my jpeg data to the server with the code above.
The problem is that it almost doubles the size of the data.
Is there a way to send the image data directly without using any encoding.

+1  A: 

base64 increases size by a third, so if you really have about 100% overhead, you have a problem elsewhere.

haven't looked at the sources to well, but from the reference it seems, you could retrieve the binary data directly.

just tuck that into a URLRequest and send it per POST.

greetz

back2dos

back2dos
A: 

You can save the snapshot as jpg or png.

Take a look at: http://blog.flexexamples.com/2007/12/07/using-the-imagesnapshot-class-to-capture-images-as-jpegs-or-pngs-in-flex-3/

michael
A: 

Here is a sample of sending image data without using Base64 :

 var myEncoder:JPGEncoder = new JPGEncoder(100);
 var byteArray:ByteArray = myEncoder.encode(bitmapData);
 var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
    var url:String = "../../default.php";
    var saveJPG:URLRequest = new URLRequest(url);
    saveJPG.requestHeaders.push(header);
    saveJPG.method = URLRequestMethod.POST;
    saveJPG.data = byteArray;

On PHP side, I need to access :

 $globalS["HTTP_raw_post_data"]
dta