开发者

Graphics.DrawString specify opacity of text

开发者 https://www.devze.com 2023-03-18 03:59 出处:网络
Is it possible to specify the opacity of text written using the Graphics.DrawString method? I\'m doing something like this, but would like my text to be semi-transparent if it is possible.

Is it possible to specify the opacity of text written using the Graphics.DrawString method?

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);
graph开发者_开发百科ics.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

0

精彩评论

暂无评论...
验证码 换一张
取 消