Visual Studio 2010 - C++具有 Ribbon UI 的 MFC 应用程序 - 位图中的透明度

发布于 2024-09-25 14:23:25 字数 535 浏览 2 评论 0原文

我正在使用 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 主位图没有使用此配色方案或调色板。

这是实际结果的示例,我希望这表明结果不是我想要的: alt text

顺便说一句,似乎不可能在应用程序按钮中使用 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:
alt text

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

GRAY°灰色天空 2024-10-02 14:23:25

您需要创建一个具有 Alpha 通道以实现透明度的 32 位位图。我完成此操作的方法不是很简单,但这是我能想到的唯一方法。

  • 使用 Paint.Net 将源图像转换为保留透明度的 PNG。不幸的是Paint.Net不支持直接创建32位位图。
  • 然后下载AlphaConv,它可以从PNG文件创建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.

  • Use Paint.Net to convert your source image into a PNG that preserves the transparency. Unfortunately Paint.Net does not support creating 32-bit bitmaps directly.
  • Then download AlphaConv which can create the 32-bit bitmap from the PNG file.
春夜浅 2024-10-02 14:23:25

也许是半透明的PNG?您知道 BMP 文件也可以有 Alpha 通道吗?

Translucent PNG, perhaps? Did you know that BMP files can also have alpha channels?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文