using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Drawing;//image的命名空间 namespace 实现本网站图片保护功能 { public class yanzhengma:IHttpHandler { public bool IsReusable { get { throw new NotImplementedException(); } } public void ProcessRequest(HttpContext context)//请求的方法 { Image img = Image.FromFile(context.Request.PhysicalPath);//1:从文件中获取图片;获取请求的文件的物理路径 Graphics g = Graphics.FromImage(img); //2:声明graphicse把img做为填充他的参数 g.DrawString("net", new Font("宋体", 20, FontStyle.Italic), Brushes.Blue, 10, 10);//3:在graphicse上写图片 img.Save(context.Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg);//4:保存(保存到什么什么流里,什么格式保存) context.Response.Flush();//5:从缓存区中输出 context.Response.End();//6:结束 //7:配置 } } } //csharp/6128