//程序运行完后,会在newFile位置生成一个新文件。
string
oldFile
=
Environment.CurrentDirectory
+
"\\test.jpg"
string
newFile
=
Environment.CurrentDirectory
+
"\\test1.jpg"
Image
image
=
Image.FromFile(oldFile)
Graphics
graphic
=
Graphics.FromImage(image)
graphic.DrawString("绘画时间:2010年11月24日11:31:10",
new
Font("幼圆",
24f,
FontStyle.Regular),
new
SolidBrush(Color.Black),
100f,
100f)
image.Save(newFile)
image.Dispose()
graphic.Dispose()
/// <summary>/// 在图片上增加文字水印
/// </summary>
/// <param name="Path">原服务器图片路径</param>
/// <param name="Path_sy">生成的带文字水印的图片路径</param>
protected void AddShuiYinWord(string Path, string Path_sy)
{
string addText = "测试水印"
System.Drawing.Image image = System.Drawing.Image.FromFile(Path)
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image)
System.Drawing.Font f = new System.Drawing.Font("Verdana", 16)
System.Drawing.Brush b = new System.Drawing.SolidBrush(System.Drawing.Color.Blue)
g.DrawString(addText, f, b, 15, 15)
g.Dispose()
image.Save(Path_sy)
image.Dispose()
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)