dustinkredmond / FXTrayIcon

Tray Icon implementation for JavaFX applications. Say goodbye to using AWT's SystemTray icon, instead use a JavaFX Tray Icon.
MIT License
324 stars 25 forks source link

Icon looks distorted #32

Closed hrzafer closed 2 years ago

hrzafer commented 2 years ago

My icon is 16x16. SystemTray.getSystemTray().getTrayIconSize() returns java.awt.Dimension[width=16,height=16] as well. But sometimes the icon looks distorted as in the image:

image

How can I fix that? Have you guys faces a similar issue?

EasyG0ing1 commented 2 years ago

@hrzafer If you're using a mac, then use an icon that is at least 24 x 24 pixels and define it as such in FXTrayIcon. I'v discovered that with the Mac, is doesn't really matter what dimensions you give FXTI above something like 22 x22 or somewhere around there if I remember correctly, and it ends up looking very nice... This key, for example, is being presented by FXTrayIcon and as you can see ... there are even noticeable details in the cut portion of the key...

Screen Shot 2021-12-12 at 12 39 12 AM

.

hrzafer commented 2 years ago

The image above is from windows-11. This one is from windows-10: image

icon looks OK on the system tray:

image

EasyG0ing1 commented 2 years ago

@hrzafer - I was just looking at the Oracle sample project for the AWT TrayIcon and they posted a gif file that they used for their icon. I copied that file and put a star in it. Here is how they create the image for the TrayIcon object:

final TrayIcon trayIcon = new TrayIcon(createImage("images/bulb.gif", "tray icon"));

USing this method to actually create the image:

 protected static Image createImage(String path, String description) {
    URL imageURL = TrayIconDemo.class.getResource(path);

    if (imageURL == null) {
        System.err.println("Resource not found: " + path);
        return null;
    } else {
        return (new ImageIcon(imageURL, description)).getImage();
    }
}

And here is the gif that I made from theirs:

star

Not sure it will be of any use to you, but it might be worth trying it their way to see if you get any different results.

I actually found it curious that they assigned a description to the image ... not sure what that's about...

hrzafer commented 2 years ago

I converted my logo.png to logo.gif via an online converter and it looks fine. Interesting. Thanks for the tip.

dustinkredmond commented 2 years ago

Closing as this issue is caused by underlying AWT code and not by FXTrayIcon specific code.