How can i get a BitmapData object out of a File ob

2019-05-21 01:13发布

So I am trying to create an image gallery. My AIR application accepts files that are dragged and dropped onto a TileList component. I am using the images as icons but the problem is that they take a long time to load so i want to compress the file data first (I have that part done) The problem is that I can't figure out how to open the file and put the data into a BitmapData object.

Any ideas?

1条回答
Fickle 薄情
2楼-- · 2019-05-21 01:45
var req:URLRequest = new URLRequest(value.file.url);
var ldr:Loader = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
ldr.load(req);
.
.
.
private function completeHandler(event:Event):void {
  var ldr:Loader = Loader(event.target.loader);
  var b:Bitmap = Bitmap(ldr.content);
}
查看更多
登录 后发表回答