Reputation: 78748
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?
Upvotes: 7
Views: 2527
Reputation: 5131
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.
Upvotes: 0
Reputation: 309
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.
Upvotes: 7
Reputation: 39888
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.
Upvotes: 0
Reputation: 101494
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!
Upvotes: 1