Here is a simple example of how to fill a given shape (TRectangle, TRoundRect, TEllipse etc) with the bitmap which belongs to an image. In this example i have created a new project, dropped a button and an RoundRect onto the form. On the Button Click i have the following code:
procedure TForm1.Button1Click(Sender: TObject);
var
Image: TImage;
begin
Image := TImage.Create(self);
Image.Bitmap.LoadFromFile('C:\Temp\Test.jpg');
RoundRect1.Fill.Kind := TbrushKind.Bitmap;
RoundRect1.Fill.Bitmap.WrapMode := TWrapMode.TileStretch;
RoundRect1.Fill.Bitmap.Bitmap := Image.Bitmap;
end;
This will create a new instance of a TImage. Load my Test.jpg file into its Bitmap property. Then set the Image to fill the space in the RoundRect.
Thanks!
ReplyDelete