Systray (TrayItem) icon background not transparent

I’m trying out using TrayItem for the first time. Pretty easy to get it up and running based on the built-in example. I am having trouble with the icon I’m using in that I can’t get the background to be transparent. The icon is circular in shape and the square border around it is obvious. I’ve tried making a transparent background PNG file with my icon, but XOJO just makes it a white background when compiled and ran. I’ve also tried color matching the Windows 10 Systray background, and while that looks great on some monitors, on others it looks worse. Is there a way to make the background transparent in XOJO? All the other circular icons in my Systray from Microsoft and other vendors are transparent. Hoping this is not a limitation of XOJO. Would be grateful for any advice! Thanks!

Check that your source image is really transparent. I can confirm that TrayItem does indeed support transparency, my Issues Linker TrayItem app is working as expected.

I made the PNG using Pixelmator Pro. It shows up without any background when I open it on either the macOS or Windows. Any other way to check it’s actually transparent beyond visual inspection of the file?

Export as PNG with Transparency (and being sure there’s no background layer) should be sufficient. The other thing to check would be the code that sets the icon. If you’re creating your own in-memory picture that needs to be transparent as well.

Double checked the first part. Still white background.

On your 2nd point I’m using the stock code from the example, just commenting out the masking option and the name and location of the icons is different of course. Here’s what i have currently.

Var p As Picture
p = New Picture(CH_LOGO_0.Width / 2, CH_LOGO_0.Height, 32)
p.Graphics.DrawPicture(CH_LOGO_0, 0, 0, p.Width, p.Height)
'p.Mask.Graphics.DrawPicture(CH_LOGO_0, 0, 0, p.Width, p.Height, p.Width, 0, p.Width, p.Height)
mIcons(0) = p

p = New Picture(CH_LOGO_1.Width / 2, CH_LOGO_1.Height, 32)
p.Graphics.DrawPicture(CH_LOGO_1, 0, 0, p.Width, p.Height)
'p.Mask.Graphics.DrawPicture( CH_LOGO_1, 0, 0, p.Width, p.Height, p.Width, 0, p.Width, p.Height)
mIcons(1) = p

p = New Picture(CH_LOGO_2.Width / 2, CH_LOGO_2.Height, 32)
p.Graphics.DrawPicture(CH_LOGO_2, 0, 0, p.Width, p.Height)
'p.Mask.Graphics.DrawPicture(CH_LOGO_2, 0, 0, p.Width, p.Height, p.Width, 0, p.Width, p.Height)
mIcons(2) = p

p = New Picture(CH_LOGO_3.Width / 2, CH_LOGO_3.Height, 32)
p.Graphics.DrawPicture(CH_LOGO_3, 0, 0, p.Width, p.Height)
'p.Mask.Graphics.DrawPicture(CH_LOGO_3, 0, 0, p.Width, p.Height, p.Width, 0, p.Width, p.Height)
mIcons(3) = p

p = New Picture(CH_LOGO_4.Width / 2, CH_LOGO_4.Height, 32)
p.Graphics.DrawPicture(CH_LOGO_4, 0, 0, p.Width, p.Height)
'p.Mask.Graphics.DrawPicture( CH_LOGO_4, 0, 0, p.Width, p.Height, p.Width, 0, p.Width, p.Height)
mIcons(4) = p



Me.Icon = mIcons(0)

The drawing (scaling) of your logo pictures into the p picture is removing the alpha channel.

Solutions…
1.Prepare the logos the correct size so that you don’t have to scale them in code.

2.Scale the foreground and alpha channels separately into the p picture.
Something like:

p = New Picture(CH_LOGO_0.Width / 2, CH_LOGO_0.Height, 32)
p.Graphics.DrawPicture(CH_LOGO_0.CopyColorChannels, 0, 0, p.Width, p.Height)
p.Mask.Graphics.DrawPicture(CH_LOGO_0.CopyMask, 0, 0, p.Width, p.Height)

Perfect! Your second suggestion worked like a charm! I’ll mess with resizing the pictures sometime to get rid of the odd 32x64 format that was in the example, but for now, this works great! Thank you very much!