在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Drawing; namespace 图片水印 { /// <summary> /// 水印类 /// </summary> public class WaterMark { private string ImagePath = null; private Image bm = null; public WaterMark() { } public WaterMark(string ImagePath) { this.ImagePath = ImagePath; } public WaterMark(Image b) { this.bm = b; } public Image Draw(string content) { Image image = null; if (ImagePath != null) { try { image = Image.FromFile(this.ImagePath); } catch { return null; } } if (bm != null) { image = this.bm; } Graphics g = Graphics.FromImage(image); StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Far; sf.LineAlignment = StringAlignment.Far; RectangleF rf = new RectangleF(0,0,image.Width,image.Height); g.DrawString(content, new Font("宋体", 40), Brushes.Red,rf,sf); g.Dispose(); return image; } } }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论