以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  请问如何在照相的时候在照片上加名字  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=166088)

--  作者:13796361423
--  发布时间:2021/5/17 22:36:00
--  请问如何在照相的时候在照片上加名字
请问如何在照相的时候在照片上加名字
图片点击可在新窗口打开查看此主题相关图片如下:2345截图20210517223246.jpg
图片点击可在新窗口打开查看

--  作者:13796361423
--  发布时间:2021/5/17 22:38:00
--  
想在照片上加上名字
--  作者:有点蓝
--  发布时间:2021/5/17 22:48:00
--  
参考:http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=142398
--  作者:13796361423
--  发布时间:2021/5/18 8:32: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

--  作者:有点蓝
--  发布时间:2021/5/18 8:42:00
--  
比如保存按钮,放到保存图片后。比如

Dim file As String = "图片保存的路径"

--  作者:13796361423
--  发布时间:2021/5/18 10:07:00
--  放在保存按钮后提示不对啊
Dim pic As WinForm.PictureBox = e.Form.Controls("PicView2")
Dim img As Image
e.Form.TimerEnabled = False
If pic.Image IsNot Nothing
    Dim buffer() As Byte = Functions.Execute("GetImageToBytes",pic.Image)
    Dim result As Integer = Functions.Execute("SaveBytesToFile",buffer,e.Form.Controls("FileName").Value)
    If result = 1
        Tables("初二会考系统").Current("相片") = Tables("初二会考系统").Current("学籍号") & ".JPG"
        Tables("学籍表").Current("已拍照") = True
        MessageBox.Show("照片保存为: " & e.Form.Controls("FileName").Value ,"保存成功")
    Else
        MessageBox.Show("保存失败","失败")
    End If
Else
    MessageBox.Show("请先拍照!","错误")
End If
e.Form.TimerEnabled = True

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
图片点击可在新窗口打开查看此主题相关图片如下:2345截图20210518100513.jpg
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2021/5/18 10:13:00
--  
把项目移到其它文件夹使用,注意项目名称和项目所在的路径不能有括号等特殊符号。重新打开项目测试就可以看到具体的错误提示
--  作者:13796361423
--  发布时间:2021/5/18 13:20: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

--  作者:有点蓝
--  发布时间:2021/5/18 13:37:00
--  
Dim file As String = "d:\\123.jpg这里改为自己窗口图片保存的路径"

bmp.save("E:\\问题\\shuiyin.jpg这里改为自己加名称后图片保存的路径",img.RawFormat)
[此贴子已经被作者于2021/5/18 13:37:39编辑过]

--  作者:13796361423
--  发布时间:2021/5/18 14:43:00
--  文字的位置和颜色
Dim file As String = "D:\\test.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("微软雅黑", 10, FontStyle.Bold) \'水印文字字体
Dim size = g.MeasureString(txt, fnt)
g.TranslateTransform((img.width-size.width)/2, img.Height - size.height - 50) \'设置文字的绘制起点
g.RotateTransform(-0) \'逆时针旋转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("D:\\shuiyin.jpg",img.RawFormat)
bmp.Dispose
semiTransBrush.Dispose

我想要名字出现在相片的左上角, 并且字体为红色,请问在哪里改?