2017-10-20 49 views
1

当图像写入文本 - 发现图像尺寸大 Origanl图片: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") 

回答

1

如果你不这样做:32 KB 对图片添加文字后指定格式,默认为“png”。从Image.Save Method

如果图像的文件格式不存在编码器,则使用便携式网络图形(PNG)编码器。

所以你需要指定格式:

newImage.Save(DbPath + "\Pictures\" + MigraID.Text + ".jpg", ImageFormat.Jpeg)