开发者

Flex sending snapshot without using base64Encode

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 almos开发者_Go百科t doubles the size of the data.

Is there a way to send the image data directly without using any encoding.


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.


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"]


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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜