日期:2014-05-18 浏览次数:20523 次
<%@ WebHandler Language="C#" Class="Handler" %> using System; using System.Web; using System.Drawing; public class Handler : IHttpHandler { public void ProcessRequest (HttpContext context) { Bitmap img = new Bitmap(600, 400); Graphics g = Graphics.FromImage(img); Pen p = new Pen(Color.Blue, 2);//定义了一个蓝色,宽度为的画笔 g.DrawLine(p, 10, 10, 100, 100);//在画板上画直线,起始坐标为(10,10),终点坐标为(100,100) context.Response.ContentType = "Image/GIF"; context.Response.Clear(); context.Response.BufferOutput = true; img.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif); img.Dispose(); g.Dispose(); p.Dispose(); } public bool IsReusable { get { return false; } } }