Reputation: 1
How to do this on Delphi XE 10.1 with FMX?
I'm trying to insert a small image at a desired location on a large image. https://forums.embarcadero.com/thread.jspa?messageID=867027 I tried using an example in this question. In the first DrawBitmap example If you set the Rect coordinate value to fit the desired coordinate value, the small image will be cut off. The second example does not have a method called Draw in FMX TCanvas. I want to get help. Thank you.
Upvotes: 0
Views: 903
Reputation: 7912
The DrawBitmap method draws scaled bitmap area described by the SrcRect parameter into the canvas area described by the DstRect parameter. So you must have used wrong area rectangles. Try this (it draws 50% scaled bitmap onto the canvas 8 pixels from left and top):
var
Bitmap: TBitmap;
SrcRect: TRectF;
DstRect: TRectF;
begin
Bitmap := TBitmap.CreateFromFile('C:\MyImage.bmp');
try
SrcRect := Bitmap.BoundsF;
DstRect := SrcRect;
DstRect.Width := DstRect.Width / 2;
DstRect.Height := DstRect.Height / 2;
DstRect.Offset(8, 8);
Image1.Bitmap.Canvas.BeginScene;
Image1.Bitmap.Canvas.DrawBitmap(Bitmap, SrcRect, DstRect, 100);
Image1.Bitmap.Canvas.EndScene;
finally
Bitmap.Free;
end;
end;
Upvotes: 3