Wednesday, February 25, 2009

How To: Capture Screen Image using C#

In this article I will show you How to Capture Screen Image using C#.

- Create Windows Application Using C#.
- Add the following code :
using System.Drawing;
using System.Drawing.Imaging;

private void Form1_Load(object sender, EventArgs e)

public Bitmap ImageBitmap
Rectangle screenShot;
Bitmap sBit;

//Drawing a Rectangle
screenShot = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;

//Set image size and format
sBit = new Bitmap(screenShot.Width, screenShot.Height, PixelFormat.Format32bppArgb);
Graphics sGraphic = Graphics.FromImage(sBit);

//Capture From Screen
sGraphic.CopyFromScreen(screenShot.Left, screenShot.Top, 0, 0, screenShot.Size);

return sBit;

1 comment: