我怎样才能从AIR本地JPEG文件获取BitmapData对象出一个文件对象? [英] How can i get a BitmapData object out of a File object from a local jpeg file in AIR?
本文介绍了我怎样才能从AIR本地JPEG文件获取BitmapData对象出一个文件对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以,我想创建一个图片库。我的AIR应用程序接受被拖拽到一个TileList组件文件。我使用的图像作为图标,但问题是,他们需要很长的时间来加载,所以我想COM preSS文件数据第一个(我的那部分做)的问题是,我无法弄清楚如何打开该文件,并把数据放入一个BitmapData对象。
任何想法?
解决方案
VAR REQ:的URLRequest =新的URLRequest(value.file.url);
VAR LDR:装载机=新的Loader();
ldr.contentLoaderInfo.addEventListener(引发Event.COMPLETE,在completeHandler);
ldr.load(REQ);
。
。
。
私有函数在completeHandler(事件:事件):无效{
VAR LDR:加载=加载程序(event.target.loader);
变种B:位图=位图(ldr.content);
}
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?
解决方案
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);
}
这篇关于我怎样才能从AIR本地JPEG文件获取BitmapData对象出一个文件对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文