0

I have a situation where I'm taking a screenshot of the WorkingArea of my PrimaryScreen. If the resolution is set to 100% in Windows, it works perfectly fineScreenshot with 100%

But if the resolution is set to 150%, it takes a partial screenshot.Screenshot with 150%

The code I've made goes like this:

Bitmap captureBitmap = new Bitmap(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Rectangle captureRectangle = Screen.AllScreens[0].Bounds;
Graphics captureGraphics = Graphics.FromImage(captureBitmap);
captureGraphics.CopyFromScreen(captureRectangle.Left, captureRectangle.Top, 0, 0, captureRectangle.Size);
captureBitmap.Save($@"{_localDestination}\{timeStampFormated}\Screenshot.png", System.Drawing.Imaging.ImageFormat.Png);

What am I missing, in order to have it take a screenshot and doesn't care about scaling?

Thanks in advance!

wads
  • 123
  • 11
  • can you try replace size in `new Bitmap`, with size of `captureRectangle`? you need exchange 1st and 2nd statement. – Lei Yang Mar 11 '22 at 07:36
  • Just to clarify, do you mean it like this? Bitmap captureBitmap = new Bitmap(captureRectangle.Width, captureRectangle.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); – wads Mar 11 '22 at 07:41
  • yes. i'm just suggest a try, not sure work or not. – Lei Yang Mar 11 '22 at 07:45
  • Unfortunately, the same thing happens. – wads Mar 11 '22 at 07:48
  • [Taking a screenshot using Graphics.CopyFromScreen with 150% scaling](https://stackoverflow.com/questions/32438736/taking-a-screenshot-using-graphics-copyfromscreen-with-150-scaling) – Lei Yang Mar 11 '22 at 07:54
  • 1
    Does this answer your question? [Windows screenshot with scaling](https://stackoverflow.com/questions/47015893/windows-screenshot-with-scaling) Just checked - setting dpiAware in manifest to true/pm fixed the issue for me. – defaultUsernameN Mar 11 '22 at 08:30
  • @defaultUsernameN Yes, that did the trick! Thank you :) – wads Mar 11 '22 at 08:38

0 Answers0