asp.net 做文字水印
/// <summary> /// 做图片水印(Drawing,IO) /// </summary> /// <param name="InPath">输入图片模板路径</param> /// <param name="OutPath">输入图片路径</param> /// <param name="oneStr">第1行文字</param> /// <param name="oneScript">1-字体</param> /// <param name="oneSize">1-字体大小</param> /// <param name="oneX">1-x坐标</param> /// <param name="oneY">1-y坐标</param> /// <param name="twoStr">第2行文字</param> /// <param name="twoScript">2-字体</param> /// <param name="twoSize">2-字体大小</param> /// <param name="twoX">2-x坐标</param> /// <param name="twoY">2-y坐标</param> private void MyGraphics(string InPath, string OutPath, string oneStr, string oneScript, int oneSize, int oneX, int oneY, string twoStr, string twoScript, int twoSize, int twoX, int twoY) { string one = oneStr; string two = twoStr; MemoryStream ms = new MemoryStream(); Bitmap bmp = new Bitmap(Server.MapPath(InPath)); Graphics g = Graphics.FromImage(bmp); g.DrawString(one, new Font(oneScript, oneSize), Brushes.White, new Point(oneX, oneY)); g.DrawString(two, new Font(twoScript, twoSize), Brushes.White, new Point(twoX, twoY)); bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); System.Drawing.Image i = System.Drawing.Image.FromStream(ms); i.Save(OutPath); g.Dispose(); bmp.Dispose(); }
本文出自 “程序猿的家” 博客,请务必保留此出处http://962410314.blog.51cto.com/7563109/1435290
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。