c++ - 如何在 C++ Builder 中使用 DrawTransparentBitmap()
问题描述
只是想弄清楚如何在 C++ Builder 中使用 DrawTransparent 来绘制带有 alpha 通道的位图或 tbitmap,以便绘制的图像与背景图像是半透明的。
我在这个地方和这个网站上到处找,但除了这个和 DrawTransparentBitmap 都存在的注释之外找不到任何东西。
在帮助中列出如下:
virtual void __fastcall DrawTransparent(TCanvas* ACanvas, const
System::Types::TRect &Rect, System::Byte Opacity);
但是没有代码示例。编译器无法识别过程名称,并且它不会作为 tbitmap 的方法出现...
我还是 C++ 的新手,我真的可以在这方面使用一些帮助......
解决方案
DrawTransparent
是一个受保护的方法,所以你不能直接调用它,但这应该工作:
// opacity 50
destination_bitmap->Canvas->Draw(0, 0, source_bitmap->Picture->Graphic, 50);
您可能也需要这样做source_bitmap->Transparent = true;
。
推荐阅读
- c++ - 为什么我不能将 =default 用于具有成员初始值设定项列表的默认 ctor
- python - 如何在python中解码二进制图像字符串
- javascript - NextJS 导航到同一页面和不同的查询不会触发钩子
- azure - Azure 数据目录允许任何用户注册对象
- ldap - LDAP 查询 OU 中的用户
- scala - 过滤具有大于和小于日期列表的火花数据框
- vue.js - 如何修复 axios 中的“TypeError:name.toUpperCase 不是函数”
- asp.net-core - 使用包含花时间加载性能问题
- python - 全局变量不会改变
- c# - C# 通过引用分配属性