⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shuiyin.cs

📁 OA系统源码 办公应用软件源码 asp.net 开发
💻 CS
字号:

using System;

using System.Web;
using System.Drawing;

/// <summary>
/// ShuiYin 的摘要说明
/// </summary>
public class ShuiYin : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {//重写接口中的方法
        Image source = Image.FromFile(context.Request.PhysicalPath);//取出请求的路径
        Image water = Image.FromFile(context.Server.MapPath("~/images/Users/WaterMark.png"));

        //获取某张图片的画笔
        Graphics g = Graphics.FromImage(source);
        g.DrawImage(water,new Rectangle(source.Width-water.Width,source.Height-water.Height,water.Width,water.Height),0,0,water.Width,water.Height,GraphicsUnit.Pixel);
        g.Dispose();
        //设置输出的类型
        context.Response.ContentType = "image/jpeg";
        water.Dispose();
        //把文件保存在内存中
        source.Save(context.Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg);
        source.Dispose();
        context.Response.End();
       
    }

    public bool IsReusable//重写接口中的属性
    {
        get
        {
            return false;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -