'' 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(
            ByVal pixelSize As Size,
            ByVal dpi As Single,
            ByVal opaque As Boolean,
            Optional ByVal sampleParams As String() = Nothing) As GcBitmap

        Dim blue = Color.FromArgb(&HFF2E4884)
        Dim bmp = New GcBitmap(pixelSize.Width, pixelSize.Height, True, dpi, dpi)
        Using g = bmp.CreateGraphics(blue)
            Dim rc = New RectangleF(0, 0, pixelSize.Width, pixelSize.Height)
            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