1

In my Swing application, since I migrated to Java 11, all my icons are bigger (with an unly antilias):

With Java 11 : Java 11

With Java 8 : Java 8

The icons are loaded basically this way:

BufferedInputStream stream = new BufferedInputStream(getApplicationRessource(pathToIcon));
int count = 0;
byte buf[] = new byte[MAX_IMAGE_SIZE];
try {
    count = stream.read(buf);
    stream.close();
} catch (IOException ieo) {
    logger.error("Reading icon file \"" + p + "\"", ieo);
}
icon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(buf));

How to improve this ? By either preventing this resize or providing icons alternates ?

lvr123
  • 524
  • 6
  • 24
  • The reason is that Java 8 doesn't handle properly the DPI settings of the OS. From Java9, it does. So if the DPI is set to 125%, all the icons will be enlarged by 125%. The solution to avoid blurred images is to provide images at different sizes. See [Can I supply image icons in Java in a higher resolution to avoid blurred icons after scaling?](https://stackoverflow.com/questions/70672430/can-i-supply-image-icons-in-java-in-a-higher-resolution-to-avoid-blurred-icons-a) for a solution. – lvr123 Nov 01 '22 at 21:43

0 Answers0