2009-07-27 27 views
2

当我将一个字符串绘制到一个缓冲区中时,得到的输出不会按照我期望的方式消除锯齿。此代码说明了这个问题......只是把这个在一个标准的智能设备项目的Form1.cs中:如何在Compact Framework上使用双缓冲区的ClearType?

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中呈现。

我想我必须创建我的图形缓冲区的方式,使它使用字体平滑,但我没有看到一种方式来做到这一点。

回答

3

原来是一个简单的问题。通过删除PixelFormat.Format32bppRgb它工作得很好。看起来像你需要确保你的缓冲区具有相同的像素格式...

0

设置你的显卡的SmoothingMode属性对象:

g.SmoothingMode = SmoothingMode.AntiAlias; 
+1

我以某种方式怀疑这是可用的CF. – leppie 2009-07-27 12:43:14

0

你将不得不使用gdiplus.dll的(存在于这几个包装),但它只能在Windows Mobile 6专业版(不标准)。