all groups > dotnet windows forms > january 2008 >
You're in the

dotnet windows forms

group:

How to capture form


How to capture form Gregory Khra
1/7/2008 12:24:00 PM
dotnet windows forms: 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
Re: How to capture form CMoya
1/7/2008 3:34:05 PM
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.

[quoted text, click to view]
Re: How to capture form Herfried K. Wagner [MVP]
1/7/2008 10:08:55 PM
"Gregory Khra" <GregoryKhra@discussions.microsoft.com> schrieb:
[quoted text, click to view]

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

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
AddThis Social Bookmark Button