gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 23:26:07 24 4
gpt4 key购买 nike

我在 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com