How can I save a Graphics to a bitmap file?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I paint into a PictureBox with the help of its Graphics object.
How can I save the painting into a bitmap file (not a metafile) ?

Thanky in advance for any helpful hint.
 
just copy-paste this in your Save method :

Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
pictureBox1.DrawToBitmap(bmp,new Rectangle(0,0,pictureBox1.Width,
pictureBox1.Height));
bmp.Save(@"temp.jpg", ImageFormat.Jpeg);

make sure you replace pictureBox1 by the name of your picturebox and
temp.jpg to the filename you want and ImageFormat.Jpeg by the format you
want too... ;)

I hope it helps

ThunderMusic
 
Back
Top