テキストで提供されているオブジェクトを使用TextRenderer.DrawText()
すると、完璧に見えます。独自のオブジェクトを作成して、テキストから取得したオブジェクトを使用すると、見栄えが悪くなります。ビットマップの背景色ではなく、黒を使用してテキストをアンチエイリアス処理しているようです。を使用すればこの問題は回避できますが、この方法には恐ろしいカーニングの問題があります。私は何をすべきか?ビットマップのコンテンツを使用して適切にアンチエイリアスを取得するにはどうすればよいですか?Graphics
OnPaintBackground
Bitmap
Graphics
Bitmap
Graphics.DrawString()
TextRenderer.DrawText()
ひどく見える:
Bitmap bmp = new Bitmap(100, 100, PixelFormat.Format32bppArgb);
using (Graphics g = Graphics.FromImage(bmp))
{
g.Clear(Color.Red);
TextFormatFlags tf = TextFormatFlags.Left;
TextRenderer.DrawText(g, @"C:\Development\Testing\blag", font, clip, Color.White,
Color.Transparent, tf);
}
良さそうに見えますが、これをコントロールの表面ではなくビットマップにレンダリングしたい:
protected override void OnPaintBackground(PaintEventArgs e)
{
e.Graphics.Clear(Color.Red);
TextFormatFlags tf = TextFormatFlags.Left;
TextRenderer.DrawText(e.Graphics, @"C:\Development\Testing\blag", font, clip,
Color.White, Color.Transparent, tf);
}
違いはなんですか?