转换图像在C#中图标 [英] Convert image to icon in c#

查看:143
本文介绍了转换图像在C#中图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有项目转换图像格式的文件转换成图标file.After转换图像的图像颜色改变

I have project convert image format file into icon file.After converting image color of the image changed

下面是我的code

Bitmap theBitmap = new Bitmap(theImage, new Size(width, height));
IntPtr Hicon = theBitmap.GetHicon();// Get an Hicon for myBitmap.
Icon newIcon = Icon.FromHandle(Hicon);// Create a new icon from the handle.
FileStream fs = new FileStream(@"c:\Icon\" + filename + ".ico", FileMode.OpenOrCreate);//Write Icon to File Stream

有人知道如何解决售后服务呢?

Anybody know how to slove this?

推荐答案

Bitmap.GetHicon()是的非常的善于创造了在任何Windows版本,可以运行.NET $ C $做工精良图标C。包括旧的,Windows 98和Windows 2000操作系统的还不支持花哨的图标。

Bitmap.GetHicon() is very good at creating icons that work well on any Windows version that can run .NET code. Including the old ones, Windows 98 and Windows 2000. Operating systems that did not yet support fancy icons.

所以,你得到的是与的只有的16种颜色,使用基本颜色的pre-熟面板的图标。这往往会产生令人失望的结果,说得客气一点。

So what you get is an icon with only 16 colors, using a pre-cooked palette with basic colors. This tends to generate disappointing results, to put it mildly.

该位图或图标类没有一个选项,以获得更好的结果。一般来说,你需要使用一个图标编辑器创造了良好的图标。其中应包括的多个的不同大小和颜色深度图像,因此他们将与任何视频适配器设置,任何操作系统版本工作。特别是从1600万色彩还原至256或16色是用多种方式来做到这一点,他们没有完美的一个不平凡的操作。一个好的图标编辑器具有您所需的工具,使这项工作不够好。

The Bitmap or Icon classes do not have an option to get a better result. In general you'll need to use an icon editor to create good icons. Which should include multiple images in different sizes and color depths so they'll work well with any video adapter setting and any operating system version. Particularly color reduction from 16 million to 256 or 16 colors is a non-trivial operation with multiple ways to do it, none of them perfect. A good icon editor has the tools you need to make that work well enough.

这篇关于转换图像在C#中图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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