从资源文件中取图片

//dll文件其中有dhzTc.resource文件

public class ImgFrmRes
 {
  public ImgFrmRes()
  {
   //
   // TODO: 在此处添加构造函数逻辑
   //
  }
  
  
  public static System.Drawing.Image     GetSrc(string name)
  {
   System.Resources.ResourceManager rm=new ResourceManager("ImgFrmRes.dhzTc",System.Reflection.Assembly.GetExecutingAssembly());
   return rm.GetObject(name) as System.Drawing.Image ;
  }
  
 }

///生成dll

public class  img  :System.Web.IHttpHandler
 {
  public img()
  {
  }
  #region IHttpHandler 成员

  public void ProcessRequest(System.Web.HttpContext context)
  {
   // TODO:  添加 img.ProcessRequest 实现
  
    System.Drawing.Image img=ImgFrmRes.ImgFrmRes.GetSrc(context.Request.QueryString["ID"].ToUpper ());

   img.Save(context.Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg);
   context.Response.Flush ();
   context.Response.End ();
   
  }

  public bool IsReusable
  {
   get
   {
    // TODO:  添加 img.IsReusable getter 实现
    return false;
   }
  }

  #endregion

 }

///

<FORM>

<img src=dhz.aspx?ID=A border=0>

</FORM>

//配置文件

<httpHandlers>
  <add verb="*" path="dhz.aspx" type="FtbMod.img,FtbMod" />
 </httpHandlers>

posted on 2005-10-20 09:25  老代哥哥  阅读(227)  评论(0编辑  收藏  举报

导航