RAD Studio VCL Reference
|
Copies a portion of a bitmap onto a rectangle on the canvas, replacing one of the colors of the bitmap with the brush of the canvas.
Use BrushCopy to achieve special effects such as making the copied image partially transparent. BrushCopy is provided mainly for backward compatibility. Use a TImageList instead of BrushCopy.
Dest specifies the rectangular portion of the canvas that will receive the copy of the bitmap. Bitmap specifies the graphic to copy from. Source specifies the rectangular area of Bitmap to copy. Color specifies the color in Bitmap to replace with the Brush of the canvas.
To use BrushCopy to make the copied image partially transparent, specify the color of the surface of the canvas (clBackground for example) as the Color of the Brush property, then call BrushCopy.
C++ Examples:
/* 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. */ #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); }
Delphi Examples:
{ 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. } procedure TForm1.Button1Click(Sender: TObject); var Bitmap: TBitmap; MyRect, MyOther: TRect; begin MyRect := Rect(10,10,150,150); MyOther := Rect(10,161,150,301); Bitmap := TBitmap.Create; Bitmap.LoadFromFile( 'c:\Program Files\Common Files\CodeGear Shared\Images\Splash\256color\factory.bmp'); Form1.Canvas.BrushCopy(MyRect, Bitmap, MyRect, clBlack); Form1.Canvas.CopyRect(MyOther,Bitmap.Canvas,MyRect); Bitmap.Free; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|