Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Is CExtBitmap::AlphaBlend what I need? Collapse All
Subject Author Date
Mark Walsen Sep 1, 2006 - 10:37 AM

I’m using BITMAP resources, CExtBitmap::LoadBMP_Resource, and CExtCmdManager::CmdSetIcon to load bitmap buttons that have transparency. Because bitmaps don’t have degrees of transparency, it is impossible to design a button image that has edges which blend well through the transparency to the background. You end up with jaggies if you don’t anti-alias the edges. Or, if you do anti-alias the edges, the edge pixels are frozen in color shades that might not match the background color of the button. The button’s background color, showing through the transparency, varies according to the Prof-UIS color scheme chosen by the end-user.

I’m wondering if the CExtBitmap::AlphaBlend member function would help me solve this problem. I don’t have any experience with alpha channels, but I’m hoping that I can use a second bitmap that defines the degrees of transparencies, 0 to 255, for the three R, G, and B of RGBs in the first bitmap. Is that what AlphaBlend is about? If so, could you demonstrate how to use it?

Cheers
-- Mark Walsen

Technical Support Sep 3, 2006 - 12:58 PM

The CExtBitmap class supports 32-bit BMP files with alpha channel and the CExtBitmap::AlphaBlend() method paints any such a bitmap on any Windows OS. Although it completely meets your requirements, there are two problems with 32-bit high quality bitmap images:

1) You should spend some time for painting these images or have them created for you.
2) Many applications destroy and/or corrupt (or simply ignore) alpha channel in BMP files. For instance, the Adobe Photoshop does not save alpha channel into exported BMP files.You have to save your image as PNG and then convert it to BMP using some other tool like Axialis Icon Workshop. Alternatively, you can load PNG images using the CExtSkinBitmap class provided with the ProfSkin library. The later comes with Prof-UIS.

The ..\Prof-UIS\Samples\FunnyBars\Res.IDR_TOOLBAR_VISTA_ICONS.bmp file is a 32-bit BMP file with alpha channel. It is not displayed correctly by the Windows shell viewer nor by the MSPaint bitmap editor nor by built in bitmap editor of any Visual Studio. This bitmap is used in the CMainFrame::m_wndToolBarVista toolbar window of the FunnyBars sample and there are no some special steps that create the toolbar there. This toolbar is initialized by using the ordinary Create() and LoadToolBar() methods.

You can initialize any CExtCmdIcon object with 32-bit bitmap with alpha channel. Simply load this bitmap into the CExtCmdIcon::m_bmpNormal property. The initialized icon object can be assigned to the command description in the command manager and you will see it both in toolbars and menus.

Mark Walsen Sep 4, 2006 - 2:08 PM

Thanks for the above help! I’d like to follow your suggestion to use CExtSkinBitmap::LoadPNG_Resource. I successfully experimented with this by using Axialis Icon Workshop to save your ..\Prof-UIS\Samples\FunnyBars\Res.IDR_TOOLBAR_VISTA_ICONS.bmp as a .PNG file, which I then included as the resource called by LoadPNG_Resource.

However, I cannot determine how to save a PNG file in Photoshop that reserves the alpha channel. In Photoshop I use Image / Mode = RGB with 8-Bit Channel. The Photoshop source file includes an Alpha 1 channel for the semi-transparency. Yet, when I save this image as a PNG, the alpha channel is discarded. If I open this PNG file in Axialis Icon Workshop, it is reported as a 24 BPP (bits per pixel) rather than a 32 BPP (with Alpha Channel).

Can you offer me a tip on how to correctly save the PNG file in Photoshop so that the Alpha Channel isn’t lost?

Cheers
-- Mark

Mark Walsen Sep 4, 2006 - 10:26 PM

I found an excellent answer to my Photoshop question at Axialis’s web site:
http://www.axialis.com/tutorials/tutorial-misc001.html

So, there’s no need for you to answer my above question.

Cheers
-- Mark

Mark Walsen Sep 4, 2006 - 2:15 PM

P.S. Do you know of any icon/button artists who would be interested in redoing the 20 toolbar buttons as PNGs with alpha channel in my soon-to-be-released Notation Composer 2.0?

A screen shot of the current buttons can be seen at http://notation.com/WhatsNew.htm.

Cheers
-- Mark

Technical Support Sep 5, 2006 - 11:56 AM

Actually we would help you with this if we could but we cannot. There should be somebody who is a good artist and has some expertise in creating icons.