SvgImage

SvgImage constructor (1 of 4)

Instantiates a new object of the SvgImage class, utilizing the specified path to locate and load the image. This constructor facilitates the creation of SVG image instances from external files, enabling seamless integration into software systems and workflows.

public SvgImage(string path)
ParameterTypeDescription
pathStringThe path to load image from and initialize pixel and palette data with.

Exceptions

exceptioncondition
ArgumentNullExceptionpath is null.

See Also


SvgImage constructor (2 of 4)

Creates a new instance of the SvgImage class, loading the image from the provided stream. This constructor enables the direct loading of SVG images from streams, enhancing flexibility and efficiency in handling image resources within software applications.

public SvgImage(Stream stream)
ParameterTypeDescription
streamStreamThe stream to load image from and initialize pixel and palette data with.

Exceptions

exceptioncondition
ArgumentNullExceptionstream is null.

Examples

This example shows how to load an SVG image from a file stream and rasterize it to PNG.

[C#]

string dir = "c:\\temp\\";

// Load an SVG image from a file stream.
using (System.IO.Stream stream = System.IO.File.OpenRead(dir + "test.svg"))
using (Aspose.Imaging.FileFormats.Svg.SvgImage svgImage = new Aspose.Imaging.FileFormats.Svg.SvgImage(stream))
{
    // In order to rasterize SVG we need to specify rasterization options.
    Aspose.Imaging.ImageOptions.SvgRasterizationOptions rasterizationOptions = new Aspose.Imaging.ImageOptions.SvgRasterizationOptions();
    Aspose.Imaging.ImageOptions.PngOptions saveOptions = new Aspose.Imaging.ImageOptions.PngOptions();
    saveOptions.VectorRasterizationOptions = rasterizationOptions;

    svgImage.Save(dir + "test.output.png", saveOptions);
}

See Also


SvgImage constructor (3 of 4)

Instantiates a new SvgImage object with the specified width and height. This constructor allows developers to create SVG images with predefined dimensions, facilitating precise control over the image’s size during initialization.

public SvgImage(int width, int height)
ParameterTypeDescription
widthInt32The image width.
heightInt32The image height.

See Also


SvgImage constructor (4 of 4)

Creates a new instance of the SvgImage class with specified SVG options, image width, and height parameters. This constructor enables developers to initialize SVG images with custom options and dimensions, providing flexibility in managing SVG content and layout.

public SvgImage(SvgOptions svgOptions, int width, int height)
ParameterTypeDescription
svgOptionsSvgOptionsThe SVG options.
widthInt32Image width.
heightInt32Image height.

See Also