X BitMap (abbreviated XBM) is a plain-text, monochrome binary image file format used by the X Window System for storing cursor and icon bitmaps in the X graphical user interface (GUI). It uses the filename extension .xbm.
Format
XBM files differ markedly from most image files in that they take the form of C source code. This allows them to be compiled directly into an application without any preprocessing steps, though it also makes them considerably larger than their raw pixel data. The image data is encoded as a comma-separated list of byte values written in C hexadecimal notation (for example, 0x13), so that multiple ASCII characters express a single byte of image information.
An XBM file consists of a series of static unsigned char arrays containing the monochrome pixel data. In place of a conventional image-file header, XBM files contain two or four #define statements. The first two specify the height and width of the bitmap in pixels; the second two, if present, specify the position of any hotspot within the bitmap (for bitmapped cursors, the hotspot is the position of the cursor "point," generally at 0,0).
Because a single bit represents each pixel (0 for white, 1 for black), each byte in the array holds the information for eight pixels, with the upper-left pixel represented by the low bit of the first byte. If the image width is not a multiple of 8, the extra bits in the last byte of each row are ignored.
A typical XBM example is:
#define test_width 16
#define test_height 7
static unsigned char test_bits[] = {
0x13, 0x00, 0x15, 0x00, 0x93, 0xcd, 0x55, 0xa5, 0x93, 0xc5, 0x00, 0x80,
0x00, 0x60 };
Origin and successor
XBM was the minimal non-proprietary image file format supported by some web browsers in the early days of the World Wide Web. The XBM format was superseded by X PixMap (XPM), which first appeared for X11 in 1989.
Support
Some web browsers historically supported XBM images, though support has largely been removed. XBM support was removed from Internet Explorer 6, Mozilla Firefox 3.6, and WebKit-based browsers, and Chromium (and therefore Google Chrome) does not support XBM. Despite being superseded, XBM is still used by some modern but lightweight window managers such as Openbox to define simple button images in a window's title bar, and it remains in use in embedded processing (microcontrollers) to display icons in GUIs. Several image tools support XBM, including XnView, FFmpeg, IrfanView, ImageMagick, GIMP, and the Netpbm toolset.