Module xpm

Module xpm 

Source
Expand description

Decoding of XPM Images

XPM (X PixMap) Format is a plain text image format, originally designed to store cursor and icon data. XPM images are valid C code.

(This format is obsolete and nobody should make new images in it. If you need to include an image in a C program, use xxd -i or #embed.)

The XPM format allows for encoding an image which can be expressed differently depending on the display capabilities (X11 visual), providing specialized versions for color, grayscale, black and white, etc. output in the same image. In practice, most XPM images created after the mid 1990s only provide a variant for the color visual. As a result, this decoder implementation only outputs the color version of the input image.

A number of features of the original libXpm are not supported (because they appear to very rarely have been used):

  • XPMEXT extensions
  • HSV color specifications
  • Output for non-color visuals
  • More relaxed header comment parsing (allowing different whitespace around XPM in /* XPM */)
  • Loading with a different color table

This is a somewhat strict decoder and will reject many broken image files, including:

  • those using the XPM2 header or static char ** name = { array string
  • those missing a trailing “,” on lines, or which use “;” instead of “,”
  • those with color data lines that are too long
  • those which have content after the final semicolon which is not a C comment

Note: color values for the X11 color name table were changed for the X11R4 release in Dec 1989; since then there have only been additions.

This overlaps with XPM version development: XPMv1 in Feb 1989, XPMv2 in Feb-August 1990, and XPMv3 in April 1991. Therefore, if you do see an ancient XPMv1 or XPMv2 file somewhere, it may be using different color name values.

This decoder uses the X11 color name table as of X11R6 (May 1994); the only additions since then, in 2014 to add some CSS color names, are not included, to preserve compatibility with other XPM parsers.

Structs§

XpmDecoder
XPM decoder