user834850
user834850

Reputation:

Accordance between pixel and mm

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.

Upvotes: 0

Views: 1788

Answers (3)

Philip Rieck
Philip Rieck

Reputation: 32568

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.

Upvotes: 0

JYelton
JYelton

Reputation: 36512

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:

Upvotes: 2

Jonathan M
Jonathan M

Reputation: 17451

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

Upvotes: 0

Related Questions