I have a need to convert Pixels to Points in C#. I've seen some complicated explanations about the topic, but can't seem to locate a simple formula. Let's assume a standard 96dpi, how do I calulate this conversion?
There are 72 points per inch; if it is sufficient to assume 96 pixels per inch, the formula is rather simple:
points = pixels * 72 / 96
There is a way to get the configured pixels per inch of your display in Windows using GetDeviceCaps
. Microsoft has a guide called "Developing DPI-Aware Applications", look for the section "Creating DPI-Aware Fonts".
The W3C has defined the pixel measurement px
as exactly 1/96th of 1in regardless of the actual resolution of your display, so the above formula should be good for all web work.