SmoothingMode 有六種列舉,可以分為三類
- 文字:必須使用 Graphics.TextRenderingHint,參考 [C#] 繪製文字 - 平滑化
- 漸層:必須使用 PathGradientBrush
C# 測試 Code
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace GraphicsSample
{
public partial class FrmLineCurveAntialiAsing : Form
{
public FrmLineCurveAntialiAsing()
{
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
int width = 100;
int height = 50;
using (Pen p = new Pen(Color.Red, 2))
{
e.Graphics.DrawEllipse(p, 10, 10, width, height);
// 平滑化
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
e.Graphics.DrawEllipse(p, 130, 10, width, height);
}
}
}
}
沒有留言:
張貼留言