Accordance between pixel and mm

无人久伴 提交于 2020-01-17 07:41:11

问题


I'm doing:

        PhysicalParameters()
    {
        IntPtr DeskTopHWND = GetDesktopWindow();
        IntPtr HDC = GetDC(DeskTopHWND);
        int mmX = GetDeviceCaps(HDC, HORZSIZE);
        int mmY = GetDeviceCaps(HDC, VERTSIZE);
        int pxX = GetDeviceCaps(HDC, HORZRES);
        int pxY = GetDeviceCaps(HDC, VERTRES);
        ReleaseDC(DeskTopHWND, HDC);
        double CoeffPIX_MM_X = 1.0 * mmX / pxX;
        double CoeffPIX_MM_Y = 1.0 * mmY / pxY;
    }

The result for both is 0.25

But what I see (MS Word' WysiWyg ) it should be about 0.27

Please, explain the subject.


回答1:


Typical LCD monitors have a 96 pixel-per-inch density. This translates to a pixel size of 0.0104167 inch or 0.265 mm.

However manufacturing techniques differ drastically, and therefore pixel sizes are not fixed. Different monitors and devices will have difference pitches and densities. So the short answer is there is no correlation between pixels and a unit of measure. A pixel is whatever size you (or a manufacturer of a device) want it to be.

References:

  • http://en.wikipedia.org/wiki/Pixel_density
  • http://en.wikipedia.org/wiki/Pixel
  • http://en.wikipedia.org/wiki/Display_resolution



回答2:


Each device is going to have a slightly different HORZSIZE, HORZRES, VERTSIZE and VERTRES.




回答3:


Calling GetDeviceCaps for HORZSIZE doesn't actually get the horizontal size of your monitor - it gets what the size would be if it was a 96 DPI monitor at the current resolution.

The 96 DPI is the default, of course - users can set the system DPI and if they set it accurately, you will get the right value back for the size of the monitor. Hardly anyone does this, though - so you will almost always get back values assuming 96 DPI.



来源:https://stackoverflow.com/questions/7044476/accordance-between-pixel-and-mm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!