Introduction
XBM is the black and white image format of the X Window System, used for icons,
cursors and fill patterns on Unix desktops. An XBM file is a piece of C source code,
so a program can #include it and get the image as an array of bytes,
with no image loader at all.
Each pixel is one bit, set or clear, so there are no colours. Colour icons in X use the related XPM format. Early web browsers could show XBM images, but modern ones no longer do.
Structure
The file defines the width and height as C macros, then an array of bytes with the
pixels. The macro names start with the image name. Two optional macros,
_x_hot and _y_hot, give the hotspot of a cursor.
#define arrow_width 16
#define arrow_height 16
static unsigned char arrow_bits[] = {
0x00, 0x00, 0x02, 0x00, 0x06, 0x00, …
};
Pixels are stored row by row from the top. Each row is padded to a whole number of
bytes, and within each byte the leftmost pixel is the lowest bit. A set bit is a
foreground pixel. Old X10 files use an array of 16-bit short values
instead of bytes.
Links
Software
- GIMP (Windows, macOS, Linux)
- ImageMagick (Windows, macOS, Linux)
- bitmap, the X Window System bitmap editor (Linux, Unix)
Developers
- libX11, C, reads and writes XBM with
XReadBitmapFileandXWriteBitmapFile