Portable Network Graphics in menu items
-
- Earned a small fee
- Posts: 10
- Joined: Thu Jan 19, 2006 3:01 pm
Portable Network Graphics in menu items
According to the documentation, support for the alpha component of images is available in recent versions of wxWidgets, but there doesn't seem to be any way to use PNG images with alpha bits in menu items (I have no idea if this is the same for other controls as well). Images with translucent bits are always shown as black instead of letting the background color get through.
Is it really not supported or am I just overlooking something?
Is it really not supported or am I just overlooking something?
I use the following code:
You can look at the detailed info about wxSystemOptions.
Code: Select all
#ifdef __WXMSW__
{
if (wxTheApp->GetComCtl32Version() >= 600 && ::wxDisplayDepth() >= 32)
wxSystemOptions::SetOption(wxT("msw.remap"), 2);
else
wxSystemOptions::SetOption(wxT("msw.remap"), 0);
}
#endif //__WXMSW__
-
- Earned a small fee
- Posts: 10
- Joined: Thu Jan 19, 2006 3:01 pm
-
- Earned a small fee
- Posts: 10
- Joined: Thu Jan 19, 2006 3:01 pm
- tierra
- Site Admin
- Posts: 1355
- Joined: Sun Aug 29, 2004 7:14 pm
- Location: Salt Lake City, Utah, USA
- Contact:
To expand on eco's reply, your PNG is guilty of having an alpha channel with values other than 0x00 and 0xFF. One way of fixing this if you have GIMP, is to open the image, go to Layer->Transparency->Threshold Alpha and use any value you want that works best for you. That will force every pixel in the alpha channel to be changed to a value of 0x00 or 0xFF depending on what it's original value was.
I've taken your PNG and done this for you as an example, see if this one works for you:
It's still possible that your problem isn't related though since your on XP, but you will have to take that into consideration for non-XP users.
I've taken your PNG and done this for you as an example, see if this one works for you:
It's still possible that your problem isn't related though since your on XP, but you will have to take that into consideration for non-XP users.
-
- Earned a small fee
- Posts: 10
- Joined: Thu Jan 19, 2006 3:01 pm
- tierra
- Site Admin
- Posts: 1355
- Joined: Sun Aug 29, 2004 7:14 pm
- Location: Salt Lake City, Utah, USA
- Contact:
If it comes down to it, you could still pull this off not only on WinXP, but on other platforms as well by using this trick: http://forums.wxwidgets.org/viewtopic.php?t=4965 (while specific to printing, it can still be applied here as well)
Just replace wxWHITE_BRUSH with the proper system color and your set... though I'm willing to bet you'd then get picky about the menu item highlight color not showing through on transparent images.
Doing web design for years now, I understand your frustration (waiting on full alpha transparency support in IE has been hell, and will continue to be for years to come), but just remember your using a cross-platform GUI toolkit, and I'm sure the devs are more concerned about consistency across platforms than platform specific features. This is one area where you may need to just jump strait into Win32 API calls if your only platform in use is Windows XP. It's not like wxWidgets prevents you from doing it.
One last item that came to my attention. The 2.6.3 changelog shows this item as fixed: "wxImage::Copy() forgot the alpha channel" ... this could be a culprit as wxMenu could be using it for something. It may be worth downloading the 2.6.3-rc1 release or just checking out from CVS to see if that fixes it.
Just replace wxWHITE_BRUSH with the proper system color and your set... though I'm willing to bet you'd then get picky about the menu item highlight color not showing through on transparent images.
Doing web design for years now, I understand your frustration (waiting on full alpha transparency support in IE has been hell, and will continue to be for years to come), but just remember your using a cross-platform GUI toolkit, and I'm sure the devs are more concerned about consistency across platforms than platform specific features. This is one area where you may need to just jump strait into Win32 API calls if your only platform in use is Windows XP. It's not like wxWidgets prevents you from doing it.
One last item that came to my attention. The 2.6.3 changelog shows this item as fixed: "wxImage::Copy() forgot the alpha channel" ... this could be a culprit as wxMenu could be using it for something. It may be worth downloading the 2.6.3-rc1 release or just checking out from CVS to see if that fixes it.
-
- Earned a small fee
- Posts: 10
- Joined: Thu Jan 19, 2006 3:01 pm