| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace HySoft.BaseCallCenter.Web.faxmanage
- {
- public partial class faxtoimage : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- Response.Expires = -1;
- if (!Page.IsPostBack)
- {
- if (!string.IsNullOrEmpty(Request.QueryString["path"]))
- {
- try
- {
- string path = Request.QueryString["path"].ToString();
- string index = Request.QueryString["page"].ToString();
- showMulTif(path, Convert.ToInt32(index));
- }
- catch
- { }
- }
- }
- }
- /// <summary>
- /// 显示多页tif图片
- /// </summary>
- /// <param name="fielname">文件名</param>
- /// <param name="index">显示页码</param>
- public void showMulTif(string fielname, int index)
- {
- try
- {
- 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 - 1;
- if (index < 0)
- index = 0;
- 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();
- }
- catch
- { }
- }
- }
- }
|