How to Captures the screen to a Bitmap object

Will be posting article on how to create simple application, with full working code in C#
And welcome to anyone who want to post their own article
Post Reply
User avatar

Topic author
Superl
Site Admin
Site Admin
Man of action
Man of action
Posts: 1331
Joined: Sat Apr 16, 2011 7:49 am
12
Location: Montreal, Canada
Contact:

How to Captures the screen to a Bitmap object

#2276

Post by Superl »

Captures the screen to a Bitmap object Introduction:
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;
}


Come and say hello in here
Any donation will help click here please.

Have a nice day :103:
Post Reply

Return to “Coding Forum”