HelloWorld.vb
  1. ''
  2. '' This code is part of Document Solutions for Imaging demos.
  3. '' Copyright (c) MESCIUS inc. All rights reserved.
  4. ''
  5. Imports System.IO
  6. Imports System.Drawing
  7. Imports GrapeCity.Documents.Drawing
  8. Imports GrapeCity.Documents.Text
  9. Imports GrapeCity.Documents.Imaging
  10. Imports GCTEXT = GrapeCity.Documents.Text
  11. Imports GCDRAW = GrapeCity.Documents.Drawing
  12.  
  13. '' A simple program drawing the "Hello, World!" text
  14. '' on a background filled with a radial gradient.
  15. Public Class HelloWorld
  16. Function GenerateImage(
  17. ByVal pixelSize As Size,
  18. ByVal dpi As Single,
  19. ByVal opaque As Boolean,
  20. Optional ByVal sampleParams As String() = Nothing) As GcBitmap
  21.  
  22. Dim blue = Color.FromArgb(&HFF2E4884)
  23. Dim bmp = New GcBitmap(pixelSize.Width, pixelSize.Height, True, dpi, dpi)
  24. Using g = bmp.CreateGraphics(blue)
  25. Dim rc = New RectangleF(0, 0, pixelSize.Width, pixelSize.Height)
  26. Dim b = New RadialGradientBrush(Color.White, blue, New PointF(0.5F, 0.5F), True)
  27. g.FillRectangle(rc, b)
  28. Dim tf = New TextFormat With {
  29. .Font = GCTEXT.Font.FromFile(Path.Combine("Resources", "Fonts", "timesbd.ttf")),
  30. .FontSize = 64,
  31. .ForeColor = Color.OrangeRed
  32. }
  33. g.DrawString("Hello, World!", tf, rc, TextAlignment.Center, ParagraphAlignment.Center, False)
  34. End Using
  35. ' Done
  36. Return bmp
  37. End Function
  38. End Class
  39.