views:

313

answers:

2

I've written a little system tray application that uses a NotifyIcon to display the status of a process. I'm loading a high quality 64 by 64 png formatted icon in the following way:

Bitmap rawImage = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("Snitch.Icons.Loading.png"));
m_icon.Icon = Icon.FromHandle(rawImage.GetHicon());  

However the icon that appears in the system tray never looks as good as my source icon, is there an setting or something I am missing? I've tried the 16x16, 32x32 eight bit icon files that VS2008 creates but they don't seem to fair any better.

+1  A: 

If you add a NotifyIcon control to your application's Form object, then your application will display an icon in the tray area of the taskbar. The rendered size of the notify icon is the same as for the Control Box and Taskbar icons: 16x16 pixels, potentially stretched to accomodate the height of the system tray, which is dependent on the height of the Taskbar. Oddly, however, Windows does not use the 16x16x256 bitmap for this circumstance; it uses the 32x32x256 bitmap by default, and squashes it down to the required size. I can think of no particularly good reason for this difference--using the 32x32 version for the notify icon, but 16x16 for taskbar and control box--but there it is.

http://www.hhhh.org/cloister/csharp/icons/

Note - the article is from c. 2003

Stuart Dunkeld
I'm using the small icons setting on my task bar so I guess that could be introducing extra distortion.
Danielb
+1  A: 

Consider the quality of a thumbnail image relative to a full-size photograph; now imagine shrinking the entire photo down to 16x16 pixels. The greater the discrepancy between the original size and the new size, the worse the result will look, no matter whether you're shrinking or stretching.

The best thing to do, if you can, is obtain or create an .ico file that actually contains separate 16x16, 32x32, 48x48 and 64x64 icons. The next best thing is probably to use a plain 16x16 icon for the notification area. Any image resizing/resampling is going to look distorted.

There are a number of sites on the web with free or inexpensive downloads of multiple-sized or 16x16 icons. There are already several questions here on where to find icons so I won't try to start listing sites myself.

Aaronaught
I've tried the small icons before (although I drew them) they still seemed to get weird artifacts e.g. a colored circle on a transparent background somehow acquired a partial black outline.
Danielb
@Danielb: For that I'd have to see an example, I can't say I've experienced that particular behaviour.
Aaronaught