如何以编程方式获取屏幕DPI(linux,mac)? [英] How to get screen DPI (linux,mac) programatically?
问题描述
我需要了解Linux和Mac OS上的活动屏幕DPI.我认为在Linux xlib上可能很有用,但是我找不到找到正确DPI的方法. 我希望该信息获得以英寸为单位的实际屏幕尺寸.
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.
提前谢谢!
推荐答案
在Linux上的X中,调用XOpenDisplay()
获取Display
,然后将DisplayWidthMM()
和DisplayHeightMM()
以及DisplayWidth()
和
In X on Linux, call XOpenDisplay()
to get the Display
, then use DisplayWidthMM()
and DisplayHeightMM()
together with DisplayWidth()
and DisplayHeight()
to compute the DPI.
在Mac上,几乎可以肯定要使用比X更多的本机API.MacOS X默认情况下不运行X Window,它具有本机窗口环境.
On the Mac, there's almost certainly a more native API to use than X. Mac OS X does not run X Window by default, it has a native windowing environment.
这篇关于如何以编程方式获取屏幕DPI(linux,mac)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!