Windows 10 NotifyIcon图标总是看起来非常像素化 [英] Windows 10 NotifyIcon Icon always looks very pixilated
问题描述
我无法在Windows 10中制作NotifyIcon,其图标资源看起来不过是一团糟。
这两个图标都来自 SystemIcons
类,或者我自己使用 Properties.Resources
。我已经尝试用图标(Icon original,int width,int height)
构造函数创建一个新的图标实例,以及其他各种疯狂的东西,包括这个块:
Icon ico = Icon.FromHandle((new Icon(Resources.InfoIcon,256,256).ToBitmap())。GetHicon ());
无济于事。任何建议,将不胜感激!
在截图中的可怜的图标很容易解决,你忘了设置
如果您希望自己的图标显示在此通知气球中,那么您必须解决ResourceManager中的限制.GetObject()方法。当你编写Resources.InfoIcon时,你正在使用哪一个。 GetObject()没有足够的参数来选择您喜欢的图标大小。使用此答案中显示的代码。切勿使用GetHicon()顺便说一句,它在调色板映射中做的很差,只能生成一个16色的图标。
I am having trouble making a NotifyIcon in Windows 10 whose icon resource looks anything but a blurry mess.
This happens with both icons from the SystemIcons
class, or my own using Properties.Resources
. I have tried creating a new instance of the icon with the Icon (Icon original, int width, int height)
constructor, and all sorts of other mad things, including this nugget:
Icon ico = Icon.FromHandle((new Icon(Resources.InfoIcon, 256, 256).ToBitmap()).GetHicon());
to no avail. Any advice would be appreciated!
The poor icon in the screenshot is easy to address, you forgot to set the NotifyIcon.BalloonTipIcon property. Or use the NotifyIcon.ShowBalloonTip() method overload that takes ToolTipIcon. With ToolTipIcon.Info
you'll get the high resolution system default icon. For example:
notifyIcon1.ShowBalloonTip(5000, "eDIDIO",
"Connected successfully!", ToolTipIcon.Info);
Which produces:
If you want your own icon to show up in this notification "balloon" then you have to work around a restriction in the ResourceManager.GetObject() method. Which is what you are using when you write "Resources.InfoIcon". GetObject() does not have enough arguments to be selective about the icon size you prefer. Use the code shown in this answer. Never use GetHicon() btw, it does a very poor job at color palette mapping and can only produce a 16 color icon.
这篇关于Windows 10 NotifyIcon图标总是看起来非常像素化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!