如何设置字体颜色?

时间:2014-03-19 06:11:12

标签: c# text fonts colors overlay

我正在使用Visual C#。在图片上叠加文本时,如何设置字体颜色?

graphicsImage.DrawString(textBox1.Text,
new Font("Arial", 12, FontStyle.Bold)
SystemBrushes.WindowText, new Point(10, 210));        

2 个答案:

答案 0 :(得分:1)

尝试使用像这样的SolidBrush,你会得到红色字体:

graphicsImage.DrawString(textBox1.Text, new Font("Arial", 12, FontStyle.Bold), new SolidBrush(Color.Red), new Point(10, 210));

答案 1 :(得分:0)

没有Font Color属性,您应该使用正确的画笔。 在您的情况下,不要忘记处理 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
    }
  }
相关问题