0
我需要保存PictureBox,包括其背景到JPG文件在硬盤中; 到目前爲止,我可以從資源加載圖片,然後將PictureBox保存到硬盤驅動器,但它刪除背景; 我的代碼如下:VB.Net圖片背景保存
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
PictureBox1.Image = My.Resources.ResourceManager.GetObject("test.jpg")
Dim Image As New Bitmap(800, 400)
Dim MekSaveImage As Graphics = Graphics.FromImage(Image)
For Parts = 0 To 3
RRRR = 10 + Parts * 198
Dim RectPen As New Pen(Color.Red)
RectPen.Width = 2
Dim rect As New Rectangle(RRRR, 10, 188, 300)
MekSaveImage.DrawRectangle(RectPen, rect)
Next
PictureBox1.Image = Image
PictureBox1.Image.Save("C:\Test\Test.jpg", Imaging.ImageFormat.Jpeg)
End Sub
在此先感謝幫助/評論。
在循環之前,使用MekSaveImage對象將picturebox的'.BackgroundImage'繪製到'Image'。 – Jens 2014-09-23 07:48:39
謝謝Jens的評論;大概需要2行代碼;你能告訴我代碼嗎...我正在嘗試,但似乎我犯了一些錯誤。 – Abbas1999 2014-09-23 08:22:05