XPM2
XPM2 simplifies the format by removing all C idiosyncrasies. An example:
! XPM2 128 128 64 1 z c #f6f6f6 Z c #eeeeee :''etc., palette using '''1''' character codes'' @ c #080808 . c #000000 ............................................This is an XPM2 file with width 128, height 128, 64 colors, using one character per pixel. One tool is known to use only a to p for 16 colors, switching to aa up to dp for 64 colors, but still reading single character encodings for 64 colors; compare Base64.
With more colors the codes use more characters, e.g. aa up to pp for 16*16=256 colors. This is less useful for text editors, because a string ab could be actually the middle of two adjacent pixels dabc. Spaces are allowed as color code, see links, but might be a bad idea depending on the used text editor. Without control codes, space, and quote (needed in XPM1 and XPM3) 128-33-2=93 ASCII characters are available for single character color codes.
For XPM2 it is clear how many lines belong to the image – two header lines, the second header line announcing the number of color codes (64 lines in the example above) and rows (height 128 in the example above), e.g. 2+64+128=194 lines.
The other styles are designed to be used as is in C source code, example:
#define XFACE_format 1 #define XFACE_width 48 #define XFACE_height 48 #define XFACE_ncolors 2 #define XFACE_chars_per_pixel 1 static char *XFACE_colors = { "a", "#ffffff", "b", "#000000" }; static char *XFACE_pixels = { "abaabaababaaabaabababaabaabaababaabaaababaabaaab", // and so on for 48 rows with 48 pixelsRead more about this topic: X PixMap