c#高性能在WEB端产生验证图片

导读:
  using System;
  using System.Web;
  using System.Drawing ;
  /// <summary><br>  /// Png 的摘要说明。 <br>  public sealed class LocalPng:IHttpHandler <br>  { <br>  #region IHttpHandler 成员 <br>   <br>  public void ProcessRequest(HttpContext context) <br>  { <br>  if(context.Request["key"]!=null&amp;&amp;context.Request["key"].Length ==4)//还有ACSSI码是1-9的数字和a-z的字母 <br>  { <br>  string machine_key=context.Request["key"]; <br>  context.Response.Clear(); <br>  try <br>  { //原图 <br>  Bitmap sImage = new Bitmap(context.Server.MapPath("key.png.bmp")); //图片路径 <br>  //验证码图 <br>  Graphics wg = Graphics.FromImage(sImage); <br>  wg.DrawString(machine_key,new Font("Comic Sans MS",14),new SolidBrush(Color.RoyalBlue),3,0); <br>  wg.Save(); <br>  context.Response.ContentType = "image/Jpeg"; <br>  sImage.Save(context.Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg); <br>  wg.Dispose(); <br>  sImage.Dispose(); <br>  } <br>  catch(Exception e) <br>  {context.Response.Write(e.Message); <br>  } <br>  context.Response.End(); <br>   <br>  } <br>  } <br>  public bool IsReusable <br>  { <br>  get <br>  { <br>  // TODO: 添加 CodeKey.IsReusable getter 实现 <br>  return false; <br>  } <br>  } <br><br>本文转自 <br><a href="http://study.qqcf.com/web/224/24038.htm">http://study.qqcf.com/web/224/24038.htm</a></summary>

你可能感兴趣的:(C++,c,Web,C#)