Search This Blog

Monday, January 19, 2015

C# Capture Screen to PictureBox

C# > Drawing > Capture Screen

Bitmap printscreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics graphics = Graphics.FromImage(printscreen as Image);
graphics.CopyFromScreen(0, 0, 0, 0, printscreen.Size);
using (MemoryStream s = new MemoryStream())
{
printscreen.Save(s, System.Drawing.Imaging.ImageFormat.Bmp);
       picCapture.Size = new System.Drawing.Size(this.Width, this.Height);
       picCapture.Image = Image.FromStream(s);

}