Plain Text

Drawing Text Layout

Demonstrates how to use plain text.

Сode Snippet

using (var bitmap = new Bitmap(400, 250, PixelFormat.Format24bppRgb, new RgbColor(255, 255, 255, 255)))
using (var graphics = bitmap.GetAdvancedGraphics())
{
    var brush = new SolidBrush(new RgbColor(0x41, 0x41, 0x41));

    var texts = new PlainText[]
    {
        new PlainText("Horizontal text\nwith two lines", graphics.CreateFont("Times New Roman", 22f), brush)
        {
            Position = new System.Drawing.PointF(50f, 38f),
        },
        new PlainText("Vertical", graphics.CreateFont("Arial", 24f), brush)
        {
            Vertical = true,
            Position = new System.Drawing.PointF(20f, 10f),
            Effect = new Glow(new RgbColor(0x66, 0xaf, 0xe9), 5),
        },
    };

    foreach (var text in texts)
    {
        graphics.DrawEllipse(new Pen(RgbColor.Red, 2), text.Position.X - 1, text.Position.Y - 1, 2, 2);
        graphics.DrawText(text);
    }

    bitmap.Save("PlainText.png");
}

Output

PlainText.png

For AI-assisted development: Download Graphics Mill Code Samples XML Catalog