RAD Studio VCL Reference
|
Specifies an external bitmap image that defines a pattern for the brush.
property Bitmap: TBitmap;
__property TBitmap Bitmap;
Bitmap points to a TBitmap object that holds a bitmap image. If Bitmap is nonempty, the bitmap image (rather than the Style property) defines the brush's pattern. If the image is larger than eight pixels by eight pixels, only the top left eight-by-eight region is used.
Changing the image does not affect the brush until the TBitmap is reassigned to the Bitmap property. Be sure to free the TBitmap after finishing with the brush, since TBrush will not free it.
C++ Examples:
/* The following code loads a bitmap from a file and assigns it to the Brush of the Canvas of Form1: */ #include <memory> //for STL auto_ptr class void __fastcall TForm1::Button1Click(TObject *Sender) { std::auto_ptr<Graphics::TBitmap> BrushBmp(new Graphics::TBitmap); BrushBmp->LoadFromFile("../bm1.BMP"); Form1->Canvas->Brush->Bitmap = BrushBmp.get(); Form1->Canvas->FillRect(Rect(0,0,100,100)); Form1->Canvas->Brush->Bitmap = NULL; }
Delphi Examples:
{ The following code loads a bitmap from a file and assigns it to the Brush of the Canvas of Form1: } var Bitmap: TBitmap; procedure TForm1.Button1Click(Sender: TObject); begin Bitmap := TBitmap.Create; try Bitmap.LoadFromFile('bm1.BMP'); Form1.Canvas.Brush.Bitmap := Bitmap; Form1.Canvas.FillRect(Rect(0,0,100,100)); finally Form1.Canvas.Brush.Bitmap := nil; Bitmap.Free; end; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|