1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Drawing.Imaging;
- using System.Reflection;
- using EMIS.Utility;
- namespace EMIS.Web.Controls.Handler
- {
- /// <summary>
- /// ImageReader 的摘要说明
- /// </summary>
- public class ImageReader : IHttpHandler
- {
- public void ProcessRequest(HttpContext context)
- {
- var image = RSI.Get(context.Request["key"]);
- context.Response.Buffer = true;
- context.Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
- context.Response.Expires = 0;
- context.Response.CacheControl = "no-cache";
- context.Response.AppendHeader("Pragma", "No-Cache");
- image.Save(context.Response.OutputStream, image.RawFormat);
- Type imageFormatType = typeof(ImageFormat);
- System.Reflection.PropertyInfo[] _ImageFormatList = imageFormatType.GetProperties(BindingFlags.Static | BindingFlags.Public);
- for (int i = 0; i != _ImageFormatList.Length; i++)
- {
- ImageFormat _FormatClass = (ImageFormat)_ImageFormatList[i].GetValue(null, null);
- if (_FormatClass.Guid.Equals(image.RawFormat.Guid))
- {
- context.Response.ContentType = "image/" + _ImageFormatList[i].Name.ToLower();
- }
- }
- context.Response.End();
- }
- public bool IsReusable
- {
- get
- {
- return false;
- }
- }
- }
- }
|