Win32 - Toolbar transparency

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
metalogic
Super wx Problem Solver
Super wx Problem Solver
Posts: 307
Joined: Fri Oct 08, 2004 8:21 am
Location: Area 51
Contact:

Win32 - Toolbar transparency

Post by metalogic »

Hi all,
I've been trying to figure out this problem for some time. Whenever I get close something else breaks :(

Problem is toolbar transparency. My understanding is that under Win32, RGB=192,192,192 is the magic color that will be replaced by whatever the current color is for buttons.
This appears to be true under wxWidgets also but, it also is replacing other shades of gray that are not magic. I was stumped on this for a while then I found a post recommending to call

Code: Select all

wxSystemOptions::SetOption(wxT("msw.remap"), 0);
so I did that and sure enough, it stops messing with my other grays but it also stops messing with magic gray. In other words, I no longer have any transparency whatsoever.

I've tried bitmaps, PNG, XPM and who knows whatever else.

My questions are:
  • * Is it a bug that non-magic grays are getting mapped to transparent?
    * When using msw.remap how do I use transparency?
TIA,
Santiago

wxWidgets 2.5.3
VC++ 2003
Window XP
metalogic
Super wx Problem Solver
Super wx Problem Solver
Posts: 307
Joined: Fri Oct 08, 2004 8:21 am
Location: Area 51
Contact:

Post by metalogic »

As is often the case in these situations, even though I'd been struggling with this for days, as soon as I post a cry for help, I find the answer :)

Problem was not wxWidgets, it was my PNG. For some reason the transparent color wasn't "taking". So I upgraded to the latest version of my image software, re-converted the bitmaps and sure enough, things started working. And for extra bonus points, the latest version supports XPM directly!

- Santiago
Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg »

I can only say, use XPM. You can save the transparency with the bitmap and in my opinion it is easier in usage too (less overhead) ..

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
metalogic
Super wx Problem Solver
Super wx Problem Solver
Posts: 307
Joined: Fri Oct 08, 2004 8:21 am
Location: Area 51
Contact:

Post by metalogic »

Jorg wrote:I can only say, use XPM.
Yep, as soon as I saw that option I switched. Life is good.

Thanks,
Santiago
kkkwj
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Nov 01, 2004 3:45 am

bitmaps to transparent xpm procedure?

Post by kkkwj »

Hi, I'm trying to make up and convert some bitmaps to transparent xpms for use as wx toolbar buttons. I have Photoshop for making bitmaps, and ImageBlocks for converting bitmaps to xpms. But I don't know how to get the transparency stuff right.

I have searched the wx website, the wx doc, the dialogblocks doc, and this message board (and found this solitary thread).

Would someone out there who knows how please be kind enough to post a step by step procedure for us people who are in the dark?

Thank you
kkkwj
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Nov 01, 2004 3:45 am

how to convert bitmaps and gifs to xpm format

Post by kkkwj »

Here is a procedure for how to convert bitmap and gif files into transparent toolbar buttons in xpm format. I know this sounds really easy now, but it took me a long time to figure it out. Thanks to the person above who posted the hint about the magic 192 192 192 RGB colors for transparency on windows.

Create your bitmap, or your gif, in the desired size. My small wx bitmaps are 16x15 pixels.

Color the transparent pixels gray (RGB 192 192 192) in a bitmap (bitmaps have no real transparency). If you are using GIFs in Photoshop, set the blend mode to "clear" and opacity to 100%, and save it out as a GIF.

Then I use ImageBlocks to convert the bitmaps or gifs to xpm format. I'd be interested to hear what other tools can convert to xpm format. Photoshop CS doesn't. Bummer.
metalogic
Super wx Problem Solver
Super wx Problem Solver
Posts: 307
Joined: Fri Oct 08, 2004 8:21 am
Location: Area 51
Contact:

Post by metalogic »

I'm sure there are better ways of doing it but this worked for me so I'll share anyway:

What I did was:
1) Open my existing bitmaps with ArtIcons (http://www.aha-soft.com/articons/)*

2) Under the color palette, there is a box for Transparent. I chose that color and flood filled all gray (192, 192, 192) areas with it.

3) Save as...

4) Selected XPM as the format.

* As the name implies, ArtIcons is an icon editing program. It didn't have any problems opening and saving my non-icon images though. I previously tried PaintShop Pro and Gimp but I didn't find an easy way to make a straightforward transparency and couldn't be bothered learning the program for such a simple task. ArtIcons did a great job with that. Note that ArtIcons is Shareware, not freeware or open source.

- Santiago
kkkwj
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Nov 01, 2004 3:45 am

Articons and XPMs

Post by kkkwj »

Hi Santiago,

Thanks for making a post about ArtIcons. Man, that's a nice piece of software that makes it easy to do XPM transparencies and icon work. I'm using it now...

I tried using the 192/192/192 for transparency on windows toolbar bitmaps on XP, but that did not work for my bitmaps. I think my app toolbar was created with a CreateEx call in the code, and perhaps that prevents the 192 trick from working. My bitmaps were 8 bit color, and maybe that too prevents 192 from working. Sigh. What a mess. XPM on Wx is a LOT easier.

Cheers
kj
Post Reply