How to capture form

  • Thread starter Thread starter Gregory Khra
  • Start date Start date
G

Gregory Khra

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.
 
Gregory Khra said:
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
///
 
Back
Top