得到充分利用的质量和Icon.ExtractAssociatedIcon的ImageList 16×16的图标 [英] Get full quality 16 x 16 icon using Icon.ExtractAssociatedIcon and ImageList

查看:486
本文介绍了得到充分利用的质量和Icon.ExtractAssociatedIcon的ImageList 16×16的图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题,我有一些$ C $ ç运行,从文件中提取图标和在ListView设置为详细信息模式显示。我要图标显示为16×16,但是当我在ImageList大小设置为出来的图标看起来非常怪异(不知道怎么形容它 - 见附件截图)

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).

我试着改变大小为32×32就出来罚款,但肯定必须有一种方式来获得良好的质量16×16的图标绝不能有?

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?

推荐答案

您必须使用2图像列表,一个用于smallimages,一个用于largeimages,以获得最好的结果,我认为。 (列表视图有两个属性,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.

    Dim BigIcon As Icon = Nothing
    BigIcon = Icon.ExtractAssociatedIcon("c:\zebra.zip")
    Dim largeimages As New ImageList
    Dim smallimages As New ImageList

    largeimages.Images.Add("1", BigIcon)

    'Fix a smaller version with interpolation
    Dim bm As New Bitmap(BigIcon.ToBitmap)
    Dim thumb As New Bitmap(16, 16)
    Dim g As Graphics = Graphics.FromImage(thumb)
    g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
    g.DrawImage(bm, New Rectangle(0, 0, 16, 16), New Rectangle(0, 0, bm.Width, bm.Height), GraphicsUnit.Pixel)
    g.Dispose()
    bm.Dispose()
    smallimages.Images.Add("1", thumb)
    ListView1.SmallImageList = smallimages
    ListView1.LargeImageList = largeimages
    thumb.Dispose()
    ListView1.Items.Add("Test", "Test", "1")

这篇关于得到充分利用的质量和Icon.ExtractAssociatedIcon的ImageList 16×16的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆