ArticleslgStudy

computer science

X PixMap

X PixMap is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand X PixMap rather than just read about it. In short: 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. It is intended primarily for creating icon pixmaps, and supports transparent pixels.

X PixMap — main illustration
X PixMap — illustration

Key takeaways

  • X PixMap belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect X PixMap to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of X PixMap from memory before moving on to harder problems.

Reference excerpt

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. 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.

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.

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

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

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 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. 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.

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, XPM and PBM formats. XBM version:

XPM2 version:

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

XPM3 version:

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. Gravatar also supports XPM. An X11 libXpm vulnerability was fixed in 2005, and three more in 2023. FFmpeg version 3.3 or later can decode XPM.

See also Netpbm – Toolkit for manipulation of images CLUT – In computer graphics, a finite set of available colorsPages displaying short descriptions of redirect targets X BitMap – File format

Notes

References

See also X Window System (X11) and X11 color names PBM (mono), PGM (grayscale), PPM (color), PNM (any) X BitMap

External links libXpm - X Pixmap (XPM) image file format library

Illustrations

X PixMap illustration
X PixMap: Blarg file opened in program window
Blarg file opened in program window
X PixMap: Blarg.xpm (XPM2) rendered by XnView
Blarg.xpm (XPM2) rendered by XnView

Worked examples

Example 1 — a first encounter with X PixMap

Start with the simplest possible case. Write down what X PixMap claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to X PixMap before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about X PixMap ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of X PixMap

In research
X PixMap appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses X PixMap in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
X PixMap is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer-related introductions in 1989, Graphics file formats, X Window System, so understanding it makes those chapters shorter.
In everyday life
Look for X PixMap outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “X PixMap” →

How to study X PixMap in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what X PixMap means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain X PixMap out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is X PixMap in simple terms?

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. It is intended primarily for creating icon pixmaps, and supports transparent…

Why does X PixMap matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study X PixMap?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on X PixMap.

Tags

  • Computer-related introductions in 1989
  • Graphics file formats
  • X Window System

Keep exploring