如何通过Java检测Mac是否具有Retina显示屏? [英] How can I detect whether a Mac has a Retina display from Java?

查看:123
本文介绍了如何通过Java检测Mac是否具有Retina显示屏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了一个Swing图像渲染错误,该错误仅会影响具有Retina显示屏的Mac(TYPE_INT_ARGB_PRE BufferedImages无法绘制).我有一个有效的解决方法(改为使用TYPE_INT_ARGB图像),但是要应用它,我需要能够检测主机是否为具有Retina显示屏的Mac.检测机器是否为Mac没问题,但是如何确定显示类型?

I've found a Swing image rendering bug which afflicts only Macs with Retina displays (TYPE_INT_ARGB_PRE BufferedImages fail to draw). I have an effective workaround (use TYPE_INT_ARGB images instead), but in order to apply it, I need to be able to detect whether the host machine is a Mac with a Retina display. Detecting whether the machine is a Mac is no problem, but how can I determine the display type?

推荐答案

Toolkit.getDefaultToolkit().getDesktopProperty("apple.awt.contentScaleFactor")

以上行应在视网膜显示屏上返回2.0.在较新的非视网膜Mac上,它返回1.0,而在所有其他平台上,您返回null.我找不到任何官方文档,但是在此邮件列表帖子,同时尝试解决类似的问题.

The above line should return 2.0 on retina displays. On more recent non-retina macs it returns 1.0 and on all other platforms you get back null. I can't find any official documentation, but I ran across it in this mailing list post while trying to solve a similar problem.

这篇关于如何通过Java检测Mac是否具有Retina显示屏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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