Delphi Firemonkey/FMX – Get TImage to fill out a TRoundRect


Probably pretty simple but I was trying to figure out how to get an Image to fill a TRoundRect in Delphi FMX. I’ve got a roundrect on my form, got an image assigned to it but when I load a rectangle shaped bitmap into the image it displays in its usual width/height ratio so overlays the roundrect which sits underneath it. The relevant bit of my code looks like this:

Rec := TRoundRect.Create(Self);
Rec.Height := 180;
Rec.Width := 250;
Rec.Corners := [TCorner.TopLeft, TCorner.TopRight, TCorner.BottomLeft];

Image := TImage.Create(Self);
Image.Parent := Rec;
Image.Bitmap := TBitmap.Create;
Image.Align := TAlignLayout.Client;
Image.WrapMode := TImageWrapMode.Stretch;
Image.Bitmap := FAllProgrammes[I].Image;


Does anyone have any suggestions/pointers on how I can clip the image to fit and fill out the TRoundRect either through using some property of the parent or the TRoundRect canvas? Cheers

Comments are closed.