Export (0) Print
Expand All

Graphics::SmoothingMode Property

Gets or sets the rendering quality for this Graphics.

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

property SmoothingMode SmoothingMode {
	SmoothingMode get ();
	void set (SmoothingMode value);

Property Value

Type: System.Drawing.Drawing2D::SmoothingMode
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. The output of the example is shown in the following illustration.

Lines with and without smoothing applied.

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.

   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;

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft