Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please help me if I can set the image/shape transparency or opacity? #1239

Open
ZhouYixxx opened this issue Dec 14, 2023 · 0 comments
Open

Comments

@ZhouYixxx
Copy link

The problem may seem naive, I'm inserting a piece of text into an Excel sheet as a watermark by drawing it as an image, but I'd like to be able to set the image to semi-transparent. I googled it for a long time. But there doesn't seem to be a good solution.
And I've tried setting the transparency of the text, which doesn't work well either.

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);

if anyone can kindly help me? Even if it makes it clear that there is no good solution it would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants