开发者

Build turns partially transparent image pixels black

开发者 https://www.devze.com 2023-01-03 13:33 出处:网络
I\'m very new to C# and I\'ve run into a problem and haven\'t been able to solve it.I have a row of buttons that have .png images assigned to them.The images are in .png format to allow transparency,

I'm very new to C# and I've run into a problem and haven't been able to solve it. I have a row of buttons that have .png images assigned to them. The images are in .png format to allow transparency, and smoothing the edges in GIMP leaves some semi-transparent pixels. I've set the Image List Toolbar (imglToolbar)'s properties to recognize "Transparent" as the designated color to show up as transparent. I'm working in Visual Studio 2005.

The strange thing is that everything looks great when I'm viewing the Visual C# form preview window. The icons look exactly as they should. However, once I actually build the project, the开发者_开发百科 buttons treat every semi-transparent pixel near the edge of the image as if it's black. It seems like it can't handle one that's both transparent and has color.

Image of it via the Visual C# form editor:

alt text http://img5.imageshack.us/img5/2577/whatiwanted.jpg

Image of what it looks like when built:

alt text http://img690.imageshack.us/img690/7241/whatigot.jpg

Any ideas as to why this is happening?


I just found the answer, at least to my specific situation.

The form I'm dealing with is a top-level MDI container. For whatever reason, having the icons set to 32 bit color doesn't allow for these semi-transparent pixels to be properly interpreted. Setting it to 24-bit, on a whim, completely solved the problem. Not sure if this is some situation that has come up as a result of some unseen factor, but the color depth change fixed my problem.

Also for those who may come here with a similar problem, make sure the window isn't a child of an MDI container. While looking for information, I found MDI children don't support TransparencyKeys at all.


I ran into this problem as well; changing the form's IsMdiContainer property to false solved it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号