i'm using the Code from this question, to save screenshots into a bitmap: Capture the Screen into a Bitmap
there is one Problem, the line Screen.PrimaryScreen.Bounds.X
and Screen.PrimaryScreen.Bounds.Y
return 1500,1000
but my screen is 3000,2000
scaled by 200%
the result of this error is an Image with size 1500,1000 from the top left corner.
how i worked around is by simply multiplying the dimensions by 2, but i dont want to hard code this scale factor, i somehow want to get it indevidually.
i also tried this, but this registry entry simply doesnt exist on my computer: Get scale of screen
here the 2 screenshots, 1. what i want 2. what i get
my current code:
int boundsX = Screen.PrimaryScreen.Bounds.X * 2;
int boundsY = Screen.PrimaryScreen.Bounds.Y * 2;
Size screenSize = Screen.PrimaryScreen.Bounds.Size;
screenSize = new Size(screenSize.Width * 2, screenSize.Height * 2);
int boundsWidth = Screen.PrimaryScreen.Bounds.Width * 2;
int boundsHeight = Screen.PrimaryScreen.Bounds.Height * 2;
// Create a new bitmap.
var bmpScreenshot = new Bitmap(boundsWidth,
boundsHeight,
PixelFormat.Format32bppArgb);
// Create a graphics object from the bitmap.
var gfxScreenshot = Graphics.FromImage(bmpScreenshot);
// Take the screenshot from the upper left corner to the right bottom corner.
gfxScreenshot.CopyFromScreen(boundsX,
boundsY,
0,
0,
screenSize ,
CopyPixelOperation.SourceCopy);
bmpScreenshot.Save("Screenshot.png", ImageFormat.Png);