Please file a bug so we can make this easier in 3.0.

 

Are you really going to use JPEGEncoder in the real app or do you get
your bytearray some other way?

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Kevin
Sent: Thursday, November 01, 2007 9:23 PM
To: [email protected]
Subject: [flexcoders] Convert ByteArray to Bitmap

 

After reading some previous posts, it appears that the best way to
convert a byte array into a Bitmap is though the loader class...

 

loader.loadBytes(myByteArray);

 

Thus, I created a simple test to see if I could get it to work.

 

private function myTest():void{

                        //get ByteArray from Image Component content

                        var testBM:Bitmap = testImg.content as Bitmap;

                        var myByte:ByteArray = new
JPEGEncoder().encode(testBM.bitmapData);

                        //convert ByteArray to Bitmap

                        var ldr:Loader = new Loader();

              ldr.loadBytes(myByte);

                                                

                        //reset source

                        myImage.source = ldr.content;

}

 

In my debugging it fails silently, but I get the follow message when I
try to look into the vars (Error: Error #2099: The loading object is not
sufficiently loaded to provide this information.)  Also the "content"
property is "null" even though the bytes are fully loaded.

 

Is there another better way to do this.  I have been struggling with
this all day.

 

Thanks, Kevin

 

 

 

Reply via email to