日期:2014-05-17 浏览次数:20517 次
<%@ WebHandler Language="C#" Class="ShuiYin" %>
using System;
using System.Web;
using System.Drawing;
public class ShuiYin : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "image/jpg";
        
        string strimgpath = context.Server.MapPath(@"UpLoad\1.jpg");
        using (Image img = Bitmap.FromFile(strimgpath))
        {
            using (Graphics g = Graphics.FromImage(img))
            {
                g.DrawString("水印", new Font("宋体", 16), Brushes.Black, 50, 100);
                img.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
            }
        }  
     
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }
}