HOME

TheInfoList



OR:

X PixMap (XPM) is an
image file format An Image file format is a file format for a digital image. There are many formats that can be used, such as JPEG, PNG, and GIF. Most formats up until 2022 were for storing 2D images, not 3D ones. The data stored in an image file format may be ...
used by the
X Window System The X Window System (X11, or simply X) is a windowing system for bitmap displays, common on Unix-like operating systems. X provides the basic framework for a GUI environment: drawing and moving windows on the display device and interacting wi ...
, created in 1989 by Daniel Dardailler and Colas Nahaboo working at Bull Research Center at
Sophia Antipolis (wisdom), gr, (Ἀντίπολις, antipolis) ("opposite city" from its position on the opposite side of the Var estuary from Nice, also former name of Antibes, part of the technology park) , postal_code = 06220 (Vallauris), 06250 (Mo ...
, France, and later enhanced by Arnaud Le Hors. It is intended primarily for creating
icon An icon () is a religious work of art, most commonly a painting, in the cultures of the Eastern Orthodox, Oriental Orthodox, and Catholic churches. They are not simply artworks; "an icon is a sacred image used in religious devotion". The most ...
pixmaps, and supports transparent pixels. Derived from the earlier
XBM 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. The XBM format is superseded by XPM, which first appeared for X11 in 1989. Format XBM fil ...
syntax, it is a
plain text In computing, plain text is a loose term for data (e.g. file contents) that represent only characters of readable material but not its graphical representation nor other objects (floating-point numbers, images, etc.). It may also include a limit ...
file in the XPM2 format or of a C programming language syntax, which can be included in a C program file.


History


XPM1

The first (1989) XPM format is relatively similar to the XBM format. Compared to XBM, it uses additional macro definitions and variables for indexed colors, and replaces bits with characters for describing the image. The following is a black-and-white image in the 1989 XPM format. #define XFACE_format 1 #define XFACE_width 48 #define XFACE_height 48 #define XFACE_ncolors 2 #define XFACE_chars_per_pixel 1 static char *XFACE_colors[] = ; static char *XFACE_pixels[] = { "abaabaababaaabaabababaabaabaababaabaaababaabaaab", // and so on for 48 rows with 48 pixels


XPM2

XPM2 (1990) simplifies the format by removing all C code. The structure is simplified to
! XPM2




* The value section describes the overall dimension of the image similar to the #define statements. * The color section defines the values, and a new concept of the "type" of the color. The types may be c for "color", m for "monochrome" output, g for "grayscale", and s for "symbolic", explaining what a defined color is supposed to do. * The pixels and optional extensions remain as in the original format. The above file, with width 48, height 4, 2 colors, and 1 character per pixel, becomes:
! XPM2
48 4 2 1
a c #FFFFFF
b c #000000
abaabaababaaabaabababaabaabaababaabaaababaabaaab
abaabaababaaabaabababaabaabaababaabaaababaabaaab
abaabaababaaabaabababaabaabaababaabaaababaabaaab
abaabaababaaabaabababaabaabaababaabaaababaabaaab


Colors

In addition to hexcodes, the colors can be any of the
X11 color names In computing, on the X Window System, X11 color names are represented in a simple text file, which maps certain strings to RGB color values. It was traditionally shipped with every X11 installation, hence the name, and is usually located in ''< ...
. In addition, None indicates transparency. The "symbolic" feature permits adjusting colors depending on the context where they are used. Code such as s border c blue could be adjusted on a blue background.


Many-color encoding

One tool is known to use only a to p for 16 colors, switching to aa up to dp for 64 colors, but still reading single character encodings for 64 colors; compare
Base64 In computer programming, Base64 is a group of binary-to-text encoding schemes that represent binary data (more specifically, a sequence of 8-bit bytes) in sequences of 24 bits that can be represented by four 6-bit Base64 digits. Common to all bina ...
. With more colors the codes use more characters, e.g. aa up to pp for 16 × 16 = 256 colors. This is less useful for text editors, because a string ab could be actually the middle of two adjacent pixels dabc. Spaces are allowed as color code, but might be a bad idea depending on the used text editor. Without control codes, backslash, and quote (needed in XPM1 and XPM3) 128 − 33 − 2 = 93
ASCII ASCII ( ), abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices. Because ...
characters are available for single character color codes. Simplified example: 90 US-ASCII characters could be arranged into nine non-overlapping sets of 10 characters. Thus unambiguous strings of nine characters could set the color of each pixel by its XPM palette index with up to 109 = colors (compare to GIF, which supports only 256). For XPM2 it is clear how many lines belong to the image – two header lines, the second header line announcing the number of color codes (2 lines in the example above) and rows (height 4 in the example above), e.g. 2 + 2 + 4 = 8 lines.


XPM3

The current and last format is XPM3 (1991). It re-introduces the C wrapper, but instead of explicitly showing a file's structure, the strings stored are essentially identical to XPM2. /* XPM */ static char * XFACE[] = { "48 4 2 1", "a c #ffffff", "b c #000000", "abaabaababaaabaabababaabaabaababaabaaababaabaaab", "abaabaababaaabaabababaabaabaababaabaaababaabaaab", "abaabaababaaabaabababaabaabaababaabaaababaabaaab", "abaabaababaaabaabababaabaabaababaabaaababaabaaab" }; If the "values" line contains six instead of four numbers, the additional values indicate the coordinates of a "hotspot", where 0 0 is the upper left corner of a box containing the icon and the default. A "hotspot" is used for mouse pointers and similar applications.


Comparison with other formats

The following code displays the same blarg file in the
XBM 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. The XBM format is superseded by XPM, which first appeared for X11 in 1989. Format XBM fil ...
, XPM and PBM formats. XBM version: #define test_width 16 #define test_height 7 static char test_bits[] = { 0x13, 0x00, 0x15, 0x00, 0x93, 0xcd, 0x55, 0xa5, 0x93, 0xc5, 0x00, 0x80, 0x00, 0x60 }; XPM2 version:
! XPM2
16 7 2 1
* c #000000
. c #ffffff
**..*...........
*.*.*...........
**..*..**.**..**
*.*.*.*.*.*..*.*
**..*..**.*...**
...............*
.............**.
XPM3 version: /* XPM */ static char * blarg_xpm[] = { "16 7 2 1", "* c #000000", ". c #ffffff", "**..*...........", "*.*.*...........", "**..*..**.**..**", "*.*.*.*.*.*..*.*", "**..*..**.*...**", "...............*", ".............**." }; PBM file:
P1
16 7
1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0
1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0
1 1 0 0 1 0 0 1 1 0 1 1 0 0 1 1
1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1
1 1 0 0 1 0 0 1 1 0 1 0 0 0 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0


Application support

ACDSee ACDSee is an image organizer, viewer, and image editor program for Windows, macOS and iOS, developed by ACD Systems International Inc. ACDSee was originally distributed as a 16-bit application for Windows 3.0 and later supplanted by a 32-bit ...
, Amaya, CorelDRAW, GIMP,
ImageMagick ImageMagick, invoked from the command line as magick, is a free and open-source cross-platform software suite for displaying, creating, converting, modifying, and editing raster images. Created in 1987 by John Cristy, it can read and write ov ...
,
IrfanView IrfanView () is an image viewer, editor, organiser and converter program for Microsoft Windows. It can also play video and audio files, and has some image creation and painting capabilities. IrfanView is free for non-commercial use; commercial u ...
(formats plugin),
PaintShop Pro PaintShop Pro (PSP) is a raster and vector graphics editor for Microsoft Windows. It was originally published by Jasc Software. In October 2004, Corel purchased Jasc Software and the distribution rights to Paint Shop Pro. PSP functionality can b ...
,
PMView PMView is a raster graphics image viewer, converter, and organizer with basic image editing capabilities. It was originally developed for OS/2 but is also available for Microsoft Windows. What it is and what it does PMView reads and writes an ...
,
Photoshop Adobe Photoshop is a raster graphics editor developed and published by Adobe Inc. for Windows and macOS. It was originally created in 1988 by Thomas and John Knoll. Since then, the software has become the industry standard not only in raster ...
(plugins), and
XnView XnView is an image organizer and general-purpose file manager used for viewing, converting, organizing and editing raster images, as well as general purpose file management. It comes with built-in hex inspection, batch renaming and screen ...
among others support XPM.
Gravatar Gravatar (a portmanteau of ''globally recognized avatar'') is a service for providing globally unique avatars and was created by Tom Preston-Werner. Since 2007, it has been owned by Automattic, having integrated it into their WordPress.com blog ...
and picons also support XPM. An
X11 The X Window System (X11, or simply X) is a windowing system for bitmap displays, common on Unix-like operating systems. X provides the basic framework for a GUI environment: drawing and moving windows on the display device and interacting wi ...
libXpm
vulnerability Vulnerability refers to "the quality or state of being exposed to the possibility of being attacked or harmed, either physically or emotionally." A window of vulnerability (WOV) is a time frame within which defensive measures are diminished, com ...
was fixed in 2005.
FFmpeg FFmpeg is a free and open-source software project consisting of a suite of libraries and programs for handling video, audio, and other multimedia files and streams. At its core is the command-line ffmpeg tool itself, designed for processing of vid ...
version 3.3 or later can decode XPM.


Notes


References


See also

*
X Window System The X Window System (X11, or simply X) is a windowing system for bitmap displays, common on Unix-like operating systems. X provides the basic framework for a GUI environment: drawing and moving windows on the display device and interacting wi ...
(X11) and
X11 color names In computing, on the X Window System, X11 color names are represented in a simple text file, which maps certain strings to RGB color values. It was traditionally shipped with every X11 installation, hence the name, and is usually located in ''< ...
* PBM (mono), PGM (grayscale), PPM (color), PNM (any) {{DEFAULTSORT:X Pixmap Graphics file formats X Window System Computer-related introductions in 1989