Graphics.SmoothingMode Proprietà

Definizione

Ottiene o imposta la qualità di rendering per questo oggetto Graphics.

C#
public System.Drawing.Drawing2D.SmoothingMode SmoothingMode { get; set; }

Valore della proprietà

Uno dei valori di SmoothingMode.

Esempio

Il metodo seguente illustra gli effetti dell'impostazione delle DashCapproprietà , DashPatterne SmoothingMode . L'output dell'esempio viene illustrato nella figura seguente.

Linee con e senza smoothing applicate.

Questo esempio è progettato per essere usato con Windows Forms. Incollare il codice in un modulo e chiamare il ShowPensAndSmoothingMode metodo durante la gestione dell'evento del Paint modulo, passando e come PaintEventArgs.

C#
private void ShowPensAndSmoothingMode(PaintEventArgs e)
{

    // Set the SmoothingMode property to smooth the line.
    e.Graphics.SmoothingMode = 
        System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

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

    // Set the width to 6.
    greenPen.Width = 6.0F;

    // Set the DashCap to round.
    greenPen.DashCap = System.Drawing.Drawing2D.DashCap.Round;

    // Create a custom dash pattern.
    greenPen.DashPattern = new float[]{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 = 
        System.Drawing.Drawing2D.SmoothingMode.None;

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

    // Dispose of the custom pen.
    greenPen.Dispose();
}

Commenti

La modalità di smoothing specifica se le linee, le curve e i bordi delle aree riempite usano lo smoothing (chiamato anche antialiasing). Un'eccezione è che i pennelli sfumatura di percorso non obbediscono alla modalità di smoothing. Le aree riempite usando un PathGradientBrush oggetto vengono visualizzate allo stesso modo (aliased) indipendentemente dalla SmoothingMode proprietà.

Si applica a

Prodotto Versioni
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9