The shortest path through the core library is:
SKSvg.SKPicture directly or export it.using SkiaSharp;
using Svg.Skia;
var svg = new SKSvg();
svg.Load("image.svg");
SKCanvas canvas = ...;
canvas.DrawPicture(svg.Picture);
using SkiaSharp;
using Svg.Skia;
using var svg = new SKSvg();
if (svg.Load("image.svg") is { })
{
svg.Save("image.png", SKEncodedImageFormat.Png, 100, 1f, 1f);
}
You can also export the picture directly:
using System.IO;
using SkiaSharp;
using Svg.Skia;
using var svg = new SKSvg();
if (svg.Load("image.svg") is { })
{
using var stream = File.OpenWrite("image.png");
svg.Picture!.ToImage(
stream,
SKColors.Transparent,
SKEncodedImageFormat.Png,
100,
1f,
1f,
SKImageInfo.PlatformColorType,
SKAlphaType.Unpremul,
svg.Settings.Srgb);
}
using SkiaSharp;
using Svg.Skia;
using var svg = new SKSvg();
if (svg.Load("image.svg") is { })
{
svg.Picture!.ToPdf("image.pdf", SKColors.Empty, 1f, 1f);
svg.Picture!.ToXps("image.xps", SKColors.Empty, 1f, 1f);
}
using Svg.Skia;
const string markup = "<svg width=\"16\" height=\"16\"><rect width=\"16\" height=\"16\" fill=\"red\" /></svg>";
using var svg = new SKSvg();
svg.FromSvg(markup);
SKSvg.Load(path) auto-detects Android VectorDrawable XML when the file content matches that format. You can also opt into the dedicated API explicitly:
using Svg.Skia;
using var svg = new SKSvg();
if (svg.LoadVectorDrawable("icon.xml") is { })
{
svg.Save("icon.png", SkiaSharp.SKColors.Transparent);
}