Graphics.SmoothingMode プロパティ

定義

この Graphics のレンダリング品質を取得または設定します。Gets or sets the rendering quality for this Graphics.

public:
 property System::Drawing::Drawing2D::SmoothingMode SmoothingMode { System::Drawing::Drawing2D::SmoothingMode get(); void set(System::Drawing::Drawing2D::SmoothingMode value); };
public System.Drawing.Drawing2D.SmoothingMode SmoothingMode { get; set; }
member this.SmoothingMode : System.Drawing.Drawing2D.SmoothingMode with get, set
Public Property SmoothingMode As SmoothingMode

プロパティ値

SmoothingMode

SmoothingMode 値のいずれか 1 つ。One of the SmoothingMode values.

次のメソッドは、、、およびの各プロパティを設定した場合の効果を示して DashCap DashPattern SmoothingMode います。The following method demonstrates the effects of setting the DashCap, DashPattern, and SmoothingMode properties. この例の出力を次の図に示します。The output of the example is shown in the following illustration.

スムージングを適用した行と適用していない行。Lines with and without smoothing applied.

この例は、Windows フォームと共に使用するように設計されています。This example is designed to be used with Windows Forms. フォームにコードを貼り付け、 ShowPensAndSmoothingMode フォームのイベントを処理するときにメソッドを呼び出し Paint e て、として渡し PaintEventArgs ます。Paste the code into a form and call the ShowPensAndSmoothingMode method when handling the form's Paint event, passing e as PaintEventArgs.

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 = gcnew 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.
      array<Single>^temp0 = {4.0F,2.0F,1.0F,3.0F};
      greenPen->DashPattern = temp0;

      // 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.
      delete greenPen;
   }
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();
}
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.
    greenPen.Dispose()
End Sub

注釈

スムージングモードでは、塗りつぶし領域の線、曲線、および端がスムージング (アンチエイリアシングとも呼ばれます) を使用するかどうかを指定します。The smoothing mode specifies whether lines, curves, and the edges of filled areas use smoothing (also called antialiasing). 1つの例外として、パスグラデーションブラシがスムージングモードに従わないことが挙げられます。One exception is that path gradient brushes do not obey the smoothing mode. を使用して塗りつぶされた領域 PathGradientBrush は、プロパティに関係なく同じ方法 (エイリアス) で表示され SmoothingMode ます。Areas filled using a PathGradientBrush are rendered the same way (aliased) regardless of the SmoothingMode property.

適用対象