Home All Groups Group Topic Archive Search About

How can I save a Graphics to a bitmap file?

Author
7 Sep 2006 11:13 AM
myNickname
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.

Author
7 Sep 2006 1:30 PM
ThunderMusic
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


Show quote
"myNickname" <myNickn***@discussions.microsoft.com> wrote in message
news:9A091C0F-B100-4D04-966F-5E37825BFDAC@microsoft.com...
>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.
Author
4 Jan 2007 7:48 AM
prof_martin
How about in .NET 1.1 using VS.NET 2003?

Thanks,
Martin

Show quote
"ThunderMusic" wrote:

> 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
>
>
> "myNickname" <myNickn***@discussions.microsoft.com> wrote in message
> news:9A091C0F-B100-4D04-966F-5E37825BFDAC@microsoft.com...
> >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.
>
>
>

AddThis Social Bookmark Button