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

推荐订阅源

博客园_首页
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
G
Google Developers Blog
B
Blog
Engineering at Meta
Engineering at Meta
阮一峰的网络日志
阮一峰的网络日志
The Register - Security
The Register - Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 叶小钗
The Cloudflare Blog
The Hacker News
The Hacker News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
雷峰网
雷峰网
F
Fortinet All Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
A
About on SuperTechFans
量子位
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
H
Help Net Security
Help Net Security
Help Net Security
P
Palo Alto Networks Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Troy Hunt's Blog
W
WeLiveSecurity
V
Vulnerabilities – Threatpost
T
The Exploit Database - CXSecurity.com
Know Your Adversary
Know Your Adversary
Apple Machine Learning Research
Apple Machine Learning Research
Scott Helme
Scott Helme
N
News | PayPal Newsroom
AWS News Blog
AWS News Blog
D
DataBreaches.Net
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
腾讯CDC
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
TaoSecurity Blog
TaoSecurity Blog
GbyAI
GbyAI
Y
Y Combinator Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
D
Docker

博客园 - 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;   
  }