SvgSpecArt.cs
C# VB
//// This code is part of Document Solutions for Imaging demos.// Copyright (c) MESCIUS inc. All rights reserved.//using System;using System.IO;using System.Drawing;using System.Collections.Generic;using System.Linq;using GrapeCity.Documents.Imaging;using GrapeCity.Documents.Svg;
namespace DsImagingWeb.Demos{ // Use GcSvgDocument to render a few images used as illustrations // in the SVG spec. public class SvgSpecArt { public GcBitmap GenerateImage(Size pixelSize, float dpi, bool opaque, string[] sampleParams = null) { // Load images from resources: var fnames = new List<string>() { "dash-path.svg", "opacity.svg", "paths.svg", "shadowstyle.svg", "units.svg", }; var images = new List<(string, GcSvgDocument)>(); foreach (var f in fnames) images.Add((f, GcSvgDocument.FromFile(Path.Combine("Resources", "SvgSpecArt", f))));
float margin = dpi / 2; float gapy = dpi / 4; var ip = new PointF(margin, margin);
// Render the images: var bmp = new GcBitmap(pixelSize.Width, pixelSize.Height, opaque, dpi, dpi); using var g = bmp.CreateGraphics(Color.White); for (int i = 0; i < images.Count(); ++i) { var svg = images[i].Item2; var s = svg.GetIntrinsicSize(SvgLengthUnits.Pixels); g.DrawSvg(svg, ip); ip.Y += s.Height + gapy; } // Dispose images after saving the result: images.ForEach(t_ => t_.Item2.Dispose()); // Done: return bmp; } }}