2017-10-20 48 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)