照片打水印

//加载文件
System.Drawing.Image Cover;
Cover = System.Drawing.Image.FromFile(src);

//创建画布
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(Cover);
Font f = new Font("宋体", 20, FontStyle.Regular);
Brush brush = System.Drawing.Brushes.Red;
g.DrawString(“水印文字balabala”, f, brush, 0, 100);

//释放画布
g.Dispose();
//释放水印图片
Cover.Save(src);
//Cover.Save(HttpContext.Current.Server.MapPath(src));//保存打过水印的图片
Cover.Dispose();

猜你喜欢

转载自www.cnblogs.com/wxh-bky/p/9705911.html