Skip to content

TSVGGraphic

Unit: SVGIconImage

Inherits from: TGraphic

Description

TSVGGraphic is a TGraphic descendant that enables SVG support in TPicture and other VCL components that use TGraphic. It is automatically registered for the 'SVG' file format.

Published Properties

FileName

pascal
property FileName: TFileName;

Path to SVG file.

Public Properties

Opacity

pascal
property Opacity: Byte;

Opacity level (0-255).

Public Methods

LoadFromFile / LoadFromStream

pascal
procedure LoadFromFile(const Filename: String); override;
procedure LoadFromStream(Stream: TStream); override;

SaveToStream

pascal
procedure SaveToStream(Stream: TStream); override;

Draw

pascal
procedure Draw(ACanvas: TCanvas; const Rect: TRect); override;

AssignSVG

pascal
procedure AssignSVG(SVG: ISVG);

Assigns an SVG interface directly.

Examples

Use with TImage

pascal
var
  SVG: TSVGGraphic;
begin
  SVG := TSVGGraphic.Create;
  try
    SVG.LoadFromFile('icon.svg');
    SVG.Opacity := 200;
    Image1.Picture.Assign(SVG);
  finally
    SVG.Free;
  end;
end;

Load SVG in TPicture

pascal
// SVG files automatically use TSVGGraphic
Image1.Picture.LoadFromFile('icon.svg');

See Also

Released under Apache License, Version 2.0.