Declaration
function ImportFromFileSVG(const FileName: WideString; Width: Integer = -1; Height: Integer = -1; MaintainAR: Boolean = False): Boolean;
Description
Loads a rasterized image from an SVG file.
FileName is the file name and must include a .SVG extension.
With Skia and
ImageMagick you can specify the import size (not with native SVF support).
Set
Width and
Height to the desired image size (the rectangle where the SVG image will be drawn). If -1 is specified for both, the original image size is used.
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.
Result will be false if the file is not SVG format (and
Aborting will be true). Loading errors due to a file not being available will raise an exception.
Note:
◼This method loads the image as a bitmap (rasterized). It will not be in vector format. To load as SVG as
vector layers, use
LayersImport
◼Improved SVG rasterized rendering is available with Delphi 12 or newer using Skia. You must add Vcl.Skia to the uses clause (of any of your project units) and enable Skia for your project
◼For improved SVG load support, use
ImageMagick
◼SVG loading options are specified by
SVGParams
◼You can abort loading by setting
Aborting to true
◼If
NativePixelFormat = True, the image will be returned in ie32RGB format with alpha in the
A channel
uses
Vcl.Skia;
// Import SVG image 'alfa.wmf', resizing to 500xHHH (HHH is auto-calculated)
ImageEnView1.IO.ImportFromFileSVG( 'C:\alfa.svg', 500, -1, true, clWhite );
// Import at default size
ImageEnView1.IO.ImportFromFileSVG( 'C:\input.svg' );
// Import at size of display control, but maintaing aspect ratio
ImageEnView1.IO.ImportFromFileSVG( 'C:\input.svg', ImageEnView1.ClientWidth, ImageEnView1.ClientHeight, True );
See Also
◼ImportFromStreamSVG
◼AsSVG
◼SVG Implementation Status