Grphics: How to draw an image transparent

  • Thread starter Thread starter felix
  • Start date Start date
F

felix

Hi,

I have an Image that is drawn with Graphics.DrawImage(..). What I want
to do is drawing it with a given transparency, e.g. at an alpha of only
180 instead of 255.

How am I doing that?!?!?

Regards,
Felix
 
Actually, I can't find such an information on your website. I know how
to draw an image and I'm also able to draw a transparent gif (well, I
think, GDI+ simply handles the transparency on its own).

What I want is to render the entire image (regardless of its own
transparency) with a specific alpha. Imagine a slider where the user can
modify the alpha value in the range [0,255] and the image will be
rendered accordingly.

I can't find any information about that issue. Thus, I'm really looking
forward for any help I can get.

Regards,
Felix
 
Actually, I can't find such an information on your website. I know how
to draw an image and I'm also able to draw a transparent gif (well, I
think, GDI+ simply handles the transparency on its own).

What I want is to render the entire image (regardless of its own
transparency or file-format / pixel-format) with a specific alpha.
Imagine a slider where the user can modify the alpha value in the range
[0,255] and the image will be rendered accordingly.

I can't find any information about that issue. Thus, I'm really looking
forward for any help I can get.

Regards,
Felix
 
At the bottom of the Drawing An Image article in the GDI+ FAQ it clearly
shows how to draw an image with transparency using the ColorMatrix
structure.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





felix said:
Actually, I can't find such an information on your website. I know how to
draw an image and I'm also able to draw a transparent gif (well, I think,
GDI+ simply handles the transparency on its own).

What I want is to render the entire image (regardless of its own
transparency or file-format / pixel-format) with a specific alpha. Imagine
a slider where the user can modify the alpha value in the range [0,255]
and the image will be rendered accordingly.

I can't find any information about that issue. Thus, I'm really looking
forward for any help I can get.

Regards,
Felix

The info you need is actually in the GDI+ FAQ. See the article on Drawing
images.
 
Oops, I didn't see the very last example. I'm really sorry.

Everything works fine now -- THANK YOU!

Regards,
Felix
 
Back
Top