当我将字符串绘制到缓冲区中时,生成的输出不会像我期望的那样抗锯齿。这段代码说明了问题......只需将其放入标准智能设备项目的 Form1.cs 中:
protected override void OnPaint(PaintEventArgs e)
{
Bitmap buffer = new Bitmap(Width, Height, PixelFormat.Format32bppRgb);
using(Graphics g = Graphics.FromImage(buffer))
{
g.Clear(Color.White);
g.DrawString("Hello, World", Font, new SolidBrush(Color.Black), 5, 5);
}
e.Graphics.DrawImage(buffer, 0, 0);
}
另一方面,如果我只是将字符串绘制到使用 传入的 Graphics 对象中PaintEventArgs
,它会按照我的预期呈现在 ClearType 中。
我想我必须以一种使其使用字体平滑的方式创建我的图形缓冲区,但我看不到这样做的方法。