加水印
来源:互联网 发布:医院网络部提成方案 编辑:程序博客网 时间:2024/04/27 15:16
/// <summary>
/// _02UpLoad 的摘要说明
/// </summary>
public class _02UpLoad : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/html";
//HttpPostedFile file=context.Request.Files[0];
//if (file.ContentLength > 0)
//{
// string strName = System.IO.Path.GetFileName(file.FileName);
// file.SaveAs(context.Server.MapPath("/UpLoad/"+strName));
//}
//======================================加文字水印=====================================================
StringBuilder sbMsg = new StringBuilder();
for (int i = 0; i < context.Request.Files.Count; i++)
{
HttpPostedFile file = context.Request.Files[i];
if (file.ContentType.Contains("image/"))
{
if (file.ContentLength>0)
{
using (Image img=Image.FromStream(file.InputStream))
{
using ( Graphics g=Graphics.FromImage(img))
{
g.DrawString("传奇",new Font("微软雅黑",16),Brushes.Red,0,0);
}
string strName = System.IO.Path.GetFileName(file.FileName);
string PhyPath = context.Server.MapPath("/UpLoad/" + strName);
img.Save(PhyPath);
sbMsg.AppendLine(strName+"<br/>");
}
}
}
}
context.Response.Write("上传成功!<br/>" + sbMsg.ToString());
}
public bool IsReusable
{
get
{
return false;
}
}
}
============================================加图片水印======================================================
StringBuilder sbMsg = new StringBuilder();
for (int i = 0; i < context.Request.Files.Count; i++)
{
HttpPostedFile file = context.Request.Files[i];
if (file.ContentType.Contains("image/"))
{
if (file.ContentLength>0)
{
using (Image img=Image.FromStream(file.InputStream))
{
using (Image imgWater = Image.FromFile(context.Server.MapPath("/UpLoad/adidas.jpg")))
{
using (Graphics g = Graphics.FromImage(img))
{
g.DrawImage(imgWater,0,0);
}
}
string strName = System.IO.Path.GetFileName(file.FileName);
string PhyPath = context.Server.MapPath("/UpLoad/" + strName);
img.Save(PhyPath);
sbMsg.AppendLine(strName+"<br/>");
}
}
}
}
context.Response.Write("上传成功!<br/>" + sbMsg.ToString());
}
public bool IsReusable
{
get
{
return false;
}
}
- 加水印
- 加水印
- PHP 加水印
- 上传加水印
- jsp加图片水印
- 图片加水印类
- 图片加水印
- 生成缩略图加水印
- 图片加水印类
- ASP图片加水印
- 图片加水印
- 给图片加水印
- 图片加水印
- word加水印
- word 加水印C#
- 图片加水印
- C# 图片加水印
- 给图片加水印
- IE浏览器不能显示所有图片
- google hacker技术
- 花开花落
- 常用的rfc规范
- Oracle 11g ORA-12514:TNS:监听程序当前无法识别连接描述符中请求的服务 .
- 加水印
- VC通过ADO打开SQL SERVER数据库,并将其中的表、字段、数据显示出来的小程序
- Android 往Framework中添加新资源的方法详解
- 东莞3名辅警殴打男子及其怀孕女友
- MongoDB学习之旅二十九:MongoDB 移除Shard Server
- photoshop5.5切图格式为gif-转为png(单个切片保存)
- 有了多态的存在,instanceof存在的价值在什么地方
- IOS7判断程序是否可用相机
- WinCE下网络编程之send