asp.net实现图片添加文字及图片水印
2012-03-08 18:08
1036 查看
//添加文字水印
System.Drawing.Image image = System.Drawing.Image.FromFile(“文件路径”);
Graphics g = Graphics.FromImage(image);
g.DrawImage(image, 0, 0, image.Width, image.Height);
Font f = new Font("Verdana", 32);
Brush b = new SolidBrush(Color.White);
string addText = “水印文字”;
g.DrawString(addText, f, b, 10, 10);
g.Dispose();
//添加图片水印
System.Drawing.Image image = System.Drawing.Image.FromFile(“文件路径”);
System.Drawing.Image copyImage = System.Drawing.Image.FromFile(“水印图片路径”);
Graphics g = Graphics.FromImage(image);
g.DrawImage(copyImage, new Rectangle(image.Width-copyImage.Width, image.Height-copyImage.Height, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, GraphicsUnit.Pixel);
g.Dispose();
//保存加水印过后的图片,删除原始图片
string newPath = “水印文件保存路径”;
image.Save(newPath);
image.Dispose();
if(File.Exists(path))
{
File.Delete(path);
}
Response.Redirect(newPath);
System.Drawing.Image image = System.Drawing.Image.FromFile(“文件路径”);
Graphics g = Graphics.FromImage(image);
g.DrawImage(image, 0, 0, image.Width, image.Height);
Font f = new Font("Verdana", 32);
Brush b = new SolidBrush(Color.White);
string addText = “水印文字”;
g.DrawString(addText, f, b, 10, 10);
g.Dispose();
//添加图片水印
System.Drawing.Image image = System.Drawing.Image.FromFile(“文件路径”);
System.Drawing.Image copyImage = System.Drawing.Image.FromFile(“水印图片路径”);
Graphics g = Graphics.FromImage(image);
g.DrawImage(copyImage, new Rectangle(image.Width-copyImage.Width, image.Height-copyImage.Height, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, GraphicsUnit.Pixel);
g.Dispose();
//保存加水印过后的图片,删除原始图片
string newPath = “水印文件保存路径”;
image.Save(newPath);
image.Dispose();
if(File.Exists(path))
{
File.Delete(path);
}
Response.Redirect(newPath);
相关文章推荐
- ASP.NET百度Ueditor编辑器实现上传图片添加水印效果
- asp.net为图片添加文字水印
- asp.net如何在图片上加水印文字具体实现
- asp .net实现给图片添加图片水印方法示例
- asp.net 生成缩略图、为图片添加文字水印、图片水印等功能
- asp.net如何在图片上加水印文字具体实现
- asp.net通过实现IHttpHandler接口方法给图片添加水印图片(动态添加,不破坏原图片,但是耗资源)
- asp .net 为图片添加文字水印(内包含有加图片水印的方法,但尚未完善暂不能使用)
- ASP.NET 给图片动态添加文字水印
- 在MVC3或asp.net中修改KindEditor实现上传图片时添加水印
- ASP.NET(C#)缩略图片,添加文字水印和图片水印
- Asp.net简单实现给图片增加文字水印
- asp .net 为图片添加文字水印(内包含有加图片水印的方法) .
- ASP.NET 上传图片添加文字、Logo水印
- ASP.NET 给图片动态添加文字水印
- ASP.NET 上传图片添加文字、Logo水印
- asp.net如何在图片上加水印文字具体实现
- asp.net 生成缩略图、为图片添加文字水印、图片水印等功能
- 在MVC3或asp.net中修改KindEditor实现上传图片时添加水印