TransparentColor (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

An example of TBitmap Color, TGraphic Transparent, TBitmap TransparentMode, TBitmap TransparentColor, and TCanvas Draw


Code

#include <memory>       //For STL auto_ptr class

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  std::auto_ptr<Graphics::TBitmap> bitmap(new Graphics::TBitmap);
  try
  {
	bitmap->LoadFromFile("..\\FACTORY.BMP ");
	bitmap->Transparent = true;
	bitmap->TransparentColor = bitmap->Canvas->Pixels[50][50];
	Form1->Canvas->Draw( 0, 0, bitmap.get());
	bitmap->TransparentMode = tmAuto;
	Form1->Canvas->Draw(50, 50, bitmap.get());
  }
  catch (...)
  {
    ShowMessage("Could not load or display bitmap");
  }
}

Uses