X BitMap
{{Short description|File format}}
{{Use dmy dates|date=August 2020}}
{{Infobox file format
| name = X BitMap
| icon =
| extension = .xbm
| screenshot = 240px
| caption = A sample XBM file
| mime = image/x-xbitmap, image/x-xbm.xbm MIME type not [https://www.iana.org/assignments/media-types/media-types.xhtml#image registered] at IANA
| uniform type = public.xbitmap-image{{cite web |url=https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html |title=System-Declared Uniform Type Identifiers |work=Uniform Type Identifiers Reference |publisher=Apple Inc}}
| owner =
| genre = Image file formats
| url =
| containerfor =
| containedby =
| extendedfrom = C (programming language)
| extendedto = X PixMap (XPM)
}}
In computer graphics, the X Window System used X BitMap (XBM), a plain text binary image format, for storing cursor and icon bitmaps used in the X GUI.{{cite web |url=http://kinzler.com/picons/ftp/index.html|title=Picons Archive|author=Steve Kinzler|author-link=Steve Kinzler |year=2005|quote=picons are in either monochrome XBM format or color XPM and GIF formats|access-date=2014-01-06}} The XBM format is superseded by XPM, which first appeared for X11 in 1989.{{cite web |author=Daniel Dardailler|others=Colas Nahaboo and Arnaud Le Hors |date=1996-07-15 |title=The XPM Story |url=http://www.w3.org/People/danield/xpm_story.html |access-date=2014-01-01 |archive-date=2014-01-02 |archive-url=https://web.archive.org/web/20140102193652/http://www.w3.org/People/danield/xpm_story.html |url-status=dead}}
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.{{cite book|title=Encyclopedia of Graphics File Formats, Second Edition|date=April 1996|author1=James D. Murray |author2=William van Ryper |isbn=1-56592-161-5|publisher=O'Reilly |url-access=registration |url=https://archive.org/details/mac_Graphics_File_Formats_Second_Edition_1996|access-date=2014-02-27}}
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 (.h files) which featured one array per image stored in the header. The following piece of C code exemplifies the XBM file Blarg displayed in the panel at right:
- 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 };
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. (In the case of bitmapped cursors, the "hotspot" refers to the position of the cursor "point", generally at 0,0.)
XBM image data consists of a line of pixel values stored in a static array. Because a single bit represents each pixel (0 for white or 1 for black), 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 (25 July 1997).{{cite web |last=QingLong|first=Lu|date=1998-03-24|title=Arena change history|publisher=Yggdrasil Computing |url=http://www.yggdrasil.com/Products/Arena/release/CHANGES.html|access-date=2014-02-27|archive-url=https://web.archive.org/web/20030228182751/http://www.yggdrasil.com/Products/Arena/release/CHANGES.html|archive-date=2003-02-28 }} XBM support was removed from Internet Explorer 6, Mozilla Firefox 3.6,{{cite web|title=504822 – Remove XBM support from Mozilla|url=https://bugzilla.mozilla.org/show_bug.cgi?id=504822|publisher=Mozilla|access-date=2014-10-22 |date=2010-07-12}} and WebKit-based browsers.{{cite web|title=Bug 27823 – Remove XBM support |publisher=WebKit |url=https://bugs.webkit.org/show_bug.cgi?id=27823 |access-date=2014-10-22|date=2010-01-12}} There is a strong indication that Chromium (and therefore, also, Google Chrome) does not support XBM.{{cite web|title=Issue 372898: Chrome displays broken image icon when given direct link to XBM image |website=chromium - An open-source project to help move the web forward |date=2014-06-26 |url=https://code.google.com/p/chromium/issues/detail?id=372898 |access-date=2014-10-22 |url-status=dead |archive-url=https://web.archive.org/web/20141221032447/https://code.google.com/p/chromium/issues/detail?id=372898 |archive-date=2014-12-21}} Documentation for Opera 2.12 and 6.0 indicates that XBM was at least previously supported.{{cite web|title=Opera Software ASA - Opera version history|date=2013-02-05 |url=http://www.opera.com/docs/history/presto/#o2|access-date=2014-10-22|publisher=Opera Software}}{{cite web |publisher=Opera Software |title=Changelog for Opera 6.0 for Unix TP 1 |url=http://www.opera.com/docs/changelogs/unix/600tp1/ |access-date=2014-10-22 |date=2001-11-26}}
Some image viewers/converters, e.g., XnView, FFmpeg and IrfanView, support XBM.{{cite web |url=http://www.ffmpeg.org/general.html#Image-Formats|title=Image Formats|work=FFmpeg General Documentation|year=2014|access-date=2014-02-23}} A 48×48 XBM can be converted to Ikon and eventually X-Face with Netpbm tools.{{cite web|title=Online X-Face Converter|url=http://www.dairiki.org/xface/|author= Jeff Dairiki|access-date=2014-03-02}}
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.{{cite web|title=Openbox Theme Documentation |url=http://openbox.org/wiki/Help:Themes#Button_images |access-date=2014-10-08}} XBM is also used in embedded processing (microControllers) to display Icons used in GUIs.{{cite web|title=U8g2 library reference |url=https://github.com/olikraus/u8g2/wiki/u8g2reference#drawxbm|author= olikraus|website=GitHub |access-date=2017-05-22}} ImageMagick{{cite web|title=Convert Images Between Formats via the Command Line in Ubuntu |author=Aseem Kishore |date=8 May 2010 |url=http://helpdeskgeek.com/linux-tips/convert-images-between-formats-via-the-command-line-in-ubuntu/ |access-date=2017-05-22}} 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.