Windows GDI:水平/垂直 DPI
当在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);
这些值有不同吗?
When obtaining the DPI for the screen under Windows (by using ::GetDeviceCaps) will the horizontal value always be the same as the vertical? 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
它可能会有所不同,但这通常仅适用于打印机。 可以安全地假设屏幕始终具有相同的水平和垂直 DPI。
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.
我从未见过它们有什么不同,但是这个 MSDN 页面我看到一条评论表明它们可能是:
I have never seen them be different, but on this MSDN page I see a comment that suggests that they might be:
我从未见过它们不同的情况,但有两个单独的调用这一事实强烈表明它们有时可能会不同。
I've never seen a case where they're different, but the fact that there are two separate calls for it strongly suggests that they might be sometimes.
如果显示器设置为使用与物理屏幕比例不同的屏幕分辨率,例如 4:3 分辨率(如 16:9 显示器上的 1600x1200),它们很容易会有所不同。
Its easy for them to be different if the monitor is set up to use a screen resolution ratio that is not the same as the physical screen ratio, such as a 4:3 resolution like 1600x1200 on a 16:9 display.