The XPM
Frequently Asked Questions

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.

Contents

  1. How do I convert my images to or from XPM ?
  2. Why are my XPM files said to be invalid ?
  3. Why does my program core dumps using XPM ?
  4. Why does my program core dumps using XPM with a widget ?
  5. How can I get a non rectangular icon using XPM ?
  6. What exactly triggers the creation of a mask when using XPM ?
  7. How should I use the mask ?
  8. Is there a string to pixmap converter somewhere ?
  9. How can I edit XPM icons ?
  10. Is there a collection of icons somewhere ?
  11. The documentation fails to print out. Why ?
  12. Copyright

1. How do I convert my images to or from XPM ?

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

2. Why are my XPM files said to be invalid ?

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".

3. Why does my program core dumps using XPM ?

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);

4. Why does my program core dumps using XPM with a widget ?