ByteArray to BitmapData

The Below code demonstrates the conversion of ByteArray to BitmapData. In the below case, SWF is loaded and converted into BitmapData

private function swfLoad_complete(evt:Event):void {
byteArrayToBitmapData(swf.content.loaderInfo.bytes);
}
private function byteArrayToBitmapData(ba:ByteArray):void {
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, getBitmapData);
loader.loadBytes(ba);
}
private function getBitmapData(e:Event):void {
var content:* = loader.content;
var BMPData:BitmapData = new BitmapData(content.width,content.height);
var UIMatrix:Matrix = new Matrix();
BMPData.draw(content, UIMatrix);
}

About these ads
    • david
    • April 8th, 2009

    can you help to decompile an swf file?

  1. The “loader.loadBytes” was very helpful. Did not think of that function.

    Thanks!

    • Ganga
    • December 4th, 2009

    Is it possible to load .tif images.. If so How can I achieve to load tif images?

    • avejidah
    • January 14th, 2010

    How about the other way around? BitmapData to ByteArray? I tried getPixels… but the bytearray is empty.

    • avejidah
    • January 14th, 2010

    Nm, figured it out.

    var rec:Rectangle = new Rectangle(0, 0, imgWidth, imgHeight);
    var ba:ByteArray = bmpData.getPixels(rec);

    • Gesse Goncalves
    • June 6th, 2010

    tanks
    obrigado
    gracias

    for help
    from Brasil

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 442 other followers

%d bloggers like this: