我需要用DrawString方法繪製Graphics類的字符串。但圖像有一些黑色像素,而不是確切的顏色。我怎樣才能清楚畫出來?如何清楚地使用DrawString?
public Image Ciz()
{
Color renk = Color.FromArgb(255, 133, 199);
Bitmap result = new Bitmap(KutuBoyutu.Genislik, KutuBoyutu.Yukseklik);
result.SetResolution(100, 100);
Graphics g = Graphics.FromImage(result);
g.SmoothingMode = SmoothingMode.HighQuality;
Brush drawBrush = new SolidBrush(renk);
StringFormat stringFormat = new StringFormat();
stringFormat.Alignment = StringAlignment.Center;
stringFormat.LineAlignment = StringAlignment.Center;
Rectangle rect1 = new Rectangle(0, 0, result.Width, result.Height);
Font font = new Font("Arial", 15f, FontStyle.Bold, GraphicsUnit.Pixel);
g.DrawString(Yazi, font, drawBrush, rect1, stringFormat);
drawBrush.Dispose();
return result;
}
它已經是反鋸齒。這是問題:) –
@HansPassant你的意思是已經消除鋸齒?您設置的SmoothingMode是用於線條,圓形等繪圖,而不是用於文本。 –