views:

195

answers:

2

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

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...
+3  A: 

Your problems here are

  • The PNG is anti-aliased
  • It is composited against the normal form background (SystemColors.Control)
  • If you make that transparent using the TransparencyKey property (which makes a single color transparent, but nothing else), you'll end up having opaqueness where the PNG had partial transparency

So far, so expected. Keep in mind: You're not drawing a partially-transparent PNG onto the screen; you're drawing it onto your form and you then take the end result and make a single color transparent. For all what it's worth, your PNG could have pink as the surrounding color, the result would be the same.

You may want to look at regions or don't anti-alias the PNG you're drawing.

Joey
how can not anti-alias... i tried but i am unable to do it in photoshop
Junaid Saeed
+2  A: 

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.

Ash
the only thing is now i cannot have UI Components but you solved what i asked..
Junaid Saeed