Re: From Graphics to Image
Ron Young <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <000601c79bfc$0f5808c0$2e081a40$@com> |
I agree with you there samir, and thanks Fabian for the correction. However, I believe the original poster wanted to avoid running the graph creation algorithm when the same graph is requested twice; therefore the need to save the Bitmap locally or to file system I suppose. Ron -----Original Message----- From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:[email protected]] On Behalf Of samir parekh Sent: Monday, May 21, 2007 10:07 AM To: [email protected] Subject: Re: [DOTNET-WINFORMS] From Graphics to Image SORRY TO INTERRUPT.... but there seems to be some misunderstanding.. set the image property of the picture box to the image after editing the image Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics g = Graphics.FromImage(bmp); g.Clear(Color.Blue); pictureBox1.Image = bmp; pictureBox1.Refresh(); Regards samir Fabian Schmied <[email protected]> wrote: > 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. The first part is right, but if "g" is the Graphics object obtained via Graphics.FromImage(b), then g.DrawImage won't paint the image on the screen. Instead, it can be used to paint a different image on the graphics object (which in turn paints on "b"). To show the image on the screen, you can use a PictureBox or a Paint event's PaintEventArgs.Graphics.DrawImage(). Fabian --------------------------------- Get the free Yahoo! toolbar and rest assured with the added security of spyware protection.