How to get screen DPI (linux,mac) programatically?

k3a picture k3a · Apr 12, 2010 · Viewed 10.6k times · Source

I need to know active screen DPI on Linux and Mac OS. I think on linux xlib might be useful, but I can't find a way how to get currect DPI. I want this information to get real screen size in inches.

Thanks in advance!

Answer

uli picture uli · Jun 17, 2011

On a mac, use CGDisplayScreenSize to get the screen size in millimeters.