1
我正在使用Visual C#。覆盖图片上的文字时,如何设置字体颜色?如何设置字体颜色?
graphicsImage.DrawString(textBox1.Text,
new Font("Arial", 12, FontStyle.Bold)
SystemBrushes.WindowText, new Point(10, 210));
我正在使用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", 12, FontStyle.Bold), new SolidBrush(Color.Red), new Point(10, 210));
有没有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
}
}
u能PLZ添加您的XAML/ASPX问题? – Narendra