First of all - the new icons on the toolbars in ArcGIS 9.4 Beta 1 look awesome compared to what was there before. We're currently planning in "upgrading" our own icons, too.
I noticed, that the "old" rule of the color of the upper left pixel being threatened as the transparent color still is in effect - however ESRI seems to have icons where this doesn't apply: For example, all the "Show window" icons (show Pyhton window, search window ...) do have another transparency color set than what's on the upper left pixel (the upper left pixel is part of the "iconized application window"-picture). Can you confirm this?
And how would it be possible to achieve the same result (using the C++ API) - any tricks? Can the toolbars finally treat transparent PNGs?
OK, I've played with this some more. Seems to be no problem to use a alphachannel transparent PNG as a bitmap when doing this in C#/.Net using the BaseCommand... Now I just have to find a way to do this using other developing languages...
Ok, in the meantime I've been trying and investigating some more. The situation is as follows: We have a lot of older custom commands, written in Delphi. To have these commands visually fit the polished ArcGIS 10 look, we would like to support the new possibility of using fully transparency-enabled PNG icons to appear on the ArcMap toolbars. This works very well from C#/.Net, but seems to be a bit more tricky to support from other development environments.
According to some documentation found on arcigs.com, ArcObjects expects the bitmap handle that is supplied in the get-bitmap method to be a handle to a GDI bitmap. To my knowledge, GDI bitmaps do not support transparency (whereas GDI+ would do that). It seems that the command base classes to some magic with the bitmaps (premultipying? based on what colors?).
ESRI people, would it be possible to give a few hints on what you do in the baseclasses? Any other tips or tricks for this? Honestly, I'm not too much into GDI and everything, so maybe I'm just not seeing the obvious solution. And just for clarification: I do not want the key-transparency with one color being transparent or anything. Instead, I would like to support the alpha channel of PNG images (as with all the new ESRI commands).
Thanks for any help. Would be nice if we can discuss and maybe, in the end, have a nice snippet of code that would possibily help other developers, too.
Just to keep you fellow forum readers up to date: We have solved this and are now able to use PNG icons in Delphi ICommands. If anybody needs hints on this, just send me a message or write to this thread.
I would be curious to hear how you solved this problem, I am facing something similar with legacy ICommands
Just a few general hints (or do you work with Delphi?)
* I load the PNG image from the resource file using a ressource stream * Create a new BITMAPV5Header and mask the colors properly (which seems to be the only way to make GDI accept alpha values) * Use CreateDIBSection using the new header * Then a bitwise (or scanline-wise) copy of the pixel data from the previously loaded PNG ressource to the DIB * This results in a bitmap handle that works for ESRI's toolbars...
.. full alpha transparency looks just better 😉 The thing I like about this solution is that it really does the job for 100% working alpha transparency and no nasty premultiplied alpha tricks are needed (which wouldn't properly work with the gradient background of the toolbars anyway).