This article contains the answers to some Frequently Asked Questions about the XPM format and/or library. If you don't find the answer to your problem here, then you can mail either to lehors@sophia.inria.fr or to the mailing list xpm-talk@sophia.inria.fr.
Netpbm is surely the best image conversion package that I know of. It defines formats for color, gray and monochrome images and provides a set of filters. Thus a GIF image can be converted to XPM with something like:
$ giftoppm youricon.gif | ppmtoxpm > youricon.xpm
The latest release can be found at least from wuarchive.wustl.edu (128.252.135.4), directory /graphics/graphics/packages/NetPBM
There are three official versions of the XPM format. The XPM library since version 3.3 can read all them but writes out only XPM 3. Also the small program called sxpm which is part of the XPM library package can be used to automatically translate XPM 1 and 2 files to XPM 3 with a command such as:
$ sxpm -nod yourxpm1or2file -o yourxpm3file
Also, the XPM format defines "None" to be the color name meaning "transparent", but IXI used to hack the XPM library in its early days to handle transparency as "#Transparent". This makes IXI format not compatible with the official XPM format, and so not readable neither by the official XPM library nor any of the programs built on top of it.
The only solutions are either to stick on IXI programs which can deal with their format or convert your files to the standard XPM format. This can be done simply by changing "#Transparent" to "None".
Be sure the XpmAttributes structure you pass by reference has a valid valuemask. You can give NULL instead if you don't want to use an XpmAttributes but if you do, you MUST initialize its valuemask component to some valid value, at least 0, otherwise unpredictable errors can occur.
So instead of doing something like:
XpmAttributes attrib; XpmReadFileToPixmap(dpy, d, filename, &pixmap, &mask, &attrib);
you should do:
XpmAttributes attrib; attrib.valuemask = 0; XpmReadFileToPixmap(dpy, d, filename, &pixmap, &mask, &attrib);