Question Saving a drawn image on picturebox to file

davco

Member
Joined
Sep 13, 2006
Messages
8
Programming Experience
Beginner
I am using vb .net 2003 and can draw on a picturebox just fine,but I can`t figure out how to save that drawing to a file.Can anyone help me out with this problem?:D
 
I have this code here that will add the picturebox to a file but there is only black where the image is supposed to be.
Dim img As Image
img = PB1.Image
t = TBsave.Text
Dim newBitmap As Bitmap = New Bitmap(x, y, PixelFormat.Format16bppRgb555)
img = newBitmap
newBitmap.Save(t, ImageFormat.Jpeg)
I have tried several things but this is as close as I can get.
Any help is appreciated in advance.
 
Get a Graphics instance with Graphics.FromImage method, now you can draw the same that you drew to the control surface to the bitmap.
 
[ame="http://www.vbforums.com/showthread.php?t=426684"]Here[/ame] is a demonstration of what JohnH suggested. Note that the same method is used to do the drawing, whether the Graphics object comes from a Paint event handler or from a FromImage call. The method will just draw with whatever it's given. You can then call Image.Save.
 
Back
Top