Display size to DPI

From Flavio's wiki
Revision as of 20:49, 12 April 2007 by Admin (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The driver gets display size from EDID:

 (II) fglrx(0): Max H-Image Size [cm]: horiz.: 34  vert.: 27
 (II) fglrx(0): clock: 108.0 MHz   Image Size:  338 x 270 mm
 (--) fglrx(0): Display dimensions: (340, 270) mm

(Notice how the driver shows two slightly different image size values; I don't know which one is supposed to be the "best".)

As it knows the image size (in my case 1280x1024), it can calculate the DPI:

 (--) fglrx(0): DPI set to (95, 96)

That is likely the result of:

 1280 / 340 mm * 25.4mm/inch = 95.62352941176470588
 1024 / 270 mm * 25.4mm/inch = 96.33185185185185185

As you see, the calculated DPI are not integer values, so they are truncated to produce the DPI values that will reach the X server.

Then you can ask the X server what it thinks about your display size with xdpyinfo; X will give you back a slightly different value for the display size because of the truncated values:

 dimensions:    1280x1024 pixels (342x271 millimeters)
 resolution:    95x96 dots per inch

That is likely the result of:

 1280 / 95 DPI = 13.47368421052631579 inches * 25.4 = 342.2315789473684211 mm
 1024 / 96 DPI = 10.66666666666666667 inches * 25.4 = 270.9333333333333333 mm

Notice how X correctly rounds these values to integers, giving you 342x271 mm; if the driver had rounded the results instead of truncated, it would have obtained a slightly better (and perfectly square) approximation of 96x96 DPI, and presumably X would have calculated the display width as 338.6666666666666667 mm.