How to capture form

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
 
C

CMoya

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.
 
H

Herfried K. Wagner [MVP]

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
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top