问题描述
我要建一个应用程序使用ActionScript 3.0在我的Flash Builder中。这是一个后续问题this问题。
I'm building an App with actionscript 3.0 in my Flash builder. This is a followup question this question.
我需要的ByteArray上传到我的服务器,但我使用到BitmapData转换为ByteArray的功能是超级慢,很慢它冻结了我的移动设备。我的code是如下:
I need to upload the bytearray to my server, but the function i use to convert the bitmapdata to a ByteArray is super slow, So slow it freezes up my mobile device. my code is as follows:
var jpgenc:JPEGEncoder = new JPEGEncoder(50);
trace('encode');
//encode the bitmapdata object and keep the encoded ByteArray
var imgByteArray:ByteArray = jpgenc.encode(bitmap);
temp2 = File.applicationStorageDirectory.resolvePath("snapshot.jpg");
var fs:FileStream = new FileStream();
trace('fs');
try{
//open file in write mode
fs.open(temp2,FileMode.WRITE);
//write bytes from the byte array
fs.writeBytes(imgByteArray);
//close the file
fs.close();
}catch(e:Error){
有一种不同的方式将其转换为ByteArray?有没有更好的办法?在先进的感谢!
Is there a different way to convert it to a byteArray? is there a better way? thanks in advanced!
〜MYY
推荐答案
使用BitmapData.en code(),它的速度更快数量级上的移动订单<一href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html#en$c$c%28%29" rel="nofollow">http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html#en$c$c%28%29
Use BitmapData.encode(), it's faster by orders of magnitude on mobile http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html#encode%28%29
这篇关于JPEG EN codeR超慢,如何优化呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!