Icon files (*.ico) may contain multiple images at different sizes and of different colour depths.
图标文件(* .ico)可能包含不同大小和不同颜色深度的多个图像。
How can I obtain a System.Drawing.Image
object from a .ico
file?
如何从.ico文件中获取System.Drawing.Image对象?
One option is Image.FromFile(...)
, but for icon files with multiple images there is no way to specify which image size and colour depth to return.
一个选项是Image.FromFile(...),但对于具有多个图像的图标文件,无法指定要返回的图像大小和颜色深度。
Ideally the solution would use only managed code, but I'm happy to hear about interop calls to Win32 functions as well.
理想情况下,解决方案只使用托管代码,但我很高兴听到有关Win32函数的互操作调用。
3 个解决方案
#2
System.Drawing.Icon can load a specified size from a file. I don't know about depth, though. http://msdn.microsoft.com/en-us/library/ms142130.aspx
System.Drawing.Icon可以从文件加载指定的大小。不过,我不知道深度。 http://msdn.microsoft.com/en-us/library/ms142130.aspx
#3
You will need to use
你需要使用
Dim icon As System.Drawing.Icon
icon = icon.FromHandle(hIcon)
In the hIcon structure you can specify the color depth
在hIcon结构中,您可以指定颜色深度
This links will guide you in the right direction:
此链接将指导您正确的方向:
#1
Simple answer to all your questions: IconLib
简单回答您的所有问题:IconLib
#2
System.Drawing.Icon can load a specified size from a file. I don't know about depth, though. http://msdn.microsoft.com/en-us/library/ms142130.aspx
System.Drawing.Icon可以从文件加载指定的大小。不过,我不知道深度。 http://msdn.microsoft.com/en-us/library/ms142130.aspx
#3
You will need to use
你需要使用
Dim icon As System.Drawing.Icon
icon = icon.FromHandle(hIcon)
In the hIcon structure you can specify the color depth
在hIcon结构中,您可以指定颜色深度
This links will guide you in the right direction:
此链接将指导您正确的方向: