Convert Pixels to Points
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.
Assuming 96dpi is a huge mistake. Even if the assumption is right, there's also an option to scale fonts. So a font set for 10pts may actually be shown as if it's 12.5pt (125%).
Try this if your code lies in a form:
Graphics g = this.CreateGraphics();
points = pixels * 72 / g.DpiX;
g.Dispose();