Graphics.DrawString indicates the opacity of the text.

Can I specify the opacity of text written using the Graphics.DrawString method?

I am doing something similar, but would like my text to be translucent, if possible.

I am currently doing this:

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

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); 
+18
source

Try

 new SolidBrush(Color.FromArgb(0x78FF0000)) 

Hope this helps

+1
source

Source: https://habr.com/ru/post/892123/


All Articles