Draw images from svg file with Win2D.
Tokyo railmaps
Thanks to railmaps
Binding content type is SvgDocument
.
<svg:SvgImage Content="{Binding ...}" />
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,
});
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())
{
session.Clear(Colors.Transparent);
renderer.Renderer(width, height, session); // <- rendering svg content
}
- mntone
GitHub: https://github.com/mntone
Twitter: https://twitter.com/mntone (posted in Japanese; however, english is ok)