文字与图片水印
来源:互联网 发布:linux下载安装 编辑:程序博客网 时间:2024/05/16 01:28
private void Btn_Upload_Click(object sender, System.EventArgs e)
...{
if(UploadFile.PostedFile.FileName.Trim()!="")
...{
//上传文件
string extension = Path.GetExtension(UploadFile.PostedFile.FileName).ToUpper();
string fileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
string path = Server.MapPath(".") + "/UploadFile/" + fileName + extension;
UploadFile.PostedFile.SaveAs(path);
//加文字水印,注意,这里的代码和以下加图片水印的代码不能共存
System.Drawing.Image image = System.Drawing.Image.FromFile(path);
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 = AddText.Value.Trim();
g.DrawString(addText, f, b, 10, 10);
g.Dispose();
//加图片水印
System.Drawing.Image image = System.Drawing.Image.FromFile(path);
System.Drawing.Image copyImage = System.Drawing.Image.FromFile( Server.MapPath(".") + "/Alex.gif");
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 = Server.MapPath(".") + "/UploadFile/" + fileName + "_new" + extension;
image.Save(newPath);
image.Dispose();
if(File.Exists(path))
...{
File.Delete(path);
}
Response.Redirect(newPath);
}
}
...{
if(UploadFile.PostedFile.FileName.Trim()!="")
...{
//上传文件
string extension = Path.GetExtension(UploadFile.PostedFile.FileName).ToUpper();
string fileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
string path = Server.MapPath(".") + "/UploadFile/" + fileName + extension;
UploadFile.PostedFile.SaveAs(path);
//加文字水印,注意,这里的代码和以下加图片水印的代码不能共存
System.Drawing.Image image = System.Drawing.Image.FromFile(path);
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 = AddText.Value.Trim();
g.DrawString(addText, f, b, 10, 10);
g.Dispose();
//加图片水印
System.Drawing.Image image = System.Drawing.Image.FromFile(path);
System.Drawing.Image copyImage = System.Drawing.Image.FromFile( Server.MapPath(".") + "/Alex.gif");
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 = Server.MapPath(".") + "/UploadFile/" + fileName + "_new" + extension;
image.Save(newPath);
image.Dispose();
if(File.Exists(path))
...{
File.Delete(path);
}
Response.Redirect(newPath);
}
}
- 文字与图片水印
- php 图片水印 文字水印
- Java添加水印+图片水印+文字水印
- 水印图片、文字
- PHP水印图片文字
- 图片+文字水印
- 图片加文字水印
- 图片上水印文字
- 图片文字水印
- 图片加水印文字
- 文字和图片水印
- 图片添加文字水印
- C# 图片缩略图,图片水印,文字水印
- 制作文字水印图片、图片水印
- php中图片文字混合水印与缩略图
- php gd库 文字与图片组合(类似水印)
- 图像函数与文字、图片水印及验证码生成
- java给图片加水印,文字水印
- 有个帖子说
- String和StringStringBuild的区别
- girdview取隐藏列的两种方法
- 我是个疯子
- 关于java的一些基础知识和经验
- 文字与图片水印
- 下一步,我该怎么走!?
- 装修知识——贴地转
- (转)Can You Hide Your Public IP Address?
- 巧用渐变剪贴蒙版做效果
- 质量,过程和人
- [IO] File Util print file to hex bytes
- Fix the problem: java.lang.OutOfMemoryError: PermGen space in Java development
- 确定包含全角和半角字符的字符串长度(VB)