使用Graphics.DrawString绘制透明背景文本时小字号出现黑边问题
问题:透明背景Bitmap上绘制小字号文本出现黑色轮廓
我使用Graphics.DrawString()在透明背景的Bitmap上绘制文本时发现,当字体大小小于23毫米(字体通过GraphicsUnit.Millimeter创建)时,文本会出现黑色轮廓。
代码如下:
Bitmap bmp = new Bitmap(2000, 2000); Color alpha = Color.FromArgb(0, 0, 0, 0); for (int x = 0; x < bmp.Width; x++) for (int y = 0; y < bmp.Height; y++) bmp.SetPixel(x, y, alpha); Graphics g = Graphics.FromImage(bmp); g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.SmoothingMode = SmoothingMode.HighQuality; Font labelFont = new Font("Cascadia Mono SemiBold", 23/*22*/, FontStyle.Regular, GraphicsUnit.Millimeter); Brush brush = new SolidBrush(Color.White); g.DrawString("Some text", labelFont, brush, 200, 200);
23毫米字号效果:
22毫米字号效果:
我尝试使用TextRenderer,但它无法绘制透明背景的文本。
内容的提问来源于stack exchange,提问作者Yotic
相关产品推荐
相关产品推荐

