Capture screen using C# and .Net 2.0
By Anuraj P on April 13th, 2007 . No Comments .
Remember old BitBlt API, for capturing screens? Here is the solution from Microsoft on .Net framework 2.0. CopyFromScreen Method – Performs a bit-block transfer of color data from the screen to the drawing surface of the Graphics.
Rectangle region = new Rectangle(0, 0, SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height);
using (Bitmap bitmap = new Bitmap(region.Width, region.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb))
using (Graphics bitmapGraphics = Graphics.FromImage(bitmap))
{
bitmapGraphics.CopyFromScreen(region.Left, region.Top, 0, 0, region.Size);
Clipboard.SetImage(bitmap);
}
It only works with .Net 2.0 and more.
I developed an Application, which hosted in Codeplex, called captureit., which is using this code for capturing desktop.
MSDN : http://msdn2.microsoft.com/en-us/library/system.drawing.graphics.copyfromscreen.aspx