RenderSvg.vb
''
'' このコードは、DioDocs for Imaging のサンプルの一部として提供されています。
'' © 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
'' このサンプルでは、SVG 画像のサイズを測定し、描画する方法を示します。
'' 本サンプルで使用している SVG アートは、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
'' SVGを読み込みます。
Dim svgPath = Path.Combine("Resources", "SvgClipArt", "Smiling-Girl.svg")
Using svg = GcSvgDocument.FromFile(svgPath)
'' SVG画像と、その周囲の境界線を描画します。
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
'' 画像ファイルを保存します。
Return bmp
End Using
End Function
End Class