问题描述
有没有办法正确显示使用Alpha通道图像(假设PNG)在C#应用程序?感谢您的任何建议。
Is there a way to properly display an image with alpha channel (let's say PNG) in C# application? Thank you for any suggestions.
更新:
OK,我的问题是有点unprecise。我想获得alpha通道的真正的透明度 - 不与父母的背景色填充。在图像下面,我们可以看到,透明性支持,但摆在图像下面的按钮的部分是不可见的。是否有可能有一个形象的alpha通道的一个真正的透明度?
OK, my question was a bit unprecise. I'd like to acquire real transparency of alpha channel - not filling with the parent's background color. In the image below we can see that the transparency is supported, but the part of the button that lies below the image is not visible. Is it possible to have a real transparency of the alpha channel of an image?
推荐答案
如果是的WinForms则没有。在的WinForms
透明度并不是真正的透明度。
If that is winforms then no."transparency" in winforms is not real transparency.
你可以做的就是创建一个绘制PNG,它的位置在正确的位置alphatransparent形式和绑定移动等
的
What you can do is to create a alphatransparent form that draws the PNG and position it at the correct location and bind move etc.http://www.codeproject.com/KB/GDI-plus/perpxalpha_sharp.aspx
PerPixelAlphaForm transparentImageForm = new PerPixelAlphaForm();
transparentImageForm.SetBitmap(<IMAGE GOES HERE>,<OPACITY GOES HERE>);
//不透明度不透明度图像将与绘制,值255 =全透明部分将是字母/透明程度不亚于原始PNG等。
//opacity is the opacity that the image will be drawn with, a value of 255 = all transparent parts will be alpha/transparent just as much as the original PNG etc..
编辑:或去WPF
这篇关于显示PNG在C#alpha通道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!