I have this code snippet below:
int screenLeft = (int)SystemParameters.VirtualScreenLeft;
int screenTop = (int)SystemParameters.VirtualScreenTop;
int screenWidth = (int)SystemParameters.VirtualScreenWidth;
int screenHeight = (int)SystemParameters.VirtualScreenHeight;
Bitmap bitmap_Screen = new Bitmap(screenWidth, screenHeight);
Graphics g = Graphics.FromImage(bitmap_Screen);
g.CopyFromScreen(screenLeft, screenTop, 0, 0, bitmap_Screen.Size);
if (!Directory.Exists(screenshotDir))
{
Directory.CreateDirectory(screenshotDir);
}
bitmap_Screen.Save(fileLoc);
I'm trying to take a snapshot of the entire desktop. It's just that VirtualScreenWidth
and VirtualScreenHeight
returns 1536 and 800 respectively, when my desktop size is 1920 x 1080. So the snapshot is just capturing a portion of the screen and not an entire screencap
I already found the exact same issue here Screen Resolution Problem In WPF? but being new to WPF and C# in general, I don't understand the selected answer.