HelloWorld.cs
//
// This code is part of GrapeCity Documents for Imaging samples.
// Copyright (c) GrapeCity, Inc. All rights reserved.
//
using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using GrapeCity.Documents.Drawing;
using GrapeCity.Documents.Text;
using GrapeCity.Documents.Imaging;

namespace GcImagingWeb.Samples
{
    // A simple program drawing the "Hello, World!" text
    // on a background filled with a radial gradient.
    public class HelloWorld
    {
        public GcBitmap GenerateImage (int pixelWidth = 1024, int pixelHeight = 1024, bool opaque = true, float dpiX = 96, float dpiY = 96)
        {
            var blue = Color.FromArgb(unchecked((int)0xFF2e4884));
            var bmp = new GcBitmap(pixelWidth, pixelHeight, true, dpiX, dpiY);
            using (var g = bmp.CreateGraphics(blue))
            {
                var rc = new RectangleF(0, 0, pixelWidth, pixelHeight);
                var b = new RadialGradientBrush(Color.White, blue, new PointF(0.5f, 0.5f), true);
                g.FillRectangle(rc, b);
                var tf = new TextFormat
                {
                    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);
            }
            return bmp;
        }
    }
}