市长热线演示版

faxtoimage.aspx.cs 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. namespace HySoft.BaseCallCenter.Web.faxmanage
  8. {
  9. public partial class faxtoimage : System.Web.UI.Page
  10. {
  11. protected void Page_Load(object sender, EventArgs e)
  12. {
  13. Response.Expires = -1;
  14. if (!Page.IsPostBack)
  15. {
  16. if (!string.IsNullOrEmpty(Request.QueryString["path"]))
  17. {
  18. try
  19. {
  20. string path = Request.QueryString["path"].ToString();
  21. string index = Request.QueryString["page"].ToString();
  22. showMulTif(path, Convert.ToInt32(index));
  23. }
  24. catch
  25. { }
  26. }
  27. }
  28. }
  29. /// <summary>
  30. /// 显示多页tif图片
  31. /// </summary>
  32. /// <param name="fielname">文件名</param>
  33. /// <param name="index">显示页码</param>
  34. public void showMulTif(string fielname, int index)
  35. {
  36. try
  37. {
  38. HttpContext context = HttpContext.Current;
  39. string bgFilePath = context.Server.MapPath(fielname);
  40. System.Drawing.Image imgObj = System.Drawing.Image.FromFile(bgFilePath);
  41. //获得第index页的图片
  42. Guid objGuid = (imgObj.FrameDimensionsList[0]);
  43. System.Drawing.Imaging.FrameDimension objDimension = new System.Drawing.Imaging.FrameDimension(objGuid);
  44. //总页数
  45. int totFrame;
  46. totFrame = imgObj.GetFrameCount(objDimension);
  47. if (index > totFrame)
  48. index = totFrame - 1;
  49. if (index < 0)
  50. index = 0;
  51. imgObj.SelectActiveFrame(objDimension, index);
  52. // 设置输出的MIME类型
  53. context.Response.ContentType = "image/gif";
  54. // 输出文件流到浏览器中
  55. //
  56. imgObj.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
  57. // 释放资源
  58. context.Response.Flush();
  59. context.Response.End();
  60. }
  61. catch
  62. { }
  63. }
  64. }
  65. }