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:配置
}
}
}
<div> <%-- <asp:GridView ID="GridView1" runat="server"> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server"> </asp:SqlDataSource>--%> <asp:Image ID="Image1" runat="server" imageurl="imgs/1.jpg"/> <%--<image src="http://localhost:2309/WebForm1.aspx"> </image>--%> </div>
<httpHandlers> <add verb="*" path="imgs/*.jpg" type="实现本网站图片保护功能.yanzhengma"/> <!--第一个属性verb是处理什么样的文件,path是处理那个文件夹下的图片, type是要配置的文件类--> </httpHandlers>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有