Skip navigation
Currently Being Moderated

Image to ByteArray synchronously

Oct 21, 2011 5:45 PM

Hello,

 

How can I turn a string image path to a ByteArray synchronously?

 

Thank you.

 
Replies
  • Currently Being Moderated
    Oct 23, 2011 9:50 PM   in reply to Francisc

    // import flash.display.BitmapData;

    // import com.adobe.images.JPGEncoder;

    // import flash.display.BitmapData;

    private static final function encodeToJPEG(data:BitmapData, quality:Number = 75):ByteArray

    {

        var encoder:JPGEncoder = new JPGEncoder(quality);

        return encoder.encode(data);

    }

     

    now load image to Image component as below :-

     

    var myImage:Image = new Image();

    myImage.source = "imagesource.jpg";

    // bitmapdata of uicomponent

    var myBitmapData:BitmapData = getUIComponentBitmapData(myImage);

    // jpeg byte array of uicomponent

    var jpgByteArray:ByteArray = encodeToJPEG(myBitmapData);

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 31, 2012 12:20 PM   in reply to highlightscript

    var myBitmapData:BitmapData = getUIComponentBitmapData(myImage);

     

    Where is that function coming from?

     

    I get a "call to undefined method" error......

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points