以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]给图片加水印 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=142398) |
|
-- 作者:wldhj -- 发布时间:2019/10/25 16:57:00 -- [求助]给图片加水印 怎样给上传到系统的图片加文字水印? |
|
-- 作者:有点蓝 -- 发布时间:2019/10/25 17:27:00 -- Dim file As String = "d:\\123.jpg" Dim txt As String = "我是水印文字" Dim img As image = getImage(file) Dim bmp = new bitmap(img.Width, img.Height) Dim g = graphics.fromimage(bmp) g.DrawImage(img,0,0) ‘绘制原图片’ g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality Dim fnt As new Font("微软雅黑", 60, FontStyle.Bold) ‘水印文字字体 Dim size = g.MeasureString(txt, fnt) g.TranslateTransform((img.width-size.width)/2, img.Height - size.height - 50) \'设置文字的绘制起点 g.RotateTransform(-45) \'逆时针旋转45度 Dim semiTransBrush As new System.Drawing.SolidBrush(Color.FromArgb(120, 177, 171, 171)) \'水印文字颜色,120是透明度,范围0~255 g.DrawString(txt, fnt, semiTransBrush, new PointF(0,0)) bmp.save("E:\\问题\\shuiyin.jpg",img.RawFormat) bmp.Dispose semiTransBrush.Dispose
|
|
-- 作者:ljh29206 -- 发布时间:2019/12/12 9:33:00 -- mark |
|
-- 作者:ouyangfenghuan -- 发布时间:2021/5/27 18:58:00 --
|