The blog has moved to a new address. The blog is now located at http://devintelligence.com

Adsense

Tuesday, December 12, 2006

How to capture the form and save it to a bitmap

The following example source code shows how to capture the form and save it to a bitmap. Hope you find it useful.

Point point = new Point();
Rectangle rectangle
= new Rectangle(point, this.Size);
Bitmap bitmap
=
new Bitmap(rectangle.Width, rectangle.Height, PixelFormat.Format32bppRgb);
// render the form to the bitmap
this.DrawToBitmap(bitmap, rectangle);
bitmap.Save(
@"d:\MyForm.bmp");

No comments: