惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

I
InfoQ
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
B
Blog
罗磊的独立博客
GbyAI
GbyAI
博客园 - 三生石上(FineUI控件)
雷峰网
雷峰网
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Microsoft Security Blog
Microsoft Security Blog
宝玉的分享
宝玉的分享
The GitHub Blog
The GitHub Blog
人人都是产品经理
人人都是产品经理
博客园 - Franky
有赞技术团队
有赞技术团队
WordPress大学
WordPress大学
博客园 - 聂微东
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Visual Studio Blog
MyScale Blog
MyScale Blog
Google DeepMind News
Google DeepMind News
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏

博客园 - hong

VBA命令按钮操作 - hong - 博客园 VBA访问word菜单 - hong - 博客园 RUP核心概念解析 RUP 核心概念 IBM Rational 技术文档下载 项目管理规范-RUP管理实施 感叹人生 遗憾 C#中的类型相等与恒等(Equality & Identity) Windows Vista workshop 理解抽象类和接口 线程概念 开始找工作了 BI理解 Web Service基础 改变人的一生的五句话 堆和栈的区别 sql日期转换问题 Visual Studio Team System资源
在web页面中显示多页的tif文件
hong · 2006-05-31 · via 博客园 - hong

一、显示指定index页序号的tiff图片

1、通过页面显示

在显示页面里:<img src="showtif.aspx" border=0>

采用类似于验证码的显示方法

showtif.aspx的页面代码写成下面:(该页不带后台代码)

<%@ Page language="c#" %>

<%@ Import Namespace="test"  %>

<% bind.showMulTif("img/aaa.tif",1);%>

方法showMulTif如下定义

        /// <summary>
        
/// 显示多页tif图片
        
/// </summary>
        
/// <param name="fielname">文件名</param>
        
/// <param name="index">显示页码</param>

        public static void showMulTif(string fielname,int index)
        
{
            HttpContext context 
= HttpContext.Current;
            
string bgFilePath = context.Server.MapPath(fielname);
            System.Drawing.Image imgObj 
= System.Drawing.Image.FromFile(bgFilePath);

            
//获得第index页的图片
            Guid objGuid   =(imgObj.FrameDimensionsList[0]);
            System.Drawing.Imaging.FrameDimension objDimension  
=new System.Drawing.Imaging.FrameDimension(objGuid);
            
//总页数
            int totFrame   ;
            totFrame
=imgObj.GetFrameCount(objDimension);

            
if (index>totFrame)
                index
=totFrame;
            
if (index<1)
                index
=1;
               
            imgObj.SelectActiveFrame(objDimension,index);


            
// 设置输出的MIME类型
            context.Response.ContentType = "image/gif";
            
// 输出文件流到浏览器中
            
//
            imgObj.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
            
// 释放资源
            context.Response.Flush();
            context.Response.End();
        }


2、通过下载打开的方式,利用ioffice带的工具或图片查看器浏览

二、tif转换为jpg文件

将tif转换成多个jpge或者gif拉  

  public   int   SavePic(string   fullPath,int   index)   
  
{   
  
//使指定的页码在本图片的范围内   
  if(index   <   0   ||   index   >   this.frameNumber)   
  
{   
  index   
=   0;   
  }
   
    
  
//将指定的一页画到saveGif上,其中saveGif为指定的大小   
  Point   ulCorner   =   new   Point(0,   0);   
  Point   urCorner   
=   new   Point(this.saveWidth,0);   
  Point   llCorner   
=   new   Point(0,   this.saveHeight);   
  Point[]   destPara   
=   {ulCorner,   urCorner,   llCorner};   
    
  saveGif
=   new   Bitmap(this.saveWidth,this.saveHeight);   
  Graphics   save   
=   Graphics.FromImage(saveGif);   
  openTif.SelectActiveFrame(frameDime,index);   
  save.DrawImage(openTif,destPara);   
  save.Dispose();   
  save   
=   null;   
    
  
//将图片保存   
  saveGif.Save(fullPath,ImageFormat.Gif);   
  saveGif.Dispose();   
  saveGif   
=   null;   
    
  
return   1;   
  }