Windows GDI:水平/垂直 DPI

发布于 2024-07-09 05:07:29 字数 279 浏览 5 评论 0原文

当在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

蓝天 2024-07-16 05:07:29

它可能会有所不同,但这通常仅适用于打印机。 可以安全地假设屏幕始终具有相同的水平和垂直 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.

诗酒趁年少 2024-07-16 05:07:29

我从未见过它们有什么不同,但是这个 MSDN 页面我看到一条评论表明它们可能是:

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

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

I have never seen them be different, but on this MSDN page I see a comment that suggests that they might be:

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

   // almost always the same in both directions, but sometimes not!
若无相欠,怎会相见 2024-07-16 05:07:29

我从未见过它们不同的情况,但有两个单独的调用这一事实强烈表明它们有时可能会不同。

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.

时光与爱终年不遇 2024-07-16 05:07:29

如果显示器设置为使用与物理屏幕比例不同的屏幕分辨率,例如 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文