What is XBM? X BitMap Format Explained
A monochrome X Window System bitmap format stored as compilable C source code.
Last updated:
What is XBM?
XBM (X BitMap) is a monochrome image format used by the X Window System to store simple bitmaps such as icons and cursors. Its defining characteristic is that an XBM file is plain C source code rather than a conventional binary image file.
An XBM file consists of #define statements giving the width and height in pixels, followed by a static array of unsigned char values holding the 1-bit pixel data. Each byte encodes eight pixels, with the upper-left pixel in the low bit of the first byte. Because it is valid C, an XBM bitmap can be compiled directly into an application.
How XBM Works
An XBM file is plain C source code: it declares the image's width and height with #define statements and stores the 1-bit pixel data as a static array of unsigned char values.[1] Each byte holds eight pixels, with the upper-left pixel in the low bit of the first byte, so the bitmap can be compiled directly into a program.[1]
History and Context
XBM was created for the X Window System to store monochrome assets such as icons and cursors, and its source-code form let early X applications embed bitmaps without a separate image loader.[1]
XBM vs XPM
The later XPM format extended the same C-source idea to color and transparency by adding a character-to-color table, addressing XBM's strictly black-and-white limitation.[2] XBM remains far more compact per pixel but is confined to two-color images, making it suitable only for simple line art and masks.[1]
MKV Technical Specifications
XBM vs Other Image Formats
| Feature | XBM | PNG | GIF |
|---|---|---|---|
| Type | Raster | Raster | Raster |
| Color depth | 1-bit (monochrome)[1] | Up to 16-bit | 8-bit palette |
| Encoding | C source code[1] | Binary | Binary |
| Compression | None[1] | Lossless | Lossless (LZW) |
| Transparency | No | Yes | Yes (1-bit) |
| Best for | X11 bitmaps/icons[1] | Web graphics | Simple animation |
XBM stores monochrome bitmaps as compilable C arrays for the X Window System, a niche role unlike the general-purpose PNG and GIF.
Advantages & Disadvantages
Advantages
Because an XBM file is C source, the bitmap can be #included and compiled straight into an application with no separate loader.
The plain-text array can be inspected and edited in any text editor, which is convenient for tiny icons.
With just width/height defines and a byte array, XBM is trivial to generate and parse programmatically.
For small monochrome icons and cursors, XBM is a compact and dependency-free way to embed images.
Disadvantages
XBM stores only 1-bit black-and-white pixels, with no support for grayscale or color.
Encoding each byte as ASCII C hexadecimal makes files far larger than the raw pixel data they represent.
XBM was superseded by XPM for color, and is now used mainly for simple UI elements in lightweight window managers.
Common Use Cases
XBM is used for small monochrome graphics within the X Window System and similar contexts.
X Window icons and cursors | FileFormer
XBM was the original format for cursor and icon bitmaps in the X GUI environment.
Embedded UI button images | FileFormer
Lightweight window managers such as Openbox still use XBM to define simple title-bar buttons like minimize and maximize.
Compiled-in graphics | FileFormer
Developers embed small monochrome bitmaps directly into C programs by including XBM source files.
Convert XBM Files Free
Use our free online converter to convert XBM and other formats - no signup, no watermarks.
Try Image Converter FreeFrequently Asked Questions
Why is an XBM file C source code?
XBM was designed so bitmaps could be compiled directly into X applications; the file is a #define and a static unsigned char array.
Does XBM support color?
No. XBM is strictly 1-bit monochrome; the color equivalent in the X Window System is XPM.
How are pixels stored in XBM?
Each byte holds eight pixels, with the upper-left pixel in the low bit of the first byte of the array.
Is XBM still used today?
Rarely for general images, but some lightweight window managers still use XBM for simple button and decoration bitmaps.
What is the difference between XBM and XPM?
XBM stores 1-bit monochrome bitmaps, while XPM (X PixMap) extends the idea to color images with transparency.