/// <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(); }
asp.net 做文字水印
时间: 2024-10-06 04:50:02