Type Default Value Read Only Static Description
Double None No No The horizontal alignment of lines of text. A value of zero left aligns, one right aligns and 0.5 centers.



Here we draw an image and a text caption on a bitmap. We centre horizontally text and image. The image is aligned to the top (the default) and the caption to the bottom.

[C#]Font font = new Font("Arial", 36, FontStyle.Regular);
int lineHeight = (int)Math.Round(font.GetHeight());
Size border = new Size(80, 80);
using (Image image = Bitmap.FromFile(Server.MapPath("rez/vladimir-tsokalo-N3moZ3Gn-gI-unsplash.jpg"))) {
  Size size = new Size(image.Width, image.Height + lineHeight) + (2 * border);
  using (Bitmap bm = new Bitmap(size)) {
    RectangleF content = bm.Bounds;
    using (Graphics graphics = Graphics.FromImage(bm)) {
      graphics.DrawImage(image, image.Bounds + (Point)border);
      string txt = "My image caption";
      StringFormat format = new StringFormat();
      format.Alignment = StringAlignment.Center;
      format.LineAlignment = StringAlignment.Far;
      graphics.DrawString(txt, font, Brushes.Black, content, format);