Draw image from svg file with Win2D
C# PowerShell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


Svg for Xaml Library

NuGet Downloads License

Draw images from svg file with Win2D.

app screenshot

Tokyo railmaps

app screenshot

Thanks to railmaps



xaml with binding

Binding content type is SvgDocument.

<svg:SvgImage Content="{Binding ...}" />

Renderer a raster image from svg image

var svg = SvgDocument.Parse(...);
var uri = new Uri("ms-appdata:///local/filename.jpg");
var file = await StorageFile.GetFileFromApplicationUriAsync(uri);
await SvgImageRenderer.RendererImageAsync(file, new SvgImageRendererSettings()
	Document = svg,
	Format = SvgImageRendererFileFormat.Jpeg,
	Scaling = 10.0F,
	Quality = 0.8F,

Rendering in Win2D ecosystem

var svg = SvgDocument.Parse(...);

var width = 24.0F;
var height = 24.0F;
var scaling = 3.0F;
var device = CanvasDevice.GetSharedDevice();
using (var offScreen = new CanvasRenderTarget(device, width, height, scaling * 96.0F))
using (var renderer = new Win2dRenderer(offScreen, svg))
using (var session = offScreen.CreateDrawingSession())
	renderer.Renderer(width, height, session); // <- rendering svg content


If you build your app for Windows 10 Aniversary Update or later, you should use SVG API on Direct2D.


MIT License