 
                    
                
         
    
    
    
    
    
        
            
                
    
        
            
            
            
                
![]() <%@ WebHandler Language="C#" Class="image" %>
<%@ WebHandler Language="C#" Class="image" %>
![]()
![]() using System;
using System;
![]() using System.Web;
using System.Web;
![]() using System.Drawing;
using System.Drawing;
![]()
![]()
![]() public class image : IHttpHandler,System.Web.SessionState.IRequiresSessionState
public class image : IHttpHandler,System.Web.SessionState.IRequiresSessionState ![]() {
{
![]() 
    
![]()
![]() public void ProcessRequest (HttpContext context)
    public void ProcessRequest (HttpContext context) ![]() {
{
![]() context.Response.ContentType = "text/gif";
        context.Response.ContentType = "text/gif";
![]() Bitmap b = new Bitmap(200, 60);
        Bitmap b = new Bitmap(200, 60);
![]() Graphics g = Graphics.FromImage(b);
        Graphics g = Graphics.FromImage(b);
![]() g.FillRectangle(new SolidBrush(Color.White), 0, 0, 200, 60);
        g.FillRectangle(new SolidBrush(Color.White), 0, 0, 200, 60);
![]() Font font = new Font(FontFamily.GenericSansSerif, 48, FontStyle.Bold, GraphicsUnit.Pixel);
        Font font = new Font(FontFamily.GenericSansSerif, 48, FontStyle.Bold, GraphicsUnit.Pixel);
![]() Random r = new Random();
        Random r = new Random();
![]() string letters = "ABCDEFGHIJKMNPQRSTUVWXYX";
        string letters = "ABCDEFGHIJKMNPQRSTUVWXYX";
![]() string letter;
        string letter;
![]() System.Text.StringBuilder s = new System.Text.StringBuilder();
        System.Text.StringBuilder s = new System.Text.StringBuilder();
![]() for (int x = 0; x < 5; x++)
        for (int x = 0; x < 5; x++)
![]()
![]() 
        ![]() {
{
![]() letter = letters.Substring(r.Next(0, letters.Length - 1), 1);
            letter = letters.Substring(r.Next(0, letters.Length - 1), 1);
![]() s.Append(letter);
            s.Append(letter);
![]() g.DrawString(letter, font, new SolidBrush(Color.Black), x * 38, r.Next(0, 15));
            g.DrawString(letter, font, new SolidBrush(Color.Black), x * 38, r.Next(0, 15));
![]() 
            
![]() }
        }
![]()
![]() Pen linePen = new Pen(new SolidBrush(Color.Black), 2);
        Pen linePen = new Pen(new SolidBrush(Color.Black), 2);
![]() for (int x = 0; x < 6; x++)
        for (int x = 0; x < 6; x++)
![]()
![]() 
        ![]() {
{
![]() g.DrawLine(linePen, new Point(r.Next(0, 199), r.Next(0, 59)), new Point(r.Next(0, 199), r.Next(0, 59)));
            g.DrawLine(linePen, new Point(r.Next(0, 199), r.Next(0, 59)), new Point(r.Next(0, 199), r.Next(0, 59)));
![]() }
        }
![]() b.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
        b.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
![]() context.Session["aaa"] = s.ToString();
        context.Session["aaa"] = s.ToString();
![]() context.Response.End();
        context.Response.End();
![]() }
    }
![]()
![]() public bool IsReusable
    public bool IsReusable
![]()
![]() 
    ![]() {
{
![]()
![]() get
        get ![]() {
{
![]() return false;
            return false;
![]() }
        }
![]() }
    }
![]() }
}
<img src="image.ashx" />
 
             
            posted @ 
2007-11-19 20:13 
子午 
阅读(
207) 
评论() 
 
收藏 
举报