本文整理匯總了C#中System.Drawing.Graphics.SmoothingMode屬性的典型用法代碼示例。如果您正苦於以下問題:C# Graphics.SmoothingMode屬性的具體用法?C# Graphics.SmoothingMode怎麽用?C# Graphics.SmoothingMode使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.SmoothingMode屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ShowPensAndSmoothingMode
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();
}
示例2: Main
//引入命名空間
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
class AntiAlias: Form
{
public static void Main()
{
Application.Run(new AntiAlias());
}
public AntiAlias()
{
Text = "Anti-Alias Demo";
BackColor = SystemColors.Window;
ForeColor = SystemColors.WindowText;
}
protected override void OnPaint(PaintEventArgs pea)
{
Graphics grfx = pea.Graphics;
Pen pen = new Pen(ForeColor);
grfx.SmoothingMode = SmoothingMode.None;
grfx.DrawLine(pen, 2, 2, 18, 10);
}
}