Search code examples
c#winformstransparencyphotoshop

Winforms Transparency Issue (i going crazy with it)


i will show you an image below but before that...

if you have seen yahoo widgets or cartoony/themed windows media player skins..

i am building a titlebar less... background less... application... its looks like this

alt text
(source: deviantart.net)

the darker background you see is actually my wallpaper cuz this is a screen shot...

to attain this.. the shape of body and the lines, i use Trasparent PNG.. then i use the transparency key of the Win Form to make it transparent.. and the image is loaded in a picture box...

my problem is the white dots you see all over the body outline... this is because the pixels of that PNG in that are not completely opaque or transparent i.e translucent... so the transparency key fails to make the background of the form transparent at those pixels... and you see these white dots...

well is there any other way make the form transparent because...

  • transparency key will always behave like this because no matter what you do there will always be these translucent pixels in the image at curves...

Solution

  • Johannes has mentioned the main issues with your current approach.

    It is possible to do form alpha blending in Windows Forms but you will need to use the Windows API call (among others): UpdateLayeredWindow.

    Visual C# kicks has a helpful tutorial and source code on how to do this to create a professional looking splash screen.

    The only drawback is that if your form contains child controls such as buttons, textboxes, they will not be drawn using UpdateLayeredWindow. However you could still simulate buttons etc by manually drawing them as part of the form background.