简体   繁体   English

Graphics.DrawString 指定文本的不透明度

[英]Graphics.DrawString specify opacity of text

Is it possible to specify the opacity of text written using the Graphics.DrawString method?是否可以指定使用Graphics.DrawString方法编写的文本的不透明度?

I'm doing something like this, but would like my text to be semi-transparent if it is possible.我正在做这样的事情,但如果可能的话,我希望我的文字是半透明的。

Currently I'm doing this:目前我正在这样做:

Graphics graphics = Graphics.FromImage(image);
graphics.DrawString("This is a watermark", 
    new Font("Arial", 40), 
    new SolidBrush(Color.Red), 
    0, 
    0);

Try:尝试:

int opacity = 128; // 50% opaque (0 = invisible, 255 = fully opaque)
Graphics graphics = Graphics.FromImage(image);
graphics.DrawString("This is a watermark", 
    new Font("Arial", 40), 
    new SolidBrush(Color.FromArgb(opacity, Color.Red)), 
    0, 
    0);

Try尝试

new SolidBrush(Color.FromArgb(0x78FF0000))

Hope this helps希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM