Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Transparency key is easy to use - but that's not that what I need. For ex.: I have a sprite like this: http://spritedatabase.net/file/12735 (no alpha chanel) and I want to make buttons with image set to this - I want to set blue as transparency key, but on transparent parts of image I'd like to see the main form - not my desktop. How to achieve this kind of transparency?
Posted

Sure. You can do graphics rendering using ARGB colors, with alpha channel:
http://msdn.microsoft.com/en-us/library/system.drawing.color.aspx[^],
http://msdn.microsoft.com/en-us/library/system.drawing.color.fromargb.aspx[^].
It is not related only to System.Windows.Forms, but to System.Drawing, which has wider applicability (for example, you can draw on bitmaps which are not shown on a form).

On top of that, you can set opacity for the whole form, but it cannot allow you do make one part of it more transparent than other. And I won't recommend to try to implement transparency to control (unless you do your own rendering as I mentioned above) — transparency for System.Windows.Forms is a total lame. If you need to apply transparency freely to anything you want, switch to WPF.

—SA
 
Share this answer
 
or:
Bitmap bitmap = new Bitmap(...)
bitmap.MakeTransparent(some color)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900