Java Tookit Screen Resolution - How can I use it?

2019-08-06 09:05发布

问题:

When using 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?

回答1:

getScreenResolution() return dots-per-inch (DPI). If you want the size of the screen, just use getScreenSize().

Here's a quote that gets you the basic idea of DPI vs. pixels:

So, if you have a 600 pixel x 600 pixel image at 300DPI, it will output at 2 inches square. If you change this images DPI to 150, this will mean it will output at 4 inches square. So, as you can see, changing the DPI of an image changes it output size.

You can find rest of the explanation here.



标签: java toolkit