X PixMap

Last updated
X PixMap
Screenshot-xterm-linux.xpm-GVIM.png
Some text editors, for example gvim, can display xpm images in graphical form
Filename extension
.xpm
Internet media type
image/x-xpixmap [1]
Developed byBULL Research
Type of format Image file formats
Extended from XBM
Open format?yes

X PixMap (XPM) is an image file format used by the X Window System, created in 1989 by Daniel Dardailler and Colas Nahaboo working at Bull Research Center at Sophia Antipolis, France, and later enhanced by Arnaud Le Hors. [2] [3]

Contents

It is intended primarily for creating icon pixmaps, and supports transparent pixels. Derived from the earlier XBM syntax, it is a plain text file in the XPM2 format or of a C programming language syntax, which can be included in a C program file. [2]

History

XPM1

The first (1989) XPM format is relatively similar to the XBM format. [lower-alpha 1] 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 1staticchar*XFACE_colors[]={"a","#ffffff","b","#000000"};staticchar*XFACE_pixels[]={"abaabaababaaabaabababaabaabaababaabaaababaabaaab",// and so on for 48 rows with 48 pixels

XPM2

XPM2 (1990) simplifies the format by removing all C code. [lower-alpha 2] [lower-alpha 3] The structure is simplified to

! XPM2 <Values> <Colors> <Pixels> <Optional Extensions> 

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 addition, None indicates transparency. [4] [5]

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.

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 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 = 1000000000 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 */staticchar*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

Blarg file opened in program window Blarg.xbm.png
Blarg file opened in program window

The following code displays the same blarg file in the XBM, XPM and PBM formats.

XBM version:

#define test_width 16#define test_height 7staticchartest_bits[]={0x13,0x00,0x15,0x00,0x93,0xcd,0x55,0xa5,0x93,0xc5,0x00,0x80,0x00,0x60};
Blarg.xpm (XPM2) rendered by XnView Blarg.xpm.png
Blarg.xpm (XPM2) rendered by XnView

XPM2 version:

! XPM2 16 7 2 1 * c #000000 . c #ffffff **..*........... *.*.*........... **..*..**.**..** *.*.*.*.*.*..*.* **..*..**.*...** ...............* .............**. 

XPM3 version:

/* XPM */staticchar*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, Amaya, CorelDRAW, GIMP, ImageMagick, IrfanView (formats plugin), PaintShop Pro, PMView, Photoshop (plugins), and XnView among others support XPM. [6] [7] Gravatar and picons also support XPM. [8] [9]

An X11 libXpm vulnerability was fixed in 2005, [10] and three more in 2023. [11]

FFmpeg version 3.3 or later can decode XPM. [12]

See also

Notes

  1. For a description of this format in lieu of the manual (not found on the Internet), use xpm-contrib (formerly part of libXpm proper) converter (xpm2ppm, xpm1to3, xpm1to2c) source code.
  2. It is also acceptable to use programming language syntaxes for string arrays, but only the C syntax is attested. The "XPM2 C" syntax eventually became the only format in XPM version 3.
  3. For references on this syntax, see https://github.com/freedesktop/libXpm/blob/master/NEWS.old and the "history" section of libXpm 3.4 manual.

Related Research Articles

<span class="mw-page-title-main">GIF</span> Bitmap image file format family

The Graphics Interchange Format is a bitmap image format that was developed by a team at the online services provider CompuServe led by American computer scientist Steve Wilhite and released on June 15, 1987. It is in widespread usage on the World Wide Web due to its wide support and portability between applications and operating systems.

<span class="mw-page-title-main">PNG</span> Family of lossless compression file formats for image files

Portable Network Graphics is a raster-graphics file format that supports lossless data compression. PNG was developed as an improved, non-patented replacement for Graphics Interchange Format (GIF)—unofficially, the initials PNG stood for the recursive acronym "PNG's not GIF".

PCX, standing for PiCture eXchange, was an image file format developed by the now-defunct ZSoft Corporation of Marietta, Georgia, United States. It was the native file format for PC Paintbrush and became one of the first widely accepted DOS imaging standards, although it has since been succeeded by more sophisticated image formats, such as BMP, JPEG, and PNG. PCX files commonly stored palette-indexed images ranging from 2 or 4 colors to 16 and 256 colors, although the format has been extended to record true-color (24-bit) images as well.

Tag Image File Format, abbreviated TIFF or TIF, is an image file format for storing raster graphics images, popular among graphic artists, the publishing industry, and photographers. TIFF is widely supported by scanning, faxing, word processing, optical character recognition, image manipulation, desktop publishing, and page-layout applications. The format was created by the Aldus Corporation for use in desktop publishing. It published the latest version 6.0 in 1992, subsequently updated with an Adobe Systems copyright after the latter acquired Aldus in 1994. Several Aldus or Adobe technical notes have been published with minor extensions to the format, and several specifications have been based on TIFF 6.0, including TIFF/EP, TIFF/IT, TIFF-F and TIFF-FX.

The BMP file format or bitmap, is a raster graphics image file format used to store bitmap digital images, independently of the display device, especially on Microsoft Windows and OS/2 operating systems.

Web colors are colors used in displaying web pages on the World Wide Web, and the methods for describing and specifying those colors. Colors may be specified as an RGB triplet or in hexadecimal format or according to their common English names in some cases. A color tool or other graphics software is often used to generate color values. In some uses, hexadecimal color codes are specified with notation using a leading number sign (#). A color is specified according to the intensity of its red, green and blue components, each represented by eight bits. Thus, there are 24 bits used to specify a web color within the sRGB gamut, and 16,777,216 colors that may be so specified.

<span class="mw-page-title-main">Xfig</span> Vector graphics editor for UNIX-like systems

Xfig is a free and open-source vector graphics editor which runs under the X Window System on most UNIX-compatible platforms.

<span class="mw-page-title-main">Apache Groovy</span> Programming language

Apache Groovy is a Java-syntax-compatible object-oriented programming language for the Java platform. It is both a static and dynamic language with features similar to those of Python, Ruby, and Smalltalk. It can be used as both a programming language and a scripting language for the Java Platform, is compiled to Java virtual machine (JVM) bytecode, and interoperates seamlessly with other Java code and libraries. Groovy uses a curly-bracket syntax similar to Java's. Groovy supports closures, multiline strings, and expressions embedded in strings. Much of Groovy's power lies in its AST transformations, triggered through annotations.

<span class="mw-page-title-main">Smacker video</span> Digital video file format

Smacker video is a video file format developed by RAD Game Tools, and primarily used for full-motion video in video games. Smacker uses an adaptive 8-bit RGB palette. RAD's format for video at higher color depths is Bink Video. The Smacker format specifies a container format, a video compression format, and an audio compression format. Since its release in 1994, Smacker has been used in over 2300 games. Blizzard used this format for the cinematic videos seen in its games Warcraft II, StarCraft and Diablo I.

A FourCC is a sequence of four bytes used to uniquely identify data formats. It originated from the OSType or ResType metadata system used in classic Mac OS and was adopted for the Amiga/Electronic Arts Interchange File Format and derivatives. The idea was later reused to identify compressed data types in QuickTime and DirectShow.

QuickTime Animation format is a video compression format and codec created by Apple Computer to enable playback of RGB video in real time without expensive hardware. It is generally found in the QuickTime container with the FourCC 'rle '. It can perform either lossless or lossy compression and is one of the few video codecs that supports an alpha channel. Supported color depths are 1-bit (monochrome), 15-bit RGB, 24-bit RGB, 32-bit ARGB, as well as palettized RGB. As a result of reverse-engineering of the format, a decoder is implemented in XAnim as well as an encoder and decoder in libavcodec.

<span class="mw-page-title-main">X BitMap</span> File format

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.

<span class="mw-page-title-main">X-Face</span> Bitmap image

An X-Face is a small bitmap image which is added to a Usenet posting or e-mail message, typically showing a picture of the author's face. The image data is included in the posting as encoded text, and attached with an 'X-Face' header. It was devised by James Ashton.

Netpbm is an open-source package of graphics programs and a programming library. It is used mainly in the Unix world, where one can find it included in all major open-source operating system distributions, but also works on Microsoft Windows, macOS, and other operating systems.

In the X Window System, the program xwd captures the content of a screen or of a window and optionally saves it into a file.

Silicon Graphics Image (SGI) or the RGB file format is the native raster graphics file format for Silicon Graphics workstations. The format was invented by Paul Haeberli. It can be run-length encoded (RLE). FFmpeg and ImageMagick, among others, support this format.

In computing, a bitmap is a mapping from some domain to bits. It is also called a bit array or bitmap index.

Apple Video is a lossy video compression and decompression algorithm (codec) developed by Apple Inc. and first released as part of QuickTime 1.0 in 1991. The codec is also known as QuickTime Video, by its FourCC RPZA and the name Road Pizza. When used in the AVI container, the FourCC AZPR is also used.

QuickTime Graphics is a lossy video compression and decompression algorithm (codec) developed by Apple Inc. and first released as part of QuickTime 1.x in the early 1990s. The codec is also known by the name Apple Graphics and its FourCC SMC. The codec operates on 8-bit palettized RGB data. The bit-stream format of QuickTime Graphics has been reverse-engineered and a decoder has been implemented in the projects XAnim and libavcodec.

The Quite OK Image Format (QOI) is a specification for lossless image compression of 24-bit or 32-bit color raster (bitmapped) images, invented by Dominic Szablewski and first announced November 24th 2021.

References

  1. .xpm MIME type not registered at IANA
  2. 1 2 Le Hors, Arnaud (1996-02-01). XPM Manual: The X PixMap Format (PDF). Groupe Bull. pp. 7–8. Retrieved 2014-01-01.
  3. Daniel Dardailler (1996-07-15). "The XPM Story". Colas Nahaboo and Arnaud Le Hors. Archived from the original on 1997-06-07. Retrieved 2014-01-01.
  4. "The XPM FAQ". X.Org Foundation. 1996. Retrieved 2016-03-12.
  5. "XPM File Format Summary" . Encyclopedia of Graphics File Formats, 2nd Edition. ISBN   1-56592-161-5 . Retrieved 2014-01-01.
  6. Nir Sofer. ".xpm Extension" . Retrieved 2014-01-12.
  7. "File Type: X Windows Pixmap". Windows File Association. Microsoft. 2013. Retrieved 2014-01-12.
  8. Gravatar unofficial, no XPM2
  9. Steve Kinzler (2005). "Picons Archive" . Retrieved 2014-01-06. picons are in either monochrome XBM format or color XPM and GIF formats
  10. "libXpm library contains multiple integer overflow vulnerabilities". US-CERT . 2005-10-06. VU#537878. Retrieved 2014-01-01.
  11. "X.Org Security Advisory: Issues handling XPM files in libXpm prior to 3.5.15". 2023-01-17.
  12. "FFmpeg 3.3 "Hilbert"". FFmpeg. 2017-04-13. Retrieved 2017-10-28. XPM decoder

See also