我有这个代码;
public static Image AddText(this Image image, ImageText text)
{
Graphics surface = Graphics.FromImage(image);
Font font = new Font("Tahoma", 10);
System.Drawing.SolidBrush brush = new SolidBrush(Color.Red);
surface.DrawString(text.Text, font, brush, new PointF { X = 30, Y = 10 });
surface.Dispose();
return image;
}
但是,当文本被绘制到我的图像上时,它是带有黑色边框或阴影的红色。
如何在没有任何边框或阴影的情况下将文本写入图像?
编辑
我通过添加解决了这个问题;
surface.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
如果有人可以解释为什么我需要这个,那就太好了。