// Returns an image object that is a screenshot of the current virtual screen. public static System.Drawing.Image CaptureScreenImage() { int screenWidth = SystemInformation.VirtualScreen.Width; int screenHeight = SystemInformation.VirtualScreen.Height; int screenLeft = SystemInformation.VirtualScreen.Left; int screenTop = SystemInformation.VirtualScreen.Top; Bitmap bitmap = new Bitmap(screenWidth, screenHeight); Graphics g = Graphics.FromImage(bitmap); g.CopyFromScreen(screenLeft, screenTop, 0, 0, new Size(screenWidth, screenHeight)); return bitmap; }
Posted: March 19, 2023
Return to the snippets listing