I have the following code in Delphi 7 to draw Copyright text along the curved edge of a DVD. We are using an old version of Graphics32.
We are switching to Delphi XE5 with the latest code from Graphics32 and this code no longer compiles; in particular LoadArcCurve and drawingBuffer.RenderFittedText no longer exists as methods.
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}
I have the following code snippet in Delphi XE5 using the latest Graphic32 code and have attempted various other similar methods without success.
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);
All of the examples in the new Graphics32 that I can find appear to draw directly onto a Delphi control canvas while I am required to draw onto a TBitmap32.
How do I render text along an arc in an image/bitmap using Delphi XE5 and the latest version of Graphics32?
Using the pointer to Angus Johnson's work that David Heffernan provided, the following code is the solution to my question.
This code uses units: GR32_Lines, GR32_Text, GR32_Misc as well as others. It also does not protect memory or do any of the other protective processes required for releasable code.
I think that the best way to implement what you describe is to use Angus Johnson's excellent extension to graphics32, GR32_Text.