Capture and import of screen C#

Add a Button and change its name to GetCapture and write this below code on Button’s Click event handler.

private void GetCapture_Click(object sender, EventArgs e)
{
this.BackgroundImage= CaptureScreen();
}

Write this below code on class Form

private Image CaptureScreen()
{
Bitmap screen = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height);
using (Graphics g = Graphics.FromImage(screen))
{
g.CopyFromScreen(0, 0, 0, 0, screen.Size);
}
return screen;
}

Leave a Reply

Your email address will not be published. Required fields are marked *