This method performs a bit-block transfer of the color data, from the full screen to the drawing surface of the Graphics.
Code: Select all
/// <summary>
/// A method to capture the screen to a Bitmap object
/// </summary>
/// <returns>A Bitmap object of the current screen</returns>
public static Bitmap CaptureScreen ()
{
Bitmap BMP = new Bitmap(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width,
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height,
System.Drawing.Imaging.PixelFormat.Format32bppArgb);
System.Drawing.Graphics GFX = System.Drawing.Graphics.FromImage(BMP);
GFX.CopyFromScreen (System.Windows.Forms.Screen.PrimaryScreen.Bounds.X,
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Y, 0, 0,
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size,
System.Drawing.CopyPixelOperation.SourceCopy);
return BMP;
}