![]() |
||||||||||||||||||||
Screen Pixels per InchScreen pixels per inch (ppi) is the ratio of the number screen pixels to physical screen dimensions. Well, that’s simple enough except for the fact that while we know the number of screen pixels from the maximum video resolution (e.g. 1024 × 768) the only place Windows can get physical screen dimensions is from the monitor driver, and will attempt to do so via the Application Programming Interface (API). The API is a massive library of programming functions that do all the grunt work. The relevant function is GetDeviceCaps (Get Device Capabilities) and, if it doesn’t send you to sleep, you can read the function description here for GetDeviceCaps. If you peruse this you will see the parameters for the function and the information one can retrieve. Two of those parameters are HORZSIZE and VERTSIZE
For my monitors, at maximum video resolution, I get:
The screen width values that Windows has retrieved for the LCD screens are near enough to those obtained by measuring screens with a ruler, but are way out for the CRT and Laptop screens. You can see there’s a problem. A programmer can’t rely on Windows to get actual screen dimensions, and if you don’t know the real physical size of the screen then you can’t draw physical lengths on the screen that match those on a ruler. Screen Inches are not physical inches. So what use is it to retrieve inaccurate screen dimensional information? Well, quite a lot actually because a programmer can use these dimensions to lay out things on screen. The fact that they are not accurate values is irrelevant, but that’s another topic completely. |
| © 2006 - 2010 Richard Mason |