HelloWorld.vb
''
'' This code is part of GrapeCity Documents for Imaging samples.
'' Copyright (c) GrapeCity, Inc. All rights reserved.
''
Imports System.IO
Imports System.Drawing
Imports GrapeCity.Documents.Drawing
Imports GrapeCity.Documents.Text
Imports GrapeCity.Documents.Imaging

'' A simple program drawing the "Hello, World!" text
'' on a background filled with a radial gradient.
Public Class HelloWorld
    Function GenerateImage(
            Optional pixelWidth As Integer = 1024,
            Optional pixelHeight As Integer = 1024,
            Optional opaque As Boolean = True,
            Optional dpiX As Single = 96,
            Optional dpiY As Single = 96) As GcBitmap

        Dim blue = Color.FromArgb(&HFF2E4884)
        Dim bmp = New GcBitmap(pixelWidth, pixelHeight, True, dpiX, dpiY)
        Using g = bmp.CreateGraphics(blue)
            Dim rc = New RectangleF(0, 0, pixelWidth, pixelHeight)
            Dim b = New RadialGradientBrush(Color.White, blue, New PointF(0.5F, 0.5F), True)
            g.FillRectangle(rc, b)
            Dim tf = New TextFormat With {
                .Font = Font.FromFile(Path.Combine("Resources", "Fonts", "timesbd.ttf")),
                .FontSize = 64,
                .ForeColor = Color.OrangeRed
            }
            g.DrawString("Hello, World!", tf, rc, TextAlignment.Center, ParagraphAlignment.Center, False)
        End Using
        ' Done
        Return bmp
    End Function
End Class