user85511
user85511

Reputation: 533

picture's backgroundcolor in picturebox

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

Answers (2)

sakthivignesh
sakthivignesh

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

Fredrik Mörk
Fredrik Mörk

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

Related Questions