Icon.ExtractAssociatedIcon 函数的质量较差
我尝试从 exe 中获取图标,我在其中使用了以下代码片段
C#
FileStream fs = new FileStream(icoFileNam, FileMode.OpenOrCreate);
Icon ico = Icon.ExtractAssociatedIcon(exefilePath);
ico.Save(fs);
保存的图像缺乏质量。我已将图像保存为 .ico 文件。
谁能知道如何保留 exe 文件中图标的原始质量?
I try to fetch the icon from an exe, where I have used the below snippet
C#
FileStream fs = new FileStream(icoFileNam, FileMode.OpenOrCreate);
Icon ico = Icon.ExtractAssociatedIcon(exefilePath);
ico.Save(fs);
The image saved lacks quality. I have saved the image as .ico file.
Can anyone knows how to retain the original quality of the icon present in the exefile?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在最常见的情况下,您可以通过 Icon.ToBitmap() 方法。您可以将此图像保存为不同的格式。然而,将图标保存为 "true" .ico 文件。
问题是 .Net 中没有用于图标图像的嵌入式编码器。因此默认情况下结果已保存为低颜色图像。如果这是不可接受的,建议 MS 将原始位图数据手动保存为 .ico。我建议您使用已经实现此任务的 IconLib 库:
In the most common cases you can use the extracted icon bitmap data via the Icon.ToBitmap() method. You can save this image to different formats. However it is pretty hard to save the icon as "true" .ico file.
The problem is that there are no embedded encoders for icon images in .Net. So by default the result have been saved as low-color image. If this is unacceptable, the MS is recommended to save raw bitmap data as .ico manually. I suggest you use the IconLib library that already implement this task: