ByteArray to BitmapData


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. import flash.display.Loader;
  2. import flash.display.LoaderInfo;
  3. import flash.events.Event;
  4. import flash.display.BitmapData;
  5.  
  6. var loader:Loader = new Loader();
  7. loader.loadBytes(byteArray);
  8. loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderComplete);
  9.  
  10. private function loaderComplete(event:Event):void
  11. {
  12.     var loaderInfo:LoaderInfo = LoaderInfo(event.target);
  13.     var bitmapData:BitmapData = new BitmapData(loaderInfo.width, loaderInfo.height, false, 0xFFFFFF);
  14.     bitmapData.draw(loaderInfo.loader);
  15.     // result: bitmapData
  16. }

URL: http://blog.yoz.sk/2009/10/bitmap-bitmapdata-bytearray/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.