Re: From Graphics to Image

Ron Young <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <000101c79bb0$9b0d54c0$d127fe40$@com>
Just venturing a guess here, but if you create the Bitmap object:

Bitmap b = new Bitmap(100, 100);

Then the Graphics object from that object:

Graphics g = Graphics.FromImage(b);

Then you should be able to use "g" to draw your graph on "b", and then use
b.Save() to save the result, or g.DrawImage() to paint the image on the
screen.

Ron

-----Original Message-----
From: Discussion forum for developers using Windows Forms to build apps and
controls [mailto:[email protected]] On Behalf Of Richard
Kucia
Sent: Monday, May 21, 2007 8:31 AM
To: [email protected]
Subject: [DOTNET-WINFORMS] From Graphics to Image

I have a working application which draws a graph on a PictureBox using the
Graphics object. The method is in the Paint event of the PictureBox. Works
fine.

I would prefer to use the same drawing algorithm and capture the result in a
Image/Bitmap object. My theory is that the conditions that would cause the
graph to change are relatively rare, and therefore my app would perform
better by computing the graph once and avoiding the computation in the
overridden Paint method. Plus, it will be easy to save the Image to a file,
if that become a future requirement.

So how do I capture the result into an Image/Bitmap object? Thanks.

Rick Kucia
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.