ImageEn, unit imageenio

TImageEnIO.ImportFromStreamSVG

TImageEnIO.ImportFromStreamSVG


Declaration

function ImportFromStreamSVG(Stream: TStream; Width: Integer = -1; Height: Integer = -1; MaintainAR: Boolean = False): Boolean;


Description

Loads a rasterized image from a stream containing a SVG file.
Width and Height specify the image size (the rectangle where the SVG image will be drawn).
To maintain the image aspect ratio set only one size, assigning -1 to the other, e.g. ImportFromFileSVG( 'axi.svg', -1, 500 ); or set both values and enable MaintainAR.
The result will be false if an error is encountered, e.g. the file in the stream is not SVG format (Aborting will be true).

Note:
 ImportFromStreamSVG requires Delphi 12 or newer. You must add Vcl.Skia to the uses clause (of any of your project units) to support SVG
 For improved SVG load support, use ImageMagick
 This method loads the image as a bitmap (rasterized). It will not be in vector format
 Does not reset the position of the stream, so you may need to first call Stream.Position := 0;


Example

uses
  Vcl.Skia;

// Import an SVG file
if ImageEnView1.IO.ImportFromStreamSVG(fs) = False then
  ShowMessage('Not an SVG file!');