Saving graphics in a picture box to disk

scot63

Member
Joined
Sep 18, 2003
Messages
8
Location
Novato, CA
Hi,

Using vb.net 2003

So I have an app that (1) loads a jpeg into a picture box and (2) using the mouse you can draw lines over the image in the picture box.

Now I need help with (3) saving the image AND lines in the picture box to the hard drive.

I suspect I need to use fromHbitmap, but i cannot find good reference on how to do this.

i have a bitmap var prepared
Dim ThisBitmap As Bitmap

i also have the code needed to save the bitmap
ThisBitmap.Save("saved.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)

i need help between these two commands, where the pixel data in the picture box is somehow stored in a bitmap.

thanks,

scot
 
Are you saying the lines dont show up after the image is saved?
If yes then you are probably drawing to the picturebox itself and not the image object it contains to which you have to draw for anything to become the part of the image,
 
Mutant,

yes, when i save the image its an exact copy of the loaded image. the lines do not appear.

how would i target the image and not the picturebox?

Ill dig further into this.

thanks,

scot
 
Last edited by a moderator:
Ahhh - i see!

I was using...

dim g as graphics

I changed it to...

Dim g As Graphics = Graphics.FromImage(P1.Image)

Which sends my drawline commands to the image in the picture box (P1).

Thanks to you both,

Scot
 
Back
Top