首页 > 解决方案 > 如何在 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++ 的新手,我真的可以在这方面使用一些帮助......

标签: c++tbitmap

解决方案


DrawTransparent是一个受保护的方法,所以你不能直接调用它,但这应该工作:

// opacity 50 
destination_bitmap->Canvas->Draw(0, 0, source_bitmap->Picture->Graphic, 50);

您可能也需要这样做source_bitmap->Transparent = true;


推荐阅读