Reputation: 7826
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);
graphics.DrawString("This is a watermark",
new Font("Arial", 40),
new SolidBrush(Color.Red),
0,
0);
Upvotes: 8
Views: 12657
Reputation: 14660
Try:
int opacity = 128; // 50% opaque (0 = invisible, 255 = fully opaque)
using (var graphics = Graphics.FromImage(image))
using (var font = new Font("Arial", 40))
using (var brush = new SolidBrush(Color.FromArgb(opacity, Color.Red)))
graphics.DrawString("This is a watermark", font, brush, 0, 0);
Upvotes: 21
Reputation: 50752
Try
new SolidBrush(Color.FromArgb(0x78FF0000))
Hope this helps
Upvotes: 1