X BitMap


In computer graphics, the X Window System used X BitMap, a plain text binary image format, for storing cursor and icon bitmaps used in the X GUI. The XBM format is superseded by XPM, which first appeared for X11 in 1989.

Format

XBM files differ markedly from most image files in that they take the form of C source files. This means that they can be compiled directly into an application without any preprocessing steps, but it also makes them far larger than their raw pixel data. The image data is encoded as a comma-separated list of byte values, each written in the C hexadecimal notation, '0x13' for example, so that multiple ASCII characters are used to express a single byte of image information.
XBM data consists of a series of static unsigned char arrays containing the monochrome pixel data. When the format was in common use, an XBM typically appeared in headers which featured one array per image stored in the header. The following piece of C code exemplifies an XBM file:

  1. define test_width 16
  2. define test_height 7
static unsigned char test_bits = ;

In place of the usual image-file-format header, XBM files has two or four #define statements. The first two #defines specify the height and width of the bitmap in pixels. The second two, if any, specify the position of any hotspot within the bitmap.
XBM image data consists of a line of pixel values stored in a static array. Because a single bit represents each pixel, each byte in the array contains the information for eight pixels, with the upper left pixel in the bitmap represented by the low bit of the first byte in the array. If the image width does not match a multiple of 8, the extra bits in the last byte of each row are ignored.

Support

Some web browsers support displaying XBM images as a holdover from the early days of the world wide web, when XBM was the minimal non-proprietary image file format. The Arena web browser had full support since version 0.3.34. XBM support was removed from Internet Explorer 6, Mozilla Firefox 3.6, and WebKit-based browsers. There is a strong indication that Chromium does not support XBM. Documentation for Opera 2.12 and 6.0 indicates that XBM was at least previously supported.
Some image viewers/converters, e.g., XnView, FFmpeg and IrfanView, support XBM. A 48×48 XBM can be converted to Ikon and eventually X-Face with Netpbm tools.
Despite having been superseded by the XPM format, XBM is still used by some modern but lightweight window managers like Openbox to define simple button images in a window's title bar, such as the iconify/minimize, restore, and maximize buttons. XBM is also used in embedded processing to display Icons used in GUIs.. ImageMagick supports converting images both to and from XBM. GIMP may be used to create or modify images using the XBM format, and also supports converting images to and from the XBM format.