« August 2008 | Main

January 2009 Archives

January 16, 2009

"Image format is unrecognized" when setting WPF Window Icon

Vista allows embedding 256x256 png images inside of .ico files. This can be generated, for example, by an application such as IcoFX. Unfortunately, at least as of .NET 3.0, the WPF Window Icon cannot accept this. The problem does not lie in the IconBitmapDecoder, but appears to lie in the Window code. To set the Icon property in code, we can do the following:

IconBitmapDecoder ibd = new IconBitmapDecoder(s, BitmapCreateOptions.None, BitmapCacheOption.Default);
this.Icon = ibd.Frames[0];

Where "s" is your .ico stream. If you have a Vista-style .ico file, setting Icon will trigger the "image format is unrecognized" error. The only way to resolve this is to generate the .ico without the Vista images*.

donotcompress.png

Now, take a cleansing breath, smile, and get back to work.

*MSDN discussion.

Andale in Palo Alto is closing...

I had a scrumptious Baja Fish burrito at Andale in Palo Alto... and it may be the last one I ever have. As my friend approached the counter and presented his stamp card, the lady at the counter muttered, "we'll be closed on Sunday".

"Oh, you mean, you'll be closed on Sundays from now on?"

"No, we will be closed on Sunday."

Sign of the times...

About January 2009

This page contains all entries posted to Tim's Journal in January 2009. They are listed from oldest to newest.

August 2008 is the previous archive.

Many more can be found on the main index page or by looking through the archives.

Creative Commons License
This weblog is licensed under a Creative Commons License.
Powered by
Movable Type 3.35