3
I need to load the image bytecodes inside a String
and then convert to Bitmap
. I am using the code below but without success:
var urlLoader:URLLoader = new URLLoader();
urlLoader.load(new URLRequest("imagebytecode.txt"));
urlLoader.addEventListener(Event.COMPLETE, loaded);
function loaded(e:Event):void {
var str:String = urlLoader.data;
var byteArray:ByteArray = new ByteArray();
byteArray.writeUTFBytes(str);
var bitData:BitmapData = new BitmapData(100, 100);
var rec:Rectangle = new Rectangle(0, 0, 100, 100);
bitData.setPixels(rec, byteArray);
var bit:Bitmap = Bitmap(bitData);
}
When I encode the image for Base64
and open it using Steve Webster’s library, it works correctly.
Thank you for the reply Jan Cassio!
– bio
Unfortunately it hasn’t helped yet. See the following procedure I want to do: "Bytecodeimage -> String -> Bitmap = goes wrong". When I do "Bytecodeimagem64 -> String -> Decodificar64 -> Bitmap works"! Another observation is that the Base64decoder class is unfortunately for Flex and I am using Flash that does not use the mx.util package. Thanks anyway!
– bio
In this case, you can use any Base64 for AS3, take a look at this class, think it has everything you need. https://gist.github.com/burakkirkil/4051420
– Jan Cássio
Sorry but it is not a Base64 image that I want to turn into String and then into Bitmap, but a common image. I quoted this encoding because when I use it it works normally and I have no doubts regarding this library. Still thank you!
– bio