我在 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}
我使用最新的 Graphic32 代码在 Delphi XE5 中有以下代码片段,并尝试了各种其他类似的方法,但均未成功。
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 控件画布上,而我需要绘制到 TBitmap32 上。
如何使用 Delphi XE5 和最新版本的 Graphics32 在图像/位图中沿弧线渲染文本?