Hide Comments
Hide Comments

Using the TSVGDocument class to read SVGs and paint to any TCanvas (VCL and FMX)

Comments (0)

The TSVGDocument class is the base class for parsing a SVG and generating TSVGxxxElement classes to describe the SVG. Use the TSVGDocument class to load an SVG and paint the SVG to a TCanvas.  


The TSVGDocument is only available at run-time.  The TRSSVGDocument (VCL) and TRSFMXSVGDocument (FMX) components expose the TSVGDocument for loading at design-time.  To use the TSVGDocument to load an SVG, perform the following steps:


hmtoggle_plus1Create the TSVGDocument

procedure TForm20.FormCreate(Sender: TObject);
  Doc := TSVGDocument.Create(nil);
  Doc.PreferredLanguage := 'en';



hmtoggle_plus1Draw the TSVGDocument to a TCanvas

The TSVGDocument can be drawn to any TCanvas.  The following code paints to a TPaintBox.Canvas:

procedure TForm20.PaintBox1Paint(Sender: TObject; Canvas: TCanvas);
  StopWatch: TStopWatch;
  StopWatch := TStopwatch.Create;
  Doc.Draw(Canvas, PaintBox1.BoundsRect);
  lblPaintTime.Text := 'Paint Time: '+FloatToStr(StopWatch.Elapsed.TotalMilliseconds);



Comments (0)

RiverSoftAVG SVG Component Library (RSCL) © 2013-2015, Thomas G. Grubb