简体   繁体   English

Windows GDI:水平/垂直DPI

[英]Windows GDI: horizontal/vertical DPI

When obtaining the DPI for the screen under Windows (by using ::GetDeviceCaps) will the horizontal value always be the same as the vertical? 在Windows下获取屏幕的DPI(使用:: GetDeviceCaps)时,水平值是否始终与垂直相同? For example: 例如:

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

Are these values ever different? 这些价值观是否有所不同?

It's possible for it to be different, but that generally only applies to printers. 它可能有所不同,但通常只适用于打印机。 It can be safely assumed that the screen will always have identical horizontal and vertical DPIs. 可以安全地假设屏幕将始终具有相同的水平和垂直DPI。

I have never seen them be different, but on this MSDN page I see a comment that suggests that they might be: 我从未见过它们有所不同,但在这个 MSDN页面上,我看到一条评论表明它们可能是:

   int nHorz = dc.GetDeviceCaps(LOGPIXELSX);
   int nVert = dc.GetDeviceCaps(LOGPIXELSY);

   // almost always the same in both directions, but sometimes not!

我从来没有见过他们不同的情况,但事实上有两个单独的呼吁强烈暗示他们有时可能。

如果将显示器设置为使用与物理屏幕比率不同的屏幕分辨率,例如在16:9显示器上为1600x1200的4:3分辨率,则它们很容易变得不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM