屏幕显示尺寸 [英] Screen display size

查看:119
本文介绍了屏幕显示尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在编写图形程序,我一直在寻找一种方法来获得正在使用的屏幕的物理尺寸。我可以获得屏幕大小(以像素为单位)以及逻辑分辨率。我似乎无法找到的任何地方都可以获得任何显示器规格中的物理尺寸(例如19 - 376 x 301 mm)。问题是,这些信息甚至存储在操作系统的任何位置,当它加载时正在使用的特定屏幕的驱动程序?我正在编写的程序需要在Mac和Windows上运行。

Hi I'm writing a graphics program and I've been searching for a way to get the physical size of the screen being used. I can get the size of the screen in pixels and also the logical resolution. What I can't seem to find is anywhere to get the physical dimensions that are always in the specs for any monitor (eg 19"- 376 x 301 mm). Question, is this information even stored anywhere in the OS when it loads the driver for the particular screen being used? The program I'm writing needs to work on Mac and Windows.

谢谢!

nt

推荐答案

我不认为这是可能的java。你可以尝试写一些jni代码,如果这样功能在您的程序中绝对必不可少。否则,只需询问用户的显示器尺寸。

I don't think it's possible with java. You can try to write some jni code if this feature is absolutely essential in your program. Otherwise, just ask the user for their monitor size.

编辑看起来SWT可以为您提供DPI,你可以用它来计算显示器的大小:
http://www.java2s.com/Code/JavaAPI/org.eclipse.swt.graphics/DevicegetDPI.htm

EDIT Looks like SWT can give you DPI, and you can calculate the monitor size with it: http://www.java2s.com/Code/JavaAPI/org.eclipse.swt.graphics/DevicegetDPI.htm

但是,你会必须使用SWT :)这实际上并没有那么糟糕选择是否要为Mac开发好看的程序。

But, you'd have to use SWT :) Which is actually not that bad choice if you want to develop good-looking programs for Mac.

这篇关于屏幕显示尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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