C# 如何设置字体颜色?
我正在使用Visual C。在图片上叠加文字时,如何设置字体颜色C# 如何设置字体颜色?,c#,text,fonts,colors,overlay,C#,Text,Fonts,Colors,Overlay,我正在使用Visual C。在图片上叠加文字时,如何设置字体颜色 graphicsImage.DrawString(textBox1.Text, new Font("Arial", 12, FontStyle.Bold) SystemBrushes.WindowText, new Point(10, 210)); 尝试像这样使用SolidBrush,您将得到红色字体: graphicsImage.DrawString(textBox1.Text, new Font("Arial
graphicsImage.DrawString(textBox1.Text,
new Font("Arial", 12, FontStyle.Bold)
SystemBrushes.WindowText, new Point(10, 210));
尝试像这样使用SolidBrush,您将得到红色字体:
graphicsImage.DrawString(textBox1.Text, new Font("Arial", 12, FontStyle.Bold), new SolidBrush(Color.Red), new Point(10, 210));
没有
字体
颜色
属性,您应该使用正确的画笔。
在您的情况下,不要忘记处理IDisposable:
using (Brush brush = new SolidBrush(Color.Red)) { // <- Let your text be red
using (Font font = new Font("Arial", 12, FontStyle.Bold)) {
// Paint the text with selected
// font - Arial 12 Bold
// brush - solid red
graphicsImage.Graphics.DrawString(
textBox1.Text, // <- what (text)
font, // <- font
brush, // <- color
new Point(10, 210)); // <- where
}
}
使用(Brush-Brush=new-SolidBrush(Color.Red)){//u可以添加您的xaml/aspx吗?