X PixMap

Template: Infobox file format / Maintenance / Magic number is missing template: Infobox file format / Maintenance / default missing template: Infobox file format / Maintenance / missing site

X PixMap ( XPM ) is an ASCII text format for the display of raster graphics, mainly icons.

The first version of XPM dates from 1989 and was written by Daniel Dardailler and Colas Nahaboo (also author of the GWM window manager for the X Window System), who both worked at the French INRIA. Later, the format of Arnaud Le Hors been extended. The intention behind the format is to display colored icons on the computer. The structure of the data format is simple and similar to the older monochrome XBM format. The graphics consist of plain text files; they can be edited with a simple text editor and, like XBM files included directly in C source code.

Example

The following example demonstrates the syntax of the XPM format by a red octagon on a transparent background, which is covered by a blue horizontal bar.

/ * XPM * / static char * XPM_example [] = { " 24 20 3 1 12 10 XPMEXT " "C None", ". C # 0000FF " " C # FF0000 " " " ".." ".... " "...... ", "......... ", "...... ", "............ ", " ............. ", " .............. ", " ............. ", " ............. ' " ............. ' " ............. ' " .............. ' " ............", " ........... " " ......... " " ....... " " ..... ", " ...", " XPMEXT author Anonymous " " XPMEXT address", " Beispielweg 42a " " 0815 as city " " Lummerland " " mailto: [email protected] " " XPMENDEXT " }; format Description

A XPM file consists of seven parts:

The format is defined as a file XPM is always valid C source code. This can be integrated via # include directives directly into C programs XPM files.

Since most programs process the XPM files, do not have full-fledged parser for C source code, you should keep strictly in generating XPM files to the format described in the format specification.

The following on the declaration line lines consist of C- string constants, respectively. This means, its contents are enclosed in double quotation marks ASCII and separated by commas.

Header

The header consists of a C- comment / * XPM * /. This serves as a magic number to identify XPM files.

Declaration line

The next line is the so-called declaration line, which is a variable declaration in C. The variable name can be arbitrary, it must be a valid C identifier. Typically, this is the name of the image file is used:

Static char *'' picture '' name [] = { Value line

The value line contains four or six decimal numbers with the following meanings:

The last two numbers indicate the position of a so-called "hotspots" to. This is about mouse cursors at the point at which the mouse pointer "points". With normal images, this value is not needed and can be omitted.

Does the XPM file extensions ( engl. extensions ), it follows in the last number of the value line the word XPMEXT.

Color definitions

Then follow several lines, each defining a color in the image. The number of said color definition is apparent from the third row of the values ​​.

Each color definition consists of a character code. The length of the character codes can be seen from the fourth value of the value line. By a space followed by one or a plurality of color definitions which assign a color to the character code. As a result of the original purpose of the XPM file format for icons, different color definitions can be specified for different types of representation. This has the advantage that the appearance of different color depths can be optimized, and does not need to be calculated, a black and white representation of a color display.

The following display types are supported:

This indication is then followed by the actual color definition. This may consist of a symbolic name (eg, " white", "red " ), a color in the RGB color space as hexadecimal color definition (# RRGGBB ) or in the HSV color space (% HHSSVV ). If a color be marked as "transparent" as the color to " None" is set.

Example:

" A c m red black g gray50 s foreground", "B c yellow m white g s background gray80 " " C # m black black g s gray10 border", image data

After the color definitions, the image data follows. These are line-wise from top to bottom, are stored in a row from left to right. Each image line is stored in a text line in the XPM file. One or more characters used - is per pixel - depending on the value specified above. This notation has the consequence that ease of images already seen in the source code, see ASCII art.

Extensions

Unless the value line presence has been indicated by extensions, followed by the image data extension lines, which always have the following format:

  • Single-line extension data:
  • Multi-line extension data:

It is not specified how the end ofR multiline extension data should be marked.

The XPM specification recommends to avoid name collisions start to let the name of the extension with the company name. However, it leaves open how it should look like in detail.

The end of the entire expansion - block is indicated by a line that has XPMENDEXT only the contents.

End of file

To complete the C declaration is shown at the end of the file a line containing the string };.

Practical limitations

Since most programs that can handle XPM files, no complete C parser are, should programs that generate XPM files that do not deviate from this specification which make particular no other formatting of the " source code " and no C-style comments (except Add the mandatory header) or the like.

Also, many programs do not understand the complex color definitions, but mastered by only a representation or ignore this information completely and evaluate only the color code, and also only understand RGB hexadecimal color codes and " None" for the transparent color.

The character codes with which a color is coded to consist, of any ASCII characters. However, it is recommended to take only letters, numbers and some " safe" characters, which can be represented approximately 70 to 80 different colors. Contains an image more colors must be based on character codes, which consist of two characters, be dodged. Though the XPM specification provides for no maximum length of the character codes, you should use a maximum of two-character character codes, which up to 80.80 = 6400 colors permits because some programs can not otherwise read the XPM file. some programs also refuse to load more than to read 256 color definitions, or they create when you save a color table with a maximum of 256 colors, although the XPM format allows greater color tables.

The XPM specification does not provide information about what should be the content in the expand - rows; it does not define any extensions. Therefore, they are practically not used and most of the programs that do not use the libxpm to read XPM files, they do not understand.

Swell

  • Graphic format
18420
de