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 » Alpha bitmap on a CExtLabel Collapse All
Subject Author Date
Suhai Gyorgy Sep 4, 2007 - 8:29 AM

Dear Support,

On our CExtResizableDialog we need to show a 32-bit bitmap, but it has a ragged edge (around each side of it some pixels are more or less transparent). I tried to use your CExtLabel, using SS_BITMAP style and SetBitmap method. The problem is that the same color is used where the pixels are transparent. I see in your CExtLabel source that the gradient background is not drawn when the SS_BITMAP style is used, in this case you just call Default().

I’ve solved the problem by deriving a class from CExtLabel. In this class I have a CExtBitmap and I load my bitmap in it. I overriden OnPaint, call CExtLabel::DoPaint in it and then AlphaBlend on the CExtBitmap. But I don’t really like this solution, having to do all the painting in my code.

Is there any other solution you could suggest?
Thank you very much!
Chris

Technical Support Sep 4, 2007 - 12:59 PM

We could implement the same code in the CExtLabel class, but it would not draw 32-bit bitmaps with alpha channel correctly on all the Windows OS versions. Old Windows OS versions do not load such bitmaps correctly. The universal solution is to create a new CExtLabel-derived class and specify a CExtBitmap property in it. This CExtBitmap object should be loaded through the CExtBitmap APIs only. This will be approximately the same as you did.

Suhai Gyorgy Sep 5, 2007 - 1:34 AM

Could you please provide this mentioned CExtLabel-derived class? I’d like to check if there’s any code in it which would improve my version. The bitmap is loaded from resource.

Thank you again for your continuous help!

Technical Support Sep 5, 2007 - 9:42 AM

We have just added the functionality you requested. Please download the updated code from our ftp server. The CExtLabel class now supports a custom bitmap. The bitmap can be aligned, tiled, or stretched using the
CExtLabel::SetImageMode() method. The bitmap is based on CExtBitmap so you can use 32-bit bitmaps with alpha channel.Here are the methods that were added to CExtLabel:

	GetBitmapEx()
	SetBitmapEx() 
	GetImageMode() 
	SetImageMode()