Hi there,

This must be really simple but I just can't find the solution...

How do I decode a jpeg-encoded byte array so that I can draw/display an image from it?


The set pixels method obviously only works for raw image byte arrays.


                private function doEncodingAndDecoding():void
                {
                        
                        
                        var originalBitMap:Bitmap = Bitmap(image1.content);
                        
                        var encoder:JPEGEncoder = new JPEGEncoder();
                        
var myCompressedByteArray:ByteArray = encoder.encode(originalBitMap.bitmapData);
                        myCompressedByteArray.position = 0;
                        
                        
                        
var newBitmapData:BitmapData = new BitmapData(image1.content.width, image1.content.height);
                        var myRect:Rectangle = newBitmapData.rect;
                        
                        
                        //  :-(
                        newBitmapData.setPixels(myRect,myCompressedByteArray);

                        //
                        
                        var newBitmap:Bitmap = new Bitmap(newBitmapData);
                        
                        image2.source = newBitmap;
                        
                        
                        
                }




Thanks for any input!

Robin 

Reply via email to