Save graphic as jpg

Ronak

Member
Joined
Jan 13, 2006
Messages
11
Programming Experience
1-3
Hello

I have made a project on graphic. I want to save graphics ,which is created in picturebox.

I can save image of picturebox as jpg but cant save graphic as jpg

Any help...
 
Hi, though i'm not sure but i dont think you directly convert a graphic to a jpeg image. However you can draw your image directly into a bitmap variable then convert it to jpeg format.
 
Use System.Drawing.Imaging.ImageFormat when saving:
VB.NET:
[SIZE=2]PictureBoxBigPicture.Image.Save("picture.jpg", Drawing.Imaging.ImageFormat.Jpeg)
[/SIZE]
 
I'm not sure but it sounds like you are saying that you have used GDI+ to draw on a PictureBox and you now want to save that drawing as a JPEG image. If that's the case, you actually can't do it directly. You would have to create your Graphics object from a Bitmap object, rather than the PictureBox. You would have two choices here. You could either do your drawing on the Image in the PictureBox as you go, then save that when you're done, or else do your drawing on the PictureBox as you go and then when you're ready to save, repeat all the same drawing on a Bitmap and save it. The difference is that if you do the drawing on the Image as you go you cannot undo anything because GDI+ drawing on a Bitmap is permanent, while drawing on the PictureBox allows you to remove any elements simply by not redrawing them when the PictureBox is repainted.
 
Back
Top