Foxtable(狐表)用户栏目专家坐堂 → 请问如何在照相的时候在照片上加名字


  共有2707人关注过本帖树形打印复制链接

主题:请问如何在照相的时候在照片上加名字

帅哥哟,离线,有人找我吗?
13796361423
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:179 积分:1932 威望:0 精华:0 注册:2020/2/14 18:49:00
请问如何在照相的时候在照片上加名字  发帖心情 Post By:2021/5/17 22:36:00 [显示全部帖子]

请问如何在照相的时候在照片上加名字
图片点击可在新窗口打开查看此主题相关图片如下:2345截图20210517223246.jpg
图片点击可在新窗口打开查看

 回到顶部
帅哥哟,离线,有人找我吗?
13796361423
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:179 积分:1932 威望:0 精华:0 注册:2020/2/14 18:49:00
  发帖心情 Post By:2021/5/17 22:38:00 [显示全部帖子]

想在照片上加上名字

 回到顶部
帅哥哟,离线,有人找我吗?
13796361423
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:179 积分:1932 威望:0 精华:0 注册:2020/2/14 18:49:00
请问以下代码放在哪个控件里?  发帖心情 Post By: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

 回到顶部
帅哥哟,离线,有人找我吗?
13796361423
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:179 积分:1932 威望:0 精华:0 注册:2020/2/14 18:49:00
放在保存按钮后提示不对啊  发帖心情 Post By: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
图片点击可在新窗口打开查看

 回到顶部
帅哥哟,离线,有人找我吗?
13796361423
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:179 积分:1932 威望:0 精华:0 注册:2020/2/14 18:49:00
请问以下代码,我想要加水印的那个图片的路径在哪里写入?  发帖心情 Post By: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

 回到顶部
帅哥哟,离线,有人找我吗?
13796361423
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:179 积分:1932 威望:0 精华:0 注册:2020/2/14 18:49:00
文字的位置和颜色  发帖心情 Post By: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

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


 回到顶部
帅哥哟,离线,有人找我吗?
13796361423
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:179 积分:1932 威望:0 精华:0 注册:2020/2/14 18:49:00
文件名是动态的,如何加水印?  发帖心情 Post By:2021/5/18 15:22: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:\test.jpg"  你问这个位置应该上面刚保存那个文件Current("学籍号") & ".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) '水印文字字体
g.DrawString(txt, fnt, Brushes.Red, new PointF(0,0))
bmp.save("D:\test.jpg",img.RawFormat)
bmp.Dispose


 回到顶部
帅哥哟,离线,有人找我吗?
13796361423
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:179 积分:1932 威望:0 精华:0 注册:2020/2/14 18:49:00
这两段代码合一起,编译错误  发帖心情 Post By:2021/5/18 16:11:00 [显示全部帖子]


图片点击可在新窗口打开查看此主题相关图片如下:12.jpg
图片点击可在新窗口打开查看

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 = e.Form.Controls("FileName").Value 
Dim txt As String = Tables("初二会考系统").Current("姓名")  
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) '水印文字字体
g.DrawString(txt, fnt, Brushes.Red, new PointF(0,0))
bmp.save(e.Form.Controls("FileName").Value,img.RawFormat)
bmp.Dispose

以上两段代码, 单独测试都好使,放在一个“保存”按钮里就是编译错误。

 回到顶部
帅哥哟,离线,有人找我吗?
13796361423
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:179 积分:1932 威望:0 精华:0 注册:2020/2/14 18:49:00
请问这是什么意思  发帖心情 Post By:2021/5/18 16:53: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 = e.Form.Controls("FileName").Value 
Dim txt As String = Tables("初二会考系统").Current("姓名")  
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) '水印文字字体
g.DrawString(txt, fnt, Brushes.Red, new PointF(0,0))
bmp.save(e.Form.Controls("FileName").Value,img.RawFormat)
bmp.Dispose


请问这应该如何修改?
图片点击可在新窗口打开查看此主题相关图片如下:18165026.jpg
图片点击可在新窗口打开查看

 回到顶部