private static void RendererImage(Stream stream, SvgImageRendererSettings settings) { var svg = settings.Document; var viewPort = svg.RootElement.ViewPort; if (!viewPort.HasValue) { throw new ArgumentException(nameof(settings)); } var width = viewPort.Value.Width; var height = viewPort.Value.Height; var device = CanvasDevice.GetSharedDevice(); using (var offScreen = new CanvasRenderTarget(device, width, height, settings.Scaling * 96.0F)) { using (var renderer = new Win2dRenderer(offScreen, svg)) using (var session = offScreen.CreateDrawingSession()) { session.Clear(Colors.Transparent); renderer.Render(width, height, session); } offScreen.SaveAsync(stream.AsRandomAccessStream(), (CanvasBitmapFileFormat)settings.Format, settings.Quality).AsTask().GetAwaiter().GetResult(); } }
public static Task RendererImageAsync(StorageFile file, SvgImageRendererSettings settings, CancellationToken token) { return ThreadPool.RunAsync(_ => { using (var stream = file.OpenStreamForWriteAsync().GetAwaiter().GetResult()) { RendererImage(stream, settings); } }).AsTask(token); }
public static Task RendererImageAsync(StorageFile file, SvgImageRendererSettings settings, CancellationToken token) { return(ThreadPool.RunAsync(_ => { using (var stream = file.OpenStreamForWriteAsync().GetAwaiter().GetResult()) { RendererImage(stream, settings); } }).AsTask(token)); }
private static void RendererImage(Stream stream, SvgImageRendererSettings settings) { var svg = settings.Document; var viewPort = svg.RootElement.ViewPort; if (!viewPort.HasValue) throw new ArgumentException(nameof(settings)); var width = viewPort.Value.Width; var height = viewPort.Value.Height; var device = CanvasDevice.GetSharedDevice(); using (var offScreen = new CanvasRenderTarget(device, width, height, settings.Scaling * 96.0F)) { using (var renderer = new Win2dRenderer(offScreen, svg)) using (var session = offScreen.CreateDrawingSession()) { session.Clear(Colors.Transparent); renderer.Render(width, height, session); } offScreen.SaveAsync(stream.AsRandomAccessStream(), (CanvasBitmapFileFormat)settings.Format, settings.Quality).AsTask().GetAwaiter().GetResult(); } }
public static Task RendererImageAsync(Stream stream, SvgImageRendererSettings settings, CancellationToken token) { return ThreadPool.RunAsync(_ => RendererImage(stream, settings)).AsTask(token); }
public static Task RendererImageAsync(Stream stream, SvgImageRendererSettings settings) { return ThreadPool.RunAsync(_ => RendererImage(stream, settings)).AsTask(); }
public static Task RendererImageAsync(StorageFile file, SvgImageRendererSettings settings) => RendererImageAsync(file, settings, CancellationToken.None);
public static Task RendererImageAsync(Stream stream, SvgImageRendererSettings settings, CancellationToken token) { return(ThreadPool.RunAsync(_ => RendererImage(stream, settings)).AsTask(token)); }
public static Task RendererImageAsync(Stream stream, SvgImageRendererSettings settings) { return(ThreadPool.RunAsync(_ => RendererImage(stream, settings)).AsTask()); }