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
Site Admin
Site Admin
Posts: 1276
Joined: Sat Apr 16, 2011 7:49 am
Location: Montreal, Canada

How to Captures the screen to a Bitmap object


Post by Superl » Sat Dec 19, 2015 5:55 am

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.
  1. /// <summary>
  2. /// A method to capture the screen to a Bitmap object
  3. /// </summary>
  4. /// <returns>A Bitmap object of the current screen</returns>
  5. public static Bitmap CaptureScreen ()
  6. {
  7.      Bitmap BMP = new Bitmap(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width,
  8.            System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height,
  9.            System.Drawing.Imaging.PixelFormat.Format32bppArgb);
  11.      System.Drawing.Graphics GFX = System.Drawing.Graphics.FromImage(BMP);
  12.      GFX.CopyFromScreen (System.Windows.Forms.Screen.PrimaryScreen.Bounds.X,
  13.           System.Windows.Forms.Screen.PrimaryScreen.Bounds.Y, 0, 0,
  14.           System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size,
  15.           System.Drawing.CopyPixelOperation.SourceCopy);
  17.      return BMP;
  18. }

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

Have a nice day :103:

Post Reply

Return to “Coding Forum”

Who is online

Users browsing this forum: No registered users and 1 guest