So I've been trying to get the screenshot of my current active window and I'm following the answers given in Capture screenshot of active window?
This is what I expect to see
But for some reason I get the following screenshot
This is how I get the Bitmap:
public Bitmap Capture()
{
Rectangle bounds;
var foregroundWindowsHandle = GetForegroundWindow();
var rect = new Rect();
GetWindowRect(foregroundWindowsHandle, ref rect);
bounds = new Rectangle(rect.Left, rect.Top, (rect.Right - rect.Left), (rect.Bottom - rect.Top));
var result = new Bitmap(bounds.Width, bounds.Height);
using (var g = Graphics.FromImage(result))
{
g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
}
return result;
}
Where I later save I to a jpeg file
I tried all of the methods proposed in the mentioned link
What am I missing here?