1 Reply Latest reply on Jan 15, 2012 4:51 PM by AlastairJMoore

    JPEGEncoder running on iPad 2 impossibly slow


      Hello all,


      I'm having a bit of a problem with the JPEGEncoder where I'm encoding a small (around 700 x 500px) image captured from the camera.


      A snippet of my code looks like:


      if (CameraRoll.supportsAddBitmapData)                     {

            var bitmapData:BitmapData = new BitmapData(mpLoaderInfo.width, mpLoaderInfo.height);


            // this.selectedImage.source = mpLoaderInfo.loader;

            var scale:Number = 3;

            var matrix:Matrix = new Matrix();

            matrix.scale(scale, scale);

            var smallBitmapData:BitmapData = new BitmapData(bitmapData.width * scale, bitmapData.height * scale, true, 0x000000);

            smallBitmapData.draw(bitmapData, matrix, null, null, null, true);


            this.selectedImage.source = smallBitmapData;

            trace('jpeg encoding');

            var jpgEncode:JPEGEncoder = new JPEGEncoder();

            var ba:ByteArray = jpgEncode.encodeBMP(smallBitmapData);

            trace('finished jpeg encoding');



      Encoding is taking around 30 seconds to a minute to complete - I'm using the JPEGEncoder from https://github.com/ianmclean/Chunking-JPEG-encoder which I believe to be based on Thibault's code. While I realise the processor isn't the fastest ever, surely it shouldn't be taking such a long time to encode such a small image?


      Thanks in advance!