iseahound/ImagePut

when i use it to set menu tray icon, it looks sharper

Opened this issue · 6 comments

test.zip
here is test file.

pic1 is normal
1

pic2 is sharper
2

1-1
1-2
1-3
1-4

Your .ico file contains 4 different versions of the same image - 16x16, 24x24, 32x32, and 48x48.

From https://www.autohotkey.com/docs/commands/Menu.htm#Icon

Slight distortion may occur when loading tray icons from file types other than .ICO. This is especially true for 16x16 icons. To prevent this, store the desired tray icon inside a .ICO file.

So use the .ico format, with Menu, Tray, Icon because it will automatically load the correct size based on DPI (I think).

Further testing may be needed with single dimension .ico files.

test (2).zip

i tested single dimension .ico files, but still have this problem.

Looks like different interpolation by windows to me:

2022-07-11 00꞉33꞉19

The first cat is your 16x16 icon, and the third cat the 24x24 icon. As you can see, what is shown on the tray is something between 16 and 24.

I don't really know why this is happening, but my best guess is that a different algorithm is used to scale ico vs hbitmaps.

I think:

  • HBITMAP is a RGB format with an unofficial "alpha" channel. When LoadImage is called using HBITMAP it uses the black pixels to scale. Because the transparent pixels are 0x00000000 (begins with 0x00 + black), they are ignored, but the semi-transparent pixels just have their alpha channel ignored, so maybe that is why the black border is bigger with HBitmap.
  • ICO has transparency, so LoadImage behaves correctly.

Another picture:
2022-07-11 00꞉45꞉28
top cat is 16x16
bottom cat is 24x24
None of the tray icon cats are identical to source

Feel free to leave this issue open, maybe there is something I can do, but it's not obvious to me now