Posted by: Cirilo Meggiolaro | 10/22/2008

Tip of the day #8 – Capturing screenshots for your Windows Forms application

The .NET framework provides an easy way to capture a screenshot of your Windows Forms application screen:

1. All you need is a bitmap and a graphic object;

Bitmap img;

Graphics g;

img = new Bitmap(this.Width, this.Height, PixelFormat.Format32bppArgb);

g = Graphics.FromImage(img);

2. The method CopyFromScreen allow us to capture the pixels data from a specified rectangle;

g.CopyFromScreen(this.Location, new Point(0, 0), new Size(this.ClientRectangle.Width + this.Location.X, this.ClientRectangle.Height + this.Location.Y));

3. To save the image, use the method Save from the bitmap object.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: