Graphics.SmoothingMode 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定這個 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 值。
範例
下列方法示範設定 DashCap、 DashPattern和 SmoothingMode 屬性的效果。 下列圖例顯示範例的輸出。
此範例的設計目的是要與 Windows Forms 搭配使用。 將程式代碼貼到表單中,並在處理表單的事件時呼叫 ShowPensAndSmoothingMode
方法,並e
傳遞為 PaintEventArgs。Paint
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
備註
平滑模式會指定填滿區域的線條、曲線和邊緣是否使用平滑化 (也稱為反鋸齒) 。 其中一個例外狀況是路徑漸層筆刷不會遵守平滑模式。 不論 屬性為何,使用 PathGradientBrush 填滿的區域會以相同方式呈現 (別名) SmoothingMode 。