views:

2027

answers:

2

Using VS2005 and C#.

Having a button in a form and an image from a resource, the image does not have transparency.

How can I have transparency when assigning the image from the IDE ?

Thank you.

A: 

I don't really understand what you are asking. You can use an image with transparency on a button as long as the image type you are using supports transparency - such as .png.

Edit: I read your question again and it is still confusing, but maybe you meant to say that you want to add transparency to the image? If so, you would have to use an image editor to add the transparency and save it in a format that supports this. Paint.Net is a good free tool for this.

jhale
Well, the image is a resource so it is a Bitmap...
Stecy
You can open the image in an image editor and save it as a png. I'm pretty sure bitmaps don't support transparency.
jhale
I also don't understand what you mean by the image is a resource so it is a bitmap. You can save a png (with transparency) in a resource file and then use it on a button. I've done it.
jhale
The format is retained, png's and GIF's work just fine.
Ed Swangren
+2  A: 

Open the image in an image editor (Paint.NET and GIMP are free) and add the transparencies wherever you need to. It will all work once the image actually has transparent pixels. You can also use a couple mnethods of teh Bitmap class to do this programmatically:

Bitmap b = Properties.Resources.MyImage.;
b.MakeTransparent(b.GetPixel(0, 0));
Ed Swangren
Thank you very much.
Stecy
Where does this code go? not in Form1.Designer.cs, which is all generated code. How does one set the transparency for a button without overriding the button's Paint() event?
Cheeso