RenderSvg.vb
''
'' This code is part of Document Solutions for Imaging demos.
'' Copyright (c) MESCIUS inc. All rights reserved.
''
Imports System
Imports System.IO
Imports System.Drawing
Imports GrapeCity.Documents.Drawing
Imports GrapeCity.Documents.Text
Imports GrapeCity.Documents.Imaging
Imports GrapeCity.Documents.Svg
Imports GCTEXT = GrapeCity.Documents.Text
Imports GCDRAW = GrapeCity.Documents.Drawing

'' This short sample shows how to measure and render an SVG image.
'' The SVG art used in this sample is from freesvg.org.
Public Class RenderSvg
    Public Function GenerateImage(
            ByVal pixelSize As Size,
            ByVal dpi As Single,
            ByVal opaque As Boolean,
            Optional ByVal sampleParams As String() = Nothing) As GcBitmap

        '' Load the SVG:
        Dim svgPath = Path.Combine("Resources", "SvgClipArt", "Smiling-Girl.svg")
        Using svg = GcSvgDocument.FromFile(svgPath)

            '' Render the SVG image and a border around it:
            Dim bmp = New GcBitmap(pixelSize.Width, pixelSize.Height, opaque, dpi, dpi)
            Using g = bmp.CreateGraphics(Color.White)
                Dim pt = New PointF(dpi, dpi)
                g.DrawSvg(svg, pt)
                Dim sz = svg.GetIntrinsicSize(SvgLengthUnits.Pixels)
                g.DrawRectangle(New RectangleF(pt, sz), Color.MediumPurple)
            End Using

            '' Done:
            Return bmp
        End Using
    End Function
End Class