delphi - 如何沿着图像中的弧线渲染文本?

标签 delphi delphi-xe5 graphics32

我在 Delphi 7 中有以下代码,用于沿 DVD 的弯曲边缘绘制版权文本。我们正在使用旧版本的 Graphics32。

我们正在使用 Graphics32 的最新代码切换到 Delphi XE5,并且该代码不再编译;特别是 LoadArcCurve 和 DrawingBuffer.RenderFittedText 不再作为方法存在。

procedure TCDLabel.DrawCopyrightText(const drawingBuffer: TBitmap32Ex);
var
  FixedPointArray : TArrayOfFixedPoint;
  Center : TFixedPoint;
  vAngle1 : double;
  vAngle2 : double;
  radius : integer;
  CopyrightText : string;
  textColor : TColor32;
begin
  radius := (fImageSize div 2) - 30;
  UpdateTextTransform(8{2.3}, drawingBuffer);
  Center.x := GR32.Fixed(fImageSize div 2);
  Center.y := GR32.Fixed(fImageSize div 2);
  vAngle1 := DegToRad(-130);
  textColor := clWhite32;
  vAngle2 := DegToRad(0);
  LoadArcCurve(Center, GR32.Fixed(radius), GR32.Fixed(radius), vAngle1, vAngle2, FixedPointArray);
  CopyrightText := Format('%s %s Dystopia Unlimited. All rights reserved.', [GetCopyrightSymbol, fCopyrightYears]);
  drawingBuffer.RenderFittedText(CopyrightText, textColor, pdoAntialising or pdoFilling, FixedPointArray);
  FixedPointArray := NIL;
end; {DrawCopyrightText}

我在 Delphi XE5 中使用最新的 Graphic32 代码有以下代码片段,并尝试了各种其他类似的方法,但没有成功。

canvas := TCanvas32.Create(drawingBuffer); // drawingBuffer is a TBitmap32
try
  canvas.Brushes.Add(TStrokeBrush);
  canvas.Brushes[0].Visible := TRUE;
  (canvas.Brushes[0] as TStrokeBrush).StrokeWidth := 2;
  (canvas.Brushes[0] as TStrokeBrush).FillColor := clWhite32;

  canvas.Path.BeginPath;
  canvas.Path.Arc(Center, -130, 0, radius);
  canvas.Path.EndPath;
  TextToPath(drawingBuffer.Font.Handle, canvas.Path, FloatRect(0, 0, fImageSize, fImageSize), CopyrightText);

我能找到的新 Graphics32 中的所有示例似乎都直接绘制到 Delphi 控件 Canvas 上,而我需要绘制到 TBitmap32 上。

如何使用 Delphi XE5 和最新版本的 Graphics32 在图像/位图中沿着弧线渲染文本?

最佳答案

我认为实现您所描述的内容的最佳方法是使用 Angus Johnson 对图形32 的出色扩展,GR32_Text .

关于delphi - 如何沿着图像中的弧线渲染文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25913550/

相关文章:

c++ - 需要帮助将 Graphics32 Delphi 示例转换为 C++

delphi - Graphics32 用阴影图案填充多边形

delphi - 在 OpenGL 渲染上下文之上叠加图形

C# 等效于 Delphi 的 .INI 读取方法

string - 将 String 变成只有 1 行

delphi - TModel3D 的 OnClick 事件

delphi - 我正在寻找Delphi Firemonkey的拖放示例

delphi - 将 HTML 帮助作为单独的进程启动

delphi - UTC 支持比较 2 个文件的日期/时间

适用于高 DPI Windows 的 Delphi Firemonkey Scale