有没有办法在 C# 应用程序中正确显示带有 alpha 通道的图像(比如说 PNG)?感谢您的任何建议。
UPDATE:
好吧,我的问题有点不准确。我想获得 Alpha 通道的真正透明度 - 不填充父级的背景颜色。在下图中我们可以看到支持透明度,但按钮位于图像下方的部分不可见。图像的 Alpha 通道是否可能具有真正的透明度?
如果那是winform那就不行。
winforms中的“透明”并不是真正的透明。
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 http://www.codeproject.com/KB/GDI-plus/perpxalpha_sharp.aspx
PerPixelAlphaForm transparentImageForm = new PerPixelAlphaForm();
transparentImageForm.SetBitmap(<IMAGE GOES HERE>,<OPACITY GOES HERE>);
//opacity 是绘制图像时使用的不透明度,值为 255 = 所有透明部分都将是 alpha/透明,与原始 PNG 等一样多。
编辑:或转到 WPF。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)