Closed DiscreteTom closed 1 year ago
Currently the screen size is calcualted from DXGI_OUTPUT_DESC.DesktopCoordinates
, which is suitable to locate the screen and scale the screen, but the resolution is wrong in high DPI situation.
IDXGIOutput::GetDesc method (dxgi.h): On a high DPI desktop, GetDesc returns the visualized screen size unless the app is marked high DPI aware. For info about writing DPI-aware Win32 apps, see High DPI.
According to ChatGPT:
GetDpiForMonitor
.pixelWidth = width * dpi / 96
.E.g. screen with 2400 pixel width, 150% scale, got width 1600 and dpi 144, 2400 = 1600 * 144 / 96
.
From ChatGPT:
Use OutputDuplication->GetDesc(&duplDesc)
, then the duplDesc.ModeDesc.Width/Height
is the actual pixel dimension.
Sometimes the screen size from
DXGI_OUTPUT_DESC
is the size after zoomed.E.g., I have a screen with 2400x1600 and 150% scale, sometimes the returned dimension is 1600x1067.