使用加载器在 Flash 10 中加载 .bmp(位图)和 .tiff 文件 [英] Loading .bmp (Bitmap) and .tiff file in Flash 10 using a Loader

查看:29
本文介绍了使用加载器在 Flash 10 中加载 .bmp(位图)和 .tiff 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Flash 10 开发图片上传器.我使用 FileReference 对象来浏览图像和加载器来显示图像:

示例代码:

var tempFileRef:FileReference = FileReference(ev.target);var oLoader:Loader = new Loader();oLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoad);oLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError);oLoader.loadBytes(tempFileRef.data);

它适用于 .jpg.gif 文件,但是当我浏览 .bmp 或 .tiff 文件时,出现错误:

错误 #2124:加载的文件类型未知.

有没有办法从桌面加载和显示浏览过的 .bmp 图像?

谢谢

解决方案

来自 Spark 库的 BMPDecoder 类:http://www.libspark.org/svn/as3/BMPDecoder/src/com/voidelement/images/BMPDecoder.as

用法示例:http://hi.baidu.com/leyhui/blog/item/d12be8b116ec915308230298.html

关于 TIFFDecoder,它仍在进行中,但非常有前途:

http://code.google.com/p/windowsbitmapdencoder/>

I am developing a Image uploader using Flash 10. I am using FileReference object to browse images and Loader to show the image:

Sample code:

var tempFileRef:FileReference = FileReference(ev.target);
var oLoader:Loader = new Loader();
oLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoad);
oLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
oLoader.loadBytes(tempFileRef.data);

It works fine with .jpg and .gif files but when I browse .bmp or .tiff file, I am getting the error:

Error #2124: Loaded file is an unknown type.

Is there a way to load and display browsed .bmp images from desktop?

Thanks

解决方案

BMPDecoder class from Spark lib: http://www.libspark.org/svn/as3/BMPDecoder/src/com/voidelement/images/BMPDecoder.as

Example of the usage: http://hi.baidu.com/leyhui/blog/item/d12be8b116ec915308230298.html

Regarding TIFFDecoder, it is still work in progress, but very promising one:

http://code.google.com/p/windowsbitmapdencoder/

这篇关于使用加载器在 Flash 10 中加载 .bmp(位图)和 .tiff 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆