// This code is part of GrapeCity Documents for Imaging samples.
// Copyright (c) GrapeCity, Inc. All rights reserved.
using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using GrapeCity.Documents.Drawing;
using GrapeCity.Documents.Text;
using GrapeCity.Documents.Imaging;
using GrapeCity.Documents.Svg;
using GCTEXT = GrapeCity.Documents.Text;
using GCDRAW = GrapeCity.Documents.Drawing;
using GcImagingWeb.Samples.Common;

namespace GcImagingWeb.Samples
    // This short sample shows how to measure and render an SVG image.
    // The SVG art used in this sample is from
    public class RenderSvg
        public GcBitmap GenerateImage(Size pixelSize, float dpi, bool opaque, string[] sampleParams = null)
            // Load the SVG:
            var svgPath = Path.Combine("Resources", "SvgClipArt", "Smiling-Girl.svg");
            using var svg = GcSvgDocument.FromFile(svgPath);

            // Render the SVG image and a border around it:
            var bmp = new GcBitmap(pixelSize.Width, pixelSize.Height, opaque, dpi, dpi);
            using var g = bmp.CreateGraphics(Color.White);
            var pt = new PointF(dpi, dpi);
            g.DrawSvg(svg, pt);
            var sz = svg.GetIntrinsicSize(SvgLengthUnits.Pixels);
            g.DrawRectangle(new RectangleF(pt, sz), Color.MediumPurple);

            // Done:
            return bmp;