如何以编程方式获取屏幕DPI(linux,mac)? [英] How to get screen DPI (linux,mac) programatically?

查看:416
本文介绍了如何以编程方式获取屏幕DPI(linux,mac)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要了解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()以计算DPI.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆