WinForms 应用程序中 ListView 上的 .NET 图像问题(显示不正确)
我在图像方面遇到了非常奇怪的问题。我有一个设置窗口,左侧有一个 ListView,其中有各种图像图标,单击这些图标时会更新右侧面板以显示相关内容 - 没有什么特别的。
然而,我最近添加了两个额外的图标,但它们的图像没有正确显示,我无法弄清楚为什么。我尝试了各种不同的图像格式(png、jpg、gif、bmp),但它们都无法正确显示。我在另一台计算机上尝试过,看看是否是我安装的 .NET,但错误仍然存在。
如果每个图像都显示不正确,我会很高兴,但不幸的是只有这两个图像,也许还有我现在添加的任何其他图像。
有没有人有任何想法 - 我完全没有想法...
这是它运行时的样子...
这是与 Visual Studio 中显示的相同的资源文件...
另一个...
其他图像渲染得很好,比如这个...
I am experiencing very weird issues surrounding Images. I have a settings window, which has a ListView on the left hand side which has various image icons which when clicked update the panel to the right to display relevant stuff - nothing hugely special.
However, I have recently added two extra icons, but their images are not being displayed correctly and I can't for the life of me figure out why. I've tried various different image formats (png, jpg, gif, bmp) and none of them display correctly. I've tried it on another computer to see if it was my installation of .NET but the error persisted.
I'd be happy if every image displayed incorrectly, but unfortunately its just these two, and perhaps any other image I add now.
Has anyone got any ideas - I'm all out of them...
Here is what it looks like when it runs...
Here is the same resource file as shown in visual studio...
The other one...
The other images render absolutely fine, such as this one...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是由存储这些图像的ImageList 引起的。您已将 ColorDepth 属性保留为默认值 Depth8Bit。这迫使 Windows 将这些具有高颜色内容的图像(例如,请注意箭头中的微妙渐变)转换为只能存储 256 种不同颜色的像素格式。这是一种有损转换并会导致伪影。
将属性更改为 Depth32Bit。
This is caused by the ImageList that stores these images. You've left the ColorDepth property to the default, Depth8Bit. Which forces Windows to convert these images with high color content (note the subtle gradient in the arrows for example) to a pixel format that can store only 256 distinct colors. That's a lossy conversion and causes artifacts.
Change the property to Depth32Bit.