TextRenderer
(これは を使用するのに適しているためGraphics.DrawString
) を使用してテキストを描画しようとしていますBitmap
が、非常に望ましくない効果がいくつかあります。
サンプルコード
using (Bitmap buffer = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb))
{
using (Graphics graphics = Graphics.FromImage(buffer))
{
// Produces the result below
graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
// Produces clean text, but I'd really like ClearType!
graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
TextRenderer.DrawText(graphics, "Hello World", this.Font, this.ClientRectangle, Color.Black);
}
e.Graphics.DrawImageUnscaled(buffer, this.ClientRectangle);
}
結果
これを修正する方法が正確にはわかりません...助けてください!
Graphics.DrawString
正しい GDI (GDI+ ではなく) レンダリングが必要なため、使用したくありません。
注:この質問に大きな穴を残してしまったことに気付きました。一部の人々は、ClearType テキストのレンダリングが自分のマシンで正常に機能していると指摘しています...
テキストを透明 (Color.Transparent) ビットマップにレンダリングしようとしています。単色でやると上手くいきます!(ただし、透明なビットマップにレンダリングすることが不可欠です)。