I use Windows Forms and VS 2005 to draw a plot on the form. How can I save
this plot to a graphics file (preferably jpg)? I couldn't find appropriate
class in the Framework.
Thank you.
Gregory Khrapunovich
Look at the Bitmap class. You can transfer your form's Graphics object image
into a Bitmap object. The Bitmap object contains the "Save" methods you're
looking for.
>I use Windows Forms and VS 2005 to draw a plot on the form. How can I save
> this plot to a graphics file (preferably jpg)? I couldn't find appropriate
> class in the Framework.
> Thank you.
> Gregory Khrapunovich
"Gregory Khra" <GregoryKhra@discussions.microsoft.com> schrieb:
>I use Windows Forms and VS 2005 to draw a plot on the form. How can I save
> this plot to a graphics file (preferably jpg)? I couldn't find appropriate
> class in the Framework.
Simply use a 'Graphics' object based on an image to draw the plot (air
code):
\\\
Private Overrides Sub OnPaint(ByVal e As PaintEventArgs)
DrawPlot(e.Graphics)
End Sub
Private Sub SavePlot(ByVal FileName As String)
Using Image As New Bitmap(...)
Using g As Graphics = Graphics.FromImage(Image)
DrawPlot(g)
End Using
Image.Save(FileName)
End Using
End Sub
Private Sub DrawPlot(ByVal g As Graphics)
g.DrawLine(...)
' Drawing code.
End Sub
///

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>