How to use DrawTransparentBitmap() in C++ Builder

464 views Asked by At

Just trying to figure out how to use DrawTransparent in C++ Builder to draw a bitmap or tbitmap with an alpha channel so that the drawn image is semi-transparent with the background image.

I looked all over the place and on this site but can't find anything other than a note that this as well as DrawTransparentBitmap exists..

In the help it is listed as follows:

virtual void __fastcall DrawTransparent(TCanvas* ACanvas, const 
System::Types::TRect &Rect, System::Byte Opacity);

However there are no code examples. The compiler doesn't recognize the procedure name and it does not appear as a method of tbitmap...

I am still new to C++ and I could really use some help with this...

1

There are 1 answers

1
Ted Lyngmo On BEST ANSWER

DrawTransparent is a protected method so you can't call it directly, but this should work:

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

You may need to do source_bitmap->Transparent = true; too.