views:

64

answers:

2

I am playing around with a small MFC-wizard-generated application, in Visual C++ 2010, and I just decided to put my own bitmap into the resources to replace the three-cubes MFC bitmap that shows up in the ribbon UI Application Button, aka the "marble".

The original appeared to use black (0,0,0) as a transparency color, but I am unable to determine what the MFC Ribbon (mfc-feature-pack stuff) stuff in Visual Studio 2010 does to determine transparency on a bitmap used as the ribbon's main icon.

The properties of the ribbon (IDR_RIBBON) show Image=IDB_MAIN, and IDB_MAIN is a 32x32 bitmap in BMP format, loaded from a disk file called main.bmp.

Some of the bitmap resources in this project have what looks like what I would expect: A magenta color which becomes transparent, but the MFC main bitmap did not use this color scheme or palette.

Here is an example of the actual results, which are I hope show that the results are not what I wanted: alt text

Incidentally, It does not seem possible to use an ICON resource in the Application Button, so I am a little mystified how they pull off the transparency in it.

+1  A: 

Translucent PNG, perhaps? Did you know that BMP files can also have alpha channels?

Kawa
According to my various icon editing tools, BMP and PNG files do not support transparency. Maybe that means, PNG format DOES support it, but none of my tools do. I wonder, how did MFC do it before alpha channels though? What happened to good old magenta?
Warren P
It's your tools. PNG supported alpha from the beginning. Now, tools with alpha-BMP support are very rare indeed, mostly because it's really just cheating with the fact that RGB bitmaps (opposite RLE compressed ones) are 32 bits: red, green, blue... and alpha, usually set to fully opaque.
Kawa
+1  A: 

You need to create a 32-bit bitmap that has an alpha channel for transparency. The method by which I've done this is not very straightforward but it was the only thing I could come up with.

  • Use Paint.Net to convert your source image into a PNG that preserves the transparency. Unfortunately Paint.Net does not support creating 32-bit bitmaps directly.
  • Then download AlphaConv which can create the 32-bit bitmap from the PNG file.
Praetorian