Java Toolkit屏幕分辨率下降 [英] Java Toolkit Screen resolution descrepensies

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

问题描述

我正在使用Java获取屏幕的尺寸和分辨率.当我运行以下代码时,我将获得以下输出.

I'm using java to get the dimensions and resolution of my screen. When I run the following code, I get the output below.

Toolkit toolkit =  Toolkit.getDefaultToolkit ();
Dimension dim = toolkit.getScreenSize();
System.out.println("Width of Screen Size is "+dim.width+" pixels");
System.out.println("Height of Screen Size is "+dim.height+" pixels");       
int resolution =Toolkit.getDefaultToolkit().getScreenResolution();
System.out.println(resolution);

输出:

Width of Screen Size is 1920 pixels
Height of Screen Size is 1080 pixels
120

现在,Javadoc说getScreenResolution返回以dpi为单位的分辨率(每英寸点数).我的意思是,如果我有一个600像素宽的图像,那么它在屏幕上将是5英寸.当我测量时,它实际上是4英寸宽.告诉我应该是150 dpi.

Now the Javadoc says that getScreenResolution returns the resolution in dpi (dots per inch). I take that to mean if I have an image that is 600pxs wide that it would be 5 inches on my screen. When I measure, it is actually 4 inches wide. Indicating to me that it should be 150 dpi.

我的显示器是15.6英寸显示器,我测量它的宽度为13.6英寸,高7.6英寸.现在我的屏幕宽度显然是1920像素宽,每英寸约为141像素.同样是1080/7.6可以计算出每英寸141个像素.

My monitor is a 15.6" monitor and I measure it to be 13.6" wide and a little more than 7.6" tall. Now the width of my screen is apparently 1920 pixels wide which calculates to about 141 pixels per inch. Similarly 1080/7.6 calculates to about 141 pixels per inch.

此网页显示600x600px的图像.我在屏幕上将其测量为4.25英寸,可计算为141像素.

This web page displays a 600x600px image. I measure it on my screen to be 4.25" which calculates to 141 pixels.

为什么getScreenResolution返回120?

Why does getScreenResolution return 120?

请让我知道我是否误会了

Please let me know if I am mistaken on any of this.

推荐答案

Toolkit.getDefaultToolkit().getScreenResolution()尝试获取分辨率,但是取决于驱动程序的精度以及其他因素(例如,并非并非视频卡和显示器之间的所有连接都能够反馈有关尺寸的信息),返回的尺寸无法完全确定.

Toolkit.getDefaultToolkit().getScreenResolution() tries to get the resolution, but depending how accurate the drivers are and other thing (like that not all connections between the video card and monitor are not capable of feedback about the sizes), the size returned cannot be fully thrusted.

这篇关于Java Toolkit屏幕分辨率下降的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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