Visual Studio 2010 - C++具有 Ribbon UI 的 MFC 应用程序 - 位图中的透明度
我正在使用 Visual C++ 2010 中的一个小型 MFC 向导生成的应用程序,我刚刚决定将自己的位图放入资源中,以替换功能区 UI 应用程序按钮中显示的三立方体 MFC 位图,即“大理石”。
原始版本似乎使用黑色 (0,0,0) 作为透明度颜色,但我无法确定 Visual Studio 2010 中的 MFC 功能区(mfc-feature-pack stuff)内容如何确定用作位图的透明度功能区的主图标。
功能区 (IDR_RIBBON) 的属性显示 Image=IDB_MAIN,IDB_MAIN 是 BMP 格式的 32x32 位图,从名为 main.bmp 的磁盘文件加载。
该项目中的一些位图资源具有我所期望的内容:变得透明的洋红色,但 MFC 主位图没有使用此配色方案或调色板。
这是实际结果的示例,我希望这表明结果不是我想要的:
顺便说一句,似乎不可能在应用程序按钮中使用 ICON 资源,所以我有点困惑如何他们实现了其中的透明度。
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:
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要创建一个具有 Alpha 通道以实现透明度的 32 位位图。我完成此操作的方法不是很简单,但这是我能想到的唯一方法。
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.
也许是半透明的PNG?您知道 BMP 文件也可以有 Alpha 通道吗?
Translucent PNG, perhaps? Did you know that BMP files can also have alpha channels?