Windows GDI:水平/垂直DPI

Rob*_*Rob 7 c c++ windows gdi

在Windows下获取屏幕的DPI(使用:: GetDeviceCaps)时,水平值是否始终与垂直相同?例如:

HDC dc = ::GetDC(NULL);
const int xDPI = ::GetDeviceCaps(dc, LOGPIXELSX);
const int yDPI - ::GetDeviceCaps(dc, LOGPIXELSY);
assert(xDPI == yDPI);
::ReleaseDC(NULL, dc);
Run Code Online (Sandbox Code Playgroud)

这些价值观是否有所不同?

小智 7

它可能有所不同,但通常只适用于打印机.可以安全地假设屏幕将始终具有相同的水平和垂直DPI.