是否有可能到选定的图像转换成的base64 EN codeD字符串?
Is it possible to convert an selected image into base64 encoded string?
将图像上传好的和简单的解决方案。 :)
Would be nice and easy solution for image uploader. :)
感谢;)
如果你想连接code加载图像的字节数组,你可以从mx.utils使用Base64En codeR类Base64En$c$cr.
If you're wanting to encode the byteArray of a loaded image, you could use the Base64Encoder class from mx.utils Base64Encoder.
是这样的:
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.load(new URLRequest("img.jpg"));
function loadComplete(e:Event):void {
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadComplete);
var bmd:BitmapData = Bitmap(e.target.content).bitmapData;
var ba:ByteArray = bmd.getPixels(new Rectangle(0,0,bmd.width,bmd.height));
var b64:Base64Encoder = new Base64Encoder();
b64.encodeBytes(ba);
trace(b64.toString());
}
我不得不追查类here.
此外,还有,我发现,但没有这里测试另外的Base64类......但看起来像它的工作原理类似。
Also, there's another Base64 class that I found but haven't tested here...but looks like it works similarly.
希望有所帮助。