ImageList中的图标大小 [英] Icon size in an ImageList
问题描述
同事,
如您所知,.ico文件包含具有不同大小和颜色深度的多个图像.为了在树形视图中显示一个16x16的图标,我找到了一个.ico文件,该文件除其他尺寸外还具有适当的尺寸图像.我有一个ImageList
,其中ImageSize
设置为16x16.在设计时,我已将.ico加载到ImageList
中.但是ImageList
将此图标的PhysicalDimension
显示为32x32(PhysicalDimension
是只读的).看起来ImageList
选择了错误的大小.
解决方法是,我可以提取所需的16x16图像并将其另存为单独的文件(可能采用其他格式).但是,是否有办法使ImageList
从.ico文件中选择正确的大小?
任何建议,见解或参考都将受到赞赏!
-Nick
Colleagues,
As you know, the .ico files contain multiple images with different sizes and color depths. To display a 16x16 icon in my tree view, I found an .ico file which has the appropriate size image among other sizes. I’ve got an ImageList
, with ImageSize
set to 16x16. At design time, I’ve loaded the .ico into the ImageList
. But the ImageList
shows PhysicalDimension
for this icon as 32x32 (PhysicalDimension
is read-only). Looks like ImageList
chose the wrong size.
As a workaround, I can extract the needed 16x16 image and save it as a separate file (may be in a different format). But, is there a way to make ImageList
pick the right size from the .ico file?
Any suggestion, insight or reference is appreciated!
- Nick
推荐答案
类System.Windows.Forms.ImageList
设计用于位图,而不是图标.在使用它的地方(TreeView
的图像等),不需要图标.如果您确实需要图标,则表示您不需要ImageList
;使用名称空间System.Collections.Generic
中您喜欢的任何容器.
—SA
The classSystem.Windows.Forms.ImageList
is designed to be used with bitmaps, not icons. Where it is used (images forTreeView
and the like), icons are not needed. If you really need icons, it means you don''t needImageList
; use any container you prefer from the namespaceSystem.Collections.Generic
.
—SA
这篇关于ImageList中的图标大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!