Reputation: 533
how can i change the background color of a picture saving from a picturebox in vb.net.In my form there is a drawing section.after drawing i am saving the picture as jpeg.but the image's background color is black.so i can't see anything that i have drawn.the drawing pen color is also black.if anyone knows please help me.thank you.
Upvotes: 0
Views: 3274
Reputation: 117
To use this the following code:
OpenFileDialog1.Filter = "Bmp Files(*.bmp)|*.bmp|Gif Files(*.gif)|*.gif|Jpg Files(*.jpg)|*.jpg"
OpenFileDialog1.ShowDialog()
Textbox1.Text = OpenFileDialog1.FileName
PicText.Image = Image.FromFile(OpenFileDialog1.FileName)
Upvotes: 0
Reputation: 158289
I would say that the easiest way is to paint the background when the image object is created (sample initializing the background to being white):
Dim theImage As Image = New Bitmap(someWidth, someHeight)
Using g As Graphics = Graphics.FromImage(theImage)
g.Clear(Color.White)
End Using
Upvotes: 1