Home
Email
Butnz!

Convert Windows Icons to GIFs

If you're like me, you're always frustrated that you have a heap of cool little Windows icon files that you downloaded from the web, but the programs you have to convert them to .gif for use in Java programs are next to useless. On the other hand, you might have a better program to convert them than I do. Anyway, I got sick of it and wrote a Java class to read a Windows .ico file and be done with it. This doesn't mean that your web server will know how to handle .ico files, but at least you could convert them to .gif (which is smaller anyway) and store the .gif files with your applet.

WARNING: This code uses the ACME GifEncoder class. You have to obtain and install the ACME stuff separately from here. Ico2Gif won't compile without it, but ShowIcon will, so you can use this code to produce java.awt.Images from .ico files even if you don't have the ACME stuff. I must say, ACME's classes were about the first that I have downloaded from the web that just worked without problems.

Download ico2gif.zip 12.4K. This file contains:

IconEntry.java, BitmapHeader.java, RGBQuad.java
Classes representing various parts of the structure of .ico files. The bitmap header is the same as in .BMP files, but I haven't yet written a .BMP parser.
WinInputStream.java extends DataInputStream
An input stream with methods to read some types commonly used in Windows.
IconFile.java, WinIcon.java
IconFile represents a file containing icons, and WinIcon repesents a single icon image within that file. A .ICO file can contain multiple images, so IconFile has a member which is a Vector of WinIcon objects. WinIcon implements several types of paint routine, and also can produce an Image and an ImageProducer.
ShowIcon.java, IconCanvas.java
Test program to demonstrate the easiest way to read a .ICO and display it as an image.
Ico2Gif.java
The .ICO to .GIF conversion program. It will convert all .ICOs in the current directory to .GIFs.
ExtensionFilter.java implements FilenameFilter
Used by Ico2Gif. You give this class a list of file extensions, and you can use it as a filename filter to list only particular files that you want.
Some .ico files which can be converted to these GIFs:
Libraries of Icons I can't remember if all of these actually provide .ico files.

This page hosted by Get your own Free Home Page.
This page uses Verdana fonts which Windows users can download from Microsoft for free.
Background pattern by Net Creations.
Wizard image from Caboodles.

Friendless 1