using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
namespace WebApplication1
{
public class MyHandler:IHttpHandler
{
public bool IsReusable => false;
public void ProcessRequest(HttpContext context)
{
//得到用户请求的图片
String filename = context.Request.PhysicalPath;
Bitmap bitmap = new Bitmap(filename);
//实例化画布
Graphics graphics = Graphics.FromImage(bitmap);
//在image上绘制水印
graphics.DrawString("叼毛", new Font("宋体", 40, FontStyle.Bold), Brushes.Blue, new Point(0, 0));
graphics.Flush();
bitmap.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
}