HelloWorld.cs
  1. //
  2. // This code is part of Document Solutions for Imaging demos.
  3. // Copyright (c) MESCIUS inc. All rights reserved.
  4. //
  5. using System;
  6. using System.IO;
  7. using System.Drawing;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using GrapeCity.Documents.Drawing;
  11. using GrapeCity.Documents.Text;
  12. using GrapeCity.Documents.Imaging;
  13. using GCTEXT = GrapeCity.Documents.Text;
  14. using GCDRAW = GrapeCity.Documents.Drawing;
  15.  
  16. namespace DsImagingWeb.Demos
  17. {
  18. // A simple program drawing the "Hello, World!" text
  19. // on a background filled with a radial gradient.
  20. public class HelloWorld
  21. {
  22. public GcBitmap GenerateImage(Size pixelSize, float dpi, bool opaque, string[] sampleParams = null)
  23. {
  24. var blue = Color.FromArgb(unchecked((int)0xFF2e4884));
  25. var bmp = new GcBitmap(pixelSize.Width, pixelSize.Height, true, dpi, dpi);
  26. using (var g = bmp.CreateGraphics(blue))
  27. {
  28. var rc = new RectangleF(0, 0, pixelSize.Width, pixelSize.Height);
  29. var b = new RadialGradientBrush(Color.White, blue, new PointF(0.5f, 0.5f), true);
  30. g.FillRectangle(rc, b);
  31. var tf = new TextFormat
  32. {
  33. Font = GCTEXT.Font.FromFile(Path.Combine("Resources", "Fonts", "timesbd.ttf")),
  34. FontSize = 64,
  35. ForeColor = Color.OrangeRed,
  36. };
  37. g.DrawString("Hello, World!", tf, rc, TextAlignment.Center, ParagraphAlignment.Center, false);
  38. }
  39. return bmp;
  40. }
  41. }
  42. }
  43.