使用 Icon.ExtractAssociatedIcon 和 ImageList 获取完整质量的 16 x 16 图标
按照这个问题的指示,我运行了一些代码来从中提取图标文件并在设置为详细信息模式的 ListView 中显示它们。 我希望图标以 16 x 16 的尺寸显示,但是当我将 ImageList 大小设置为该尺寸时,出现的图标看起来非常奇怪(不知道如何描述它 - 请参阅随附的屏幕截图)。
我尝试将尺寸更改为 32 x 32,效果很好,但肯定有办法获得高质量的 16 x 16 图标,不是吗?
http://img165.imageshack.us/img165/4446/badqualityiconscc4.png
Following the directions at this question, I have some code running to extract icons from files and display them in a ListView set to details mode. I want to icons to display at 16 x 16, but when I have the ImageList size set to that the icons that come out look very weird (not sure how to describe it - see attached screenshot).
I've tried changing the size to 32 x 32 and they come out fine, but surely there must be a way to get good quality 16 x 16 icons mustn't there?
http://img165.imageshack.us/img165/4446/badqualityiconscc4.png
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你必须使用 2 个图像列表,一个用于小图像,一个用于大图像才能获得我认为的最佳结果。 (列表视图有两个属性,LargeImageList和SmallImageList)
编辑(发现我尝试时有效的新信息):
这个版本使用插值来获得较小的拇指,应该更好。
You have to use 2 imagelists, one for smallimages and one for largeimages to get the best result I think. (The listview has two properties, LargeImageList and SmallImageList)
Edit (found new information that worked when I tried):
This version are using interpolation to get the smaller thumb, should be better.
通过此代码项目文章和PInvoke.net 上的 ExtractIconEx 演示 您可以编写以下内容:
您必须将 ExtractIconFromExe 的签名更改为
和将代码更改为几行
With this Code Project Article and the Demo of ExtractIconEx on PInvoke.net you can write the following:
you have to change the signature of ExtractIconFromExe to
and change the code a few lines down to
默认情况下,Imagelist ColorDepth 属性设置为 Depth8Bit,将其设置为 Depth32Bit。
By defaut Imagelist ColorDepth property is set to Depth8Bit, set it to Depth32Bit.