@xorpas
maybe some like this...
Invalidate informs the form that its entire surface needs to be repainted. Calling Invalidate can prevent flicker caused by a series of partial repaints. There is no performance penalty for calling Invalidate multiple times before the form is actually repainted.
implementation
{$R *.fmx}
var
LImageWidthOriginal, LImageHeightOriginal: single;
LFontSizeScale : single = 1; // init value
procedure TForm1.Button1Click(Sender: TObject);
begin
Image1.Align := TAlignLayout.None;
//
Image1.Size.Width := 200;
Image1.Size.Height := 200;
LFontSizeScale := (Image1.Width * Image1.Height) / (LImageWidthOriginal * LImageHeightOriginal);
//
Invalidate; // re-do form canvas
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Image1.Align := TAlignLayout.None;
//
Image1.Size.Width := 500;
Image1.Size.Height := 600;
LFontSizeScale := (Image1.Width * Image1.Height) / (LImageWidthOriginal * LImageHeightOriginal);
//
Invalidate; // re-do form canvas
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Image1.Align := TAlignLayout.Client;
//
LFontSizeScale := (Image1.Width * Image1.Height) / (LImageWidthOriginal * LImageHeightOriginal);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
// 3º - first run
Image1.WrapMode := TImageWrapMode.Stretch;
LImageWidthOriginal := Image1.Size.Width;
LImageHeightOriginal := Image1.Size.Height;
end;
procedure TForm1.Image1Paint(Sender: TObject; Canvas: TCanvas; const ARect: TRectF);
var
LRectText : TRectF;
LImagePoint: TPointF;
begin
// 4º - first run
LImagePoint := Image1.AbsoluteToLocal(PointF(Image1.Position.x + 10, Image1.Position.Y + 10));
LRectText := TRectF.Create(LImagePoint.x, LImagePoint.Y, Image1.Width, Image1.Height);
//
Canvas.Fill.Color := TAlphaColorRec.Yellow;
Canvas.Font.Size := LFontSizeScale * 20;
Canvas.FillText(LRectText, 'Hello World', false, 1, [], TTextAlign.Leading, TTextAlign.Leading);
end;
procedure TForm1.Image1Resize(Sender: TObject);
begin
// 1 º - first run
end;
procedure TForm1.Image1Resized(Sender: TObject);
begin
// 2 º - first run
end;
end.