Graphics.SmoothingMode Property

Gets or sets the rendering quality for this Graphics.

Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)

Public Property SmoothingMode As SmoothingMode
Dim instance As Graphics
Dim value As SmoothingMode

value = instance.SmoothingMode

instance.SmoothingMode = value
/** @property */
public SmoothingMode get_SmoothingMode ()

/** @property */
public void set_SmoothingMode (SmoothingMode value)

public function get SmoothingMode () : SmoothingMode

public function set SmoothingMode (value : SmoothingMode)

Not applicable.

Property Value

One of the SmoothingMode values.

The smoothing mode specifies whether lines, curves, and the edges of filled areas use smoothing (also called antialiasing). One exception is that path gradient brushes do not obey the smoothing mode. Areas filled using a PathGradientBrush are rendered the same way (aliased) regardless of the SmoothingMode property.

The following method demonstrates the effects of setting the DashCap, DashPattern, and SmoothingMode properties.

This example is designed to be used with Windows Forms. Paste the code into a form and call the ShowPensAndSmoothingMode method when handling the form's Paint event, passing e as PaintEventArgs.

Private Sub ShowPensAndSmoothingMode(ByVal e As PaintEventArgs)

    ' Set the SmoothingMode property to smooth the line.
    e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias

    ' Create a new Pen object.
    Dim greenPen As New Pen(Color.Green)

    ' Set the width to 6.
    greenPen.Width = 6.0F

    ' Set the DashCap to round.
    greenPen.DashCap = Drawing2D.DashCap.Round

    ' Create a custom dash pattern.
    greenPen.DashPattern = New Single() {4.0F, 2.0F, 1.0F, 3.0F}

    ' Draw a line.
    e.Graphics.DrawLine(greenPen, 20.0F, 20.0F, 100.0F, 240.0F)

    ' Change the SmoothingMode to none.
    e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.None

    ' Draw another line.
    e.Graphics.DrawLine(greenPen, 100.0F, 240.0F, 160.0F, 20.0F)

    ' Dispose of the custom pen.
End Sub

private void ShowPensAndSmoothingMode(PaintEventArgs e)
    // Set the SmoothingMode property to smooth the line.

    // Create a new Pen object.
    Pen greenPen = new Pen(Color.get_Green());

    // Set the width to 6.

    // Set the DashCap to round.

    // Create a custom dash pattern.
    greenPen.set_DashPattern(new float[] { 4, 2, 1, 3 });

    // Draw a line.
    e.get_Graphics().DrawLine(greenPen, 20, 20, 100, 240);

    // Change the SmoothingMode to none.

    // Draw another line.
    e.get_Graphics().DrawLine(greenPen, 100, 240, 160, 20);

    // Dispose of the custom pen.
} //ShowPensAndSmoothingMode

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions