Flex 加载tiff
2024-10-19 13:35:31
gis系统常常要加载tiff,因为好多土地证书,各种文件都是扫描件,如果你是用as来写的前台,怎么加载呢,顺便说下用插件AlternaTIFF也是可以得不过浏览器加载这么多插件是不太好的。
首先TIFF格式不仅仅是一种格式,它有相当多的标准,我在github上找到的TestZaaIL是可以加载一部分tiff,但是我系统的就不行,我还跟作者聊过,他说最好的方法是用后台方式解析,c++之类写的库。我还去搞c++也醉了,但是我记得之前团队写过一个as3的tiff类库 测试代码如下
<?xml version="1.0" encoding="utf-8"?>
<mx:Application creationComplete="init()" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[ import tiff.Tiff;
//这是一个flex工程
private var loader:URLLoader;
private var tiff_img:Tiff;
private var currentPageCount:int;
[Bindable] private var bitmap:Bitmap; private function init():void{ loader=new URLLoader(new URLRequest("cenfax_1245134002_519_0.tiff"));//读取图片
loader.dataFormat=URLLoaderDataFormat.BINARY;
loader.addEventListener(Event.COMPLETE,onComplete); }
private function onComplete(e:Event):void{ var img:ByteArray=loader.data;
tiff_img=new Tiff;
tiff_img.read(img);//将图片数据传入,进行解码
showPage(0);//返回的是一个bitmapdata对象 }
//当按pre按钮
private function preClick():void{ showPage(currentPageCount-1); }
//当按next按钮
private function nextClick():void{ showPage(currentPageCount+1); }
//显示分页图片
private function showPage(num:int):void{ if(!(num>tiff_img.getPageCount()-1||num<0)){
bitmap=new Bitmap(tiff_img.getImage(num));
currentPageCount=num;
labelPage.text=num+1+"/"+tiff_img.getPageCount();
} }
]]>
</mx:Script>
<mx:Label id="labelPage" text="/" height="20" bottom="17" horizontalCenter="5"/>
<mx:Panel id="panel" layout="absolute" left="0" right="0" top="0" bottom="45">
<mx:Image id="image" source="{bitmap}">
</mx:Image>
</mx:Panel>
<mx:Button id="preBtn" label="Pre" left="122" bottom="10" click="preClick()"/>
<mx:Button id="nextBtn" label="Next" right="107" bottom="10" click="nextClick()"/>
</mx:Application>
具体源码下载http://files.cnblogs.com/files/haibalai/tifflib.rar 但是还是解决不了问题,tiff格式太广泛了,as想要还原所有解码还是麻烦,AlternaTIFF是一种不错解决方案了。
最新文章
- 锐捷linux客户端常用命令(主要用来连接校园网或公司局域网)
- 服务器搭建多个tomcat服务器
- ubuntu linux 下wine的使用
- tableView滚到最后一行
- webServices
- python练习程序_员工信息表_基本实例
- 安装php时,make test报错
- 武汉科技大学ACM :1001: 零起点学算法34——继续求多项式
- 省部级干部list
- 如何恢复未释放租约的HDFS文件
- Windows系统CredSSP漏洞修复
- 白话说java gc垃圾回收
- python之OpenCv(三)---基本绘图
- 集合-HashMap
- 一脸懵逼加从入门到绝望学习hadoop之Caused by: java.net.UnknownHostException: master报错
- linux服务器ssh防爆破
- day05_python_1124
- charles捕获手机端请求数据
- 【Canal源码分析】TableMetaTSDB
- Container [pid=6263,containerID=container_1494900155967_0001_02_000001] is running beyond virtual memory limits
热门文章
- hdu 1036 (I/O routines, fgets, sscanf, %02d, rounding, atoi, strtol) 分类: hdoj 2015-06-16 19:37 32人阅读 评论(0) 收藏
- GFT_News Auto
- rpm软件包管理
- [转]深入理解学习GIT工作流
- 跨服务器之间的session共享
- Block存储区域
- JDK各版本新特性!
- C语言编译和链接过程
- LeetCode() Issomorphic Strings
- C++宽窄字符串转换