如何通过主窗体上的按钮单击填写第二种形式的TImage画布上的文本? 我已经尝试了好几次,但画布仍然是空白的。
我的尝试:
Form2.Image1.Canvas.BeginScene;
Form2.Image1.Canvas.Font.Size:=18;
Form2.Image1.Canvas.Font.Family:='Arial';
Form2.Image1.Canvas.Fill.Color:=claBlack;
Form2.Image1.Canvas.Font.Style:=[TFontStyle.fsbold];
Form2.Image1.Canvas.FillText(TRectF.Create(4,70,70,200),'Hello',true,1,[TFillTextFlag.RightToLeft], TTextAlign.Leading, TTextAlign.Leading);
Form2.Image1.Canvas.EndScene;
答案 0 :(得分:2)
将TImage与firemonkey一起使用,您必须先创建或加载位图才能绘制。
Form2.Image1.Bitmap.Create(Round(Form2.Image1.width),Round(Form2.Image1.height));
With Form2.Image1.Bitmap.Canvas do
begin
BeginScene;
Font.Size:=18;
Font.Family:='Arial';
Fill.Color:=TAlphaColors.Black;
Font.Style:=[TFontStyle.fsbold];
FillText(TRectF.Create(4,70,70,200),'Hello',true,1,[TFillTextFlag.ftRightToLeft], TTextAlign.taLeading,TTextAlign.taCenter);
EndScene;
end;