Bitmap.GetGdiPlusGraphics Method

Gets the System.Drawing.Graphics object associated with this Bitmap.

Namespace: Aurigma.GraphicsMill
Assembly: Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)

Syntax

C#
public Graphics GetGdiPlusGraphics()

Return Value

A System.Drawing.Graphics object associated with this Bitmap.

Examples

C#
using (var bitmap = new Bitmap(100, 60, PixelFormat.Format24bppRgb, RgbColor.White))
{
    using (System.Drawing.Graphics graphics = bitmap.GetGdiPlusGraphics())
    {
        graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

        var bluePen = new System.Drawing.Pen(System.Drawing.Color.Blue, 8);
        graphics.DrawLine(bluePen, 10, 55, 90, 5);

        var redPen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(200, 255, 0, 0), 8);
        graphics.DrawLine(redPen, 10, 5, 90, 55);

        bitmap.Save(@"Images\Output\pen.png");
    }
}

See Also

Reference