Delphi 在firemonkey中绘制文本

Delphi 在firemonkey中绘制文本,delphi,firemonkey,delphi-xe3,Delphi,Firemonkey,Delphi Xe3,如何在firemonkey应用程序中绘制位图高质量文本 我的表格中有一个名为imgStoryname的TImage 我试过这个代码,但它不起作用,imgStory仍然显示空白 imgStory.Canvas.Stroke.Kind := TBrushKind.bkSolid; imgStory.Canvas.StrokeThickness := 1; imgStory.Canvas.Fill.Color := TAlphaColors.Red; mRect.Create(100, 229, 30

如何在firemonkey应用程序中绘制位图高质量文本

我的表格中有一个名为
imgStory
name的
TImage

我试过这个代码,但它不起作用,imgStory仍然显示空白

imgStory.Canvas.Stroke.Kind := TBrushKind.bkSolid;
imgStory.Canvas.StrokeThickness := 1;
imgStory.Canvas.Fill.Color := TAlphaColors.Red;
mRect.Create(100, 229, 300, 250);
imgStory.Canvas.FillText(mRect, 'Hello Text!', false, 100, [TFillTextFlag.ftRightToLeft],
TTextAlign.taCenter, TTextAlign.taCenter);

在画布上而不是在绘制方法中绘制时,需要使用beginscene和endscene包围绘制命令

因此,在代码前添加一行:

imgStory.canvas.beginscene;
imgStory.canvas.endscene;
在您的代码之后:

imgStory.canvas.beginscene;
imgStory.canvas.endscene;

在画布上而不是在绘制方法中绘制时,需要使用beginscene和endscene包围绘制命令

因此,在代码前添加一行:

imgStory.canvas.beginscene;
imgStory.canvas.endscene;
在您的代码之后:

imgStory.canvas.beginscene;
imgStory.canvas.endscene;

因此,这是一个需要先加载或创建位图,然后在位图上绘制的时间段。在图形命令周围还需要beginscene和endscene。要从文件创建位图,请执行以下操作:

imgstory.bitmap.createfromfile(filename);
或者您可以创建一个空白的:

imgstory.bitmap.create(width,height);
然后,图形变为:

imgstory.Bitmap.canvas.BeginScene();
imgStory.Bitmap.canvas.Stroke.Kind := TBrushKind.bkSolid;
imgStory.Bitmap.canvas.StrokeThickness := 1;
imgStory.bitmap.Canvas.Fill.Color := TAlphaColors.Red;
mRect.Create(100, 229, 300, 250);
imgStory.bitmap.Canvas.FillText(mRect, 'Hello Text!', false, 100, [TFillTextFlag.ftRightToLeft],
TTextAlign.taCenter, TTextAlign.taCenter);
imgstory.bitmap.Canvas.endscene

因此,这是一个需要先加载或创建位图,然后在位图上绘制的时间段。在图形命令周围还需要beginscene和endscene。要从文件创建位图,请执行以下操作:

imgstory.bitmap.createfromfile(filename);
或者您可以创建一个空白的:

imgstory.bitmap.create(width,height);
然后,图形变为:

imgstory.Bitmap.canvas.BeginScene();
imgStory.Bitmap.canvas.Stroke.Kind := TBrushKind.bkSolid;
imgStory.Bitmap.canvas.StrokeThickness := 1;
imgStory.bitmap.Canvas.Fill.Color := TAlphaColors.Red;
mRect.Create(100, 229, 300, 250);
imgStory.bitmap.Canvas.FillText(mRect, 'Hello Text!', false, 100, [TFillTextFlag.ftRightToLeft],
TTextAlign.taCenter, TTextAlign.taCenter);
imgstory.bitmap.Canvas.endscene

我知道这是一个古老的问题,但我遇到了它,并让它在我这边工作。这是我的密码。我想可能是你设置mrect的方式。我不认为只调用.create()函数而不将输出设置为变量就行了

Image1.Bitmap.canvas.Stroke.Kind := TBrushKind.bkSolid;
Image1.Bitmap.canvas.StrokeThickness := 1;
Image1.bitmap.Canvas.Fill.Color := TAlphaColors.Red;
Image1.Bitmap.Canvas.Font.Size:=36;
Image1.Bitmap.Canvas.Font.Family:='Arial';
Image1.Bitmap.Canvas.Font.Style:=[TFontStyle.fsbold];
ARect := TRectF.Create(100, 229, 400, 270);
Image1.Bitmap.Canvas.BeginScene;
Image1.Bitmap.Canvas.FillText(ARect, 'Hello Text!', false, 100, [], TTextAlign.taCenter);
Image1.Bitmap.Canvas.EndScene;

我知道这是一个古老的问题,但我遇到了它,并让它在我这边工作。这是我的密码。我想可能是你设置mrect的方式。我不认为只调用.create()函数而不将输出设置为变量就行了

Image1.Bitmap.canvas.Stroke.Kind := TBrushKind.bkSolid;
Image1.Bitmap.canvas.StrokeThickness := 1;
Image1.bitmap.Canvas.Fill.Color := TAlphaColors.Red;
Image1.Bitmap.Canvas.Font.Size:=36;
Image1.Bitmap.Canvas.Font.Family:='Arial';
Image1.Bitmap.Canvas.Font.Style:=[TFontStyle.fsbold];
ARect := TRectF.Create(100, 229, 400, 270);
Image1.Bitmap.Canvas.BeginScene;
Image1.Bitmap.Canvas.FillText(ARect, 'Hello Text!', false, 100, [], TTextAlign.taCenter);
Image1.Bitmap.Canvas.EndScene;

fmx中的高质量文本?fmx并不是以……而闻名……但当我使用我的语言(波斯语)时,字符显示质量很差!!是的,fmx因其劣质文本而广为人知,fmx中的高质量文本?fmx并不是以……而闻名……但当我使用我的语言(波斯语)时,字符显示质量很差!!是的,fmx因其劣质文本而广为人知抱歉,遗漏了关于它是图像而不是位图的一点。您需要将图像加载到图像中或创建一个空白图像。然后在imgstory.bitmap.canvas上绘制。我将发布一个新的答案,因为我不知道如何格式化这个评论中的代码。对不起,错过了关于它是一个图像而不是位图的部分。您需要将图像加载到图像中或创建一个空白图像。然后在imgstory.bitmap.canvas上绘制。将发布一个新答案,因为我无法确定如何格式化此注释中的代码。FillText不使用笔划属性。它只使用画布的填充属性。而且生成的文本充其量看起来很暗淡。FillText不使用笔划属性。它只使用画布的填充属性。而由此产生的文本充其量也显得黯淡。