在图像上写文字时 - 发现图像大尺寸 Origanl图片:32 KB 在图片上添加文字后:500 KB
On Error Resume Next
My.Computer.FileSystem.DeleteFile(DbPath + "\Pictures\" + "orign" + ".jpg")
PictureBox2.Image.Save(DbPath + "\Pictures\" + "orign" + ".jpg", Imaging.ImageFormat.Jpeg)
'End If
Dim bmp = Bitmap.FromFile(DbPath + "\Pictures\" + "orign" + ".jpg")
'Dim bmp = Bitmap.FromFile("orig.jpg")
Dim newImage = New Bitmap(bmp.Width, bmp.Height + 80)
Dim gr = Graphics.FromImage(newImage)
gr.Clear(Color.White)
gr.DrawImageUnscaled(bmp, 0, 0)
gr.DrawString(MigraID.Text & Space(1) & MigraName.Text & Space(1) & IqamaNum.Text & Space(1) & DatePicH.Text,
New Font("Arial", 27),
New SolidBrush(Color.Black), New RectangleF(0, bmp.Height, bmp.Width, 80))
bmp.Dispose()
gr.Dispose()
newImage.Save(DbPath + "\Pictures\" + MigraID.Text + ".jpg")
PictureBox2.Image = Image.FromFile(DbPath + "\Pictures\" + MigraID.Text + ".jpg")
答案 0 :(得分:1)
如果您未指定格式,则默认为" png"。来自Image.Save Method
如果图像的文件格式不存在编码器,则使用便携式网络图形(PNG)编码器。
所以你需要指定你的格式:
newImage.Save(DbPath + "\Pictures\" + MigraID.Text + ".jpg", ImageFormat.Jpeg)