RenderSvg.vb
C# VB
'''' This code is part of Document Solutions for Imaging demos.'' Copyright (c) MESCIUS inc. All rights reserved.''Imports SystemImports System.IOImports System.DrawingImports GrapeCity.Documents.ImagingImports GrapeCity.Documents.Svg
'' 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 FunctionEnd Class