将图像转换为 .ICO 文件而不丢失颜色深度(并且无需安装其他实用程序)?
在表单中,我有一个名为 MainLogoImageList
的 ImageList
,其中包含 100x100 像素 32 位色深图像。这是我的应用程序徽标。
我懒得设置图标编辑器并编辑该徽标的图标,或将图像转换为 .ICO 文件。 (呃,好吧,我不允许安装自定义实用程序。)
为了设置表单的图标,我
Icon = IconFromImage(MainLogoImageList.Images(0))
在 OnLoad
事件处理程序中使用来设置窗口图标。
在我的“关于”框中,我有一个没有图像的 PictureBox
。在其 OnLoad
事件中,我用来
LogoPictureBox.Image = MyMainForm.MainLogoImageList.Images(0)
Icon = IconFromImage(MyMainForm.MainLogoImageList.Images(0))
设置“关于”框的图标和内容。
到目前为止,一切顺利,该图标对于从 100x100 像素位图创建的图标来说看起来相当不错。
有没有一种简单的“不需要实用程序”:-) 方法来获取返回的图标,将我的 IconFromImage
保存到 .ICO 文件中,以便在加载时保持颜色深度应用程序图标? 我想完全使用 IconFromImage
创建的图标。
保存它
Dim S As New FileStream("MyAppIcon.ico", FileMode.Append, FileAccess.Write, FileShare.Write)
Icon.Save(S)
S.Close()
使用主窗体的 OnLoad 事件处理程序
,并将该 .ICO 文件作为应用程序图标加载到 VS 的项目属性对话框中,生成的图标显然会转换为 16 种颜色,而且看起来很糟糕。这是 VB 10 Express。
In a form I have an ImageList
named MainLogoImageList
containing a 100x100 pixel 32-bit colordepth image. That is my app logo.
I am too lazy to set up an icon editor and edit an icon of that logo, or convert the image to an .ICO file. (Ergh, well, I am not allowed to install custom utilities.)
To set my forms' icon, I use
Icon = IconFromImage(MainLogoImageList.Images(0))
in the OnLoad
event handler to set the window icon.
In my about box, i have a PictureBox
with no image. In its OnLoad
event, I use
LogoPictureBox.Image = MyMainForm.MainLogoImageList.Images(0)
Icon = IconFromImage(MyMainForm.MainLogoImageList.Images(0))
to set the About box's icon and content.
So far, so good, the icon looks pretty good for a being created from a 100x100 pixel bitmap.
Is there an easy "no utility required" :-) way to get the icon that is returned my IconFromImage
saved into an .ICO file so that it will keep the color depth when loaded as the app icon? I want to use exactly the icon that IconFromImage
creates.
Saving it using
Dim S As New FileStream("MyAppIcon.ico", FileMode.Append, FileAccess.Write, FileShare.Write)
Icon.Save(S)
S.Close()
in the main form's OnLoad
event handler and loading that .ICO file as the app icon in VS's project properties dialog yields and icon that is obviously converted to 16 colors, and looks awful.
This is VB 10 Express.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
遵循明智的建议将其带回家,在那里进行编辑和转换。
工作中的 Gimp@home。
做工很好,看起来很棒。
无代码解决方案比没有解决方案好:-)
Followed the wise advide to take this home, edit and convert it there.
Gimp@home at work.
Worked fine, looks great.
A codeless solution is better than no solution at all :-)