BrushCopy (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following code illustrates the differences between CopyRect and BrushCopy. The bitmap graphic FACTORY.BMP is loaded into Bitmap and displayed on the Canvas of Form1. BrushCopy replaces the color black in the graphic with the brush of the canvas, while CopyRect leaves the colors intact.

Code

#include <memory>       // For STL auto_ptr class

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  TRect MyRect = Rect(10,10,100,100);
  TRect MyOther = Rect(10,111,100,201);
  std::auto_ptr<Graphics::TBitmap> Bitmap(new Graphics::TBitmap);
  Bitmap->LoadFromFile("c:/Program Files/Common Files/CodeGear Shared/Images/Splash/256color/factory.bmp");
  Form1->Canvas->BrushCopy(MyRect, Bitmap.get(), MyRect, clBlack);
  Form1->Canvas->CopyRect(MyOther, Bitmap->Canvas, MyRect);
}

Uses

Personal tools
Assistance