如何从AIR中的本地jpeg文件中获取File对象中的BitmapData对象?

时间:2023-01-21 21:19:06

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.

所以我想创建一个图库。我的AIR应用程序接受拖放到TileList组件上的文件。我使用图像作为图标但问题是他们需要很长时间才能加载所以我想首先压缩文件数据(我已完成那部分)问题是我无法弄清楚如何打开文件并将数据放入BitmapData对象。

Any ideas?

1 个解决方案

#1


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);
}

#1


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);
}