本文介绍了如何为CMFCToolBar应用蒙版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CMFCToolBar中加载24位图像。工具栏图像具有白色背景。显示工具栏时,图像不透明。

I am loading 24 bit images in CMFCToolBar. The toolbar images are having white background.When displaying the toolbar, the  images are not transparent.

如何告诉工具栏识别蒙版?

How to tell the toolbar to recognize the mask?

提前致谢。

推荐答案

感谢您在此发帖。

1。要添加如下所示的其他样式:TBSTYLE_TRANSPARENT

1. To add additional style like this: TBSTYLE_TRANSPARENT

您可以使用 CMFCToolBar :: CreateEx方法代替 CMFCToolBar :: Create

You can use the CMFCToolBar::CreateEx method instead of the CMFCToolBar::Create when you want to provide specific styles.

有关详细信息,请参阅该文档。

For more information, please reference the document.

2。您可以尝试使用RGB(0xF0,0xF0,0xF0)作为每像素24位位图的背景颜色。这是按钮的默认系统背景颜色。 此颜色的像素在工具栏中将是透明的。

2. you can try to use the RGB(0xF0, 0xF0, 0xF0) as the background color in a 24 bits per pixels bitmap. This is default system background color for buttons. Pixels of this color will be transparent in the toolbar.

您还可以使用每像素32位PNG文件。 PNG文件具有真正的alpha(透明度)通道,因此您可以在自己喜欢的图像编辑器中查看所获得的内容。在PNG资源部分中添加PNG文件,而不是BITMAP部分。资源中PNG文件
的ID必须与工具栏ID相同。

You also can use 32 bits per pixel PNG file. PNG files have a real alpha (transparency) channel, so you can see what you will get in your favorite image editor. Add the PNG file in the PNG resource section, not the BITMAP section. The ID of the PNG file in the resources must be the same as the toolbar ID.

最好的问候,

Hart


这篇关于如何为CMFCToolBar应用蒙版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 17:48