Saturday, November 28, 2009

Write .ICO files [C#]

Greetings. Here's a console application I wrote, which uses the BinaryWriter to create icon files (.ico image file format). It is based on these specifications.
[Note: .NET ImageFormat.Icon doesn't really write .ico files]

You can drag and drop one or more .NET compatible image files over the app icon (equivalent to console arguments).
The program creates a Bitmap of each image, and checks if it is within the 256x256 pixels limit. Then, the Bitmap data is used by the BinaryWriter to create the converted file.

CreateNew mode on the FileStream avoids file overwriting.
Since the app is targeted to run from its' icon, exceptions are shown via MessageBoxes.

No comments:

Post a Comment