简体   繁体   English

Java Tookit屏幕分辨率-如何使用它?

[英]Java Tookit Screen Resolution - How can I use it?

When using int resolution = Toolkit.getDefaultToolkit().getScreenResolution(); 使用int resolution = Toolkit.getDefaultToolkit().getScreenResolution(); to get my monitor's resolution, the integer resolution returns 96. What does this mean, how could it be used, and, if possible, could I get the resolution in a 4:3, 16:9, etc. format? 要获得显示器的分辨率,整数resolution将返回96。这是什么意思,如何使用它?如果可能,我能否以4:3、16:9等格式获得分辨率?

getScreenResolution() return dots-per-inch (DPI). getScreenResolution()返回每英寸点数(DPI)。 If you want the size of the screen, just use getScreenSize() . 如果您想要屏幕的大小,只需使用getScreenSize()

Here's a quote that gets you the basic idea of DPI vs. pixels: 这是一个引言,使您了解DPI与像素的基本关系:

So, if you have a 600 pixel x 600 pixel image at 300DPI, it will output at 2 inches square. 因此,如果您具有300DPI的600像素x 600像素的图像,它将以2英寸见方输出。 If you change this images DPI to 150, this will mean it will output at 4 inches square. 如果将此图像的DPI更改为150,则表示它将以4英寸见方输出。 So, as you can see, changing the DPI of an image changes it output size. 因此,如您所见,更改图像的DPI会更改其输出大小。

You can find rest of the explanation here . 您可以在这里找到其余的解释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM