mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-28 23:45:17 -04:00
added a plausibility check to the dpi calculation
This commit is contained in:
parent
6606a7aae0
commit
1b032b7975
@ -372,7 +372,16 @@ public final class Keys {
|
|||||||
|
|
||||||
private static int getDefaultScreenResolution() {
|
private static int getDefaultScreenResolution() {
|
||||||
try {
|
try {
|
||||||
return Toolkit.getDefaultToolkit().getScreenResolution();
|
int dpi = Toolkit.getDefaultToolkit().getScreenResolution();
|
||||||
|
|
||||||
|
// plausibility check
|
||||||
|
int widthInPixel = Toolkit.getDefaultToolkit().getScreenSize().width;
|
||||||
|
int widthInInch = widthInPixel / dpi;
|
||||||
|
// most people don't use a screen larger than 27 inch, so the resolution is presumably wrong
|
||||||
|
if (widthInInch > 27)
|
||||||
|
dpi = widthInPixel / 27;
|
||||||
|
|
||||||
|
return dpi;
|
||||||
} catch (HeadlessException e) {
|
} catch (HeadlessException e) {
|
||||||
return 95;
|
return 95;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user