//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "TransparentColor.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: TransparentColor
// Property: Graphics.TBitmap.Canvas
// Method: Graphics.TGraphic.Transparent
// Method: Graphics.TBitmap.TransparentMode
// Property: Graphics.TBitmap.TransparentColor
// Method: Graphics.TCanvas.Draw

// Warning: Nothing is transparent!

// BeginCode
/*
An examples of TBitmap Color, TGraphic Transparent, TBitmap
TransparentMode, TBitmap TransparentColor and TCanvas Draw.
*/

#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");
  }
}
// EndCode
// EndExample: TransparentColor
//---------------------------------------------------------------------------
