请输入您要查询的百科知识:

 

词条 X PixMap
释义

  1. XPM

  2. XPM2

  3. XPM3

  4. Comparison with other formats

  5. Application support

  6. See also

  7. References

{{Infobox file format
| name = X PixMap
| screenshot =
| caption = Some text editors, for example gvim, can display xpm images in graphical form
| extension = .xpm
| mime = image/x‑xpixmap[1]
| owner = BULL Research
| creatorcode =
| genre = Image file formats
| containerfor =
| containedby =
| extendedfrom = XBM
| extendedto =
| free = 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]

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]

XPM

The XPM format is an array of strings composed of six different sections as follows:

static char* [] = {

};

This is a black-and-white image in the first (1989) XPM format.

  1. define XFACE_format 1
  2. define XFACE_width 48
  3. define XFACE_height 48
  4. define XFACE_ncolors 2
  5. define XFACE_chars_per_pixel 1

static char *XFACE_colors[] = {

"a", "#ffffff",

"b", "#000000"

};

static char *XFACE_pixels[] = {

"abaabaababaaabaabababaabaabaababaabaaababaabaaab",

// and so on for 48 rows with 48 pixels

The values section contains the width, height, number of colors, and number of characters per pixel.

XPM2

XPM2 simplifies the format by removing all C code. An example:

 ! XPM2 48 4 2 1 a c #FFFFFF b c #000000 abaabaababaaabaabababaabaabaababaabaaababaabaaab abaabaababaaabaabababaabaabaababaabaaababaabaaab abaabaababaaabaabababaabaabaababaabaaababaabaaab abaabaababaaabaabababaabaabaababaabaaababaabaaab

This is an XPM2 file with width 48, height 4, 2 colors, and 1 character per pixel.

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 = {{val|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 other styles XPM1 and XPM3 are designed to be used as is in C source code, example:

/* XPM */

static char * XFACE[] = {

/* */

/* */

"48 4 2 1",

/* */

"a c #ffffff",

"b c #000000",

/* */

"abaabaababaaabaabababaabaabaababaabaaababaabaaab",

"abaabaababaaabaabababaabaabaababaabaaababaabaaab",

"abaabaababaaabaabababaabaabaababaabaaababaabaaab",

"abaabaababaaabaabababaabaabaababaabaaababaabaaab"

};

The latter format is XPM3, the common format used for the X Window System since about 1991. The c means "color", it's possible to add m for "monochrome" output, g for "grayscale", and s for "symbolic", explaining what a defined color is supposed to do.

In addition to the X11 color names the name 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.

If the width, height, colors, and characters per pixel line contains six instead of four numbers, the additional values indicate the coordinates of a "hotspot", 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:

  1. define test_width 16
  2. define test_height 7

static char test_bits[] = {

0x13, 0x00, 0x15, 0x00, 0x93, 0xcd, 0x55, 0xa5, 0x93, 0xc5, 0x00, 0x80,

0x00, 0x60 };

XPM2 version:

! XPM216 7 2 1* c #000000. c #ffffff**..*...........*.*.*...........**..*..**.**..***.*.*.*.*.*..*.***..*..**.*...**...............*.............**.

XPM3 version:

/* XPM */

static char * blarg_xpm[] = {

"16 7 2 1",

"* c #000000",

". c #ffffff",

"**..*...........",

"*.*.*...........",

"**..*..**.**..**",

"*.*.*.*.*.*..*.*",

"**..*..**.*...**",

"...............*",

".............**."

};

PBM file:

P116 71 1 0 0 1 0 0 0 0 0 0 0 0 0 0 01 0 1 0 1 0 0 0 0 0 0 0 0 0 0 01 1 0 0 1 0 0 1 1 0 1 1 0 0 1 11 0 1 0 1 0 1 0 1 0 1 0 0 1 0 11 1 0 0 1 0 0 1 1 0 1 0 0 0 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 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, 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] FFmpeg version 3.3 or later can decode XPM.[11]

{{-}}

See also

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

References

1. ^.xpm MIME type not registered at IANA
2. ^{{cite book|last1= Le Hors |first1= Arnaud |title= XPM Manual: The X PixMap Format |url= http://www.xfree86.org/current/xpm.pdf|format= PDF |accessdate= 2014-01-01 |date= 1996-02-01 |publisher= Groupe Bull |pages=7-8 |id= |ref= CITEREFLeHors1996 }}
3. ^{{cite web|url= http://www.w3.org/People/danield/xpm_story.html |title= The XPM Story |author=Daniel Dardailler|others= Colas Nahaboo and Arnaud Le Hors |date=1996-07-15|accessdate=2014-01-01 }}
4. ^{{cite web|url=http://www.ibiblio.org/pub/X11/contrib/libraries/xpm.FAQ|title=The XPM FAQ|publisher=X.Org Foundation|year=1996|accessdate=2016-03-12}}
5. ^{{cite web|url=https://www.fileformat.info/format/xpm/egff.htm|title=XPM File Format Summary|isbn=1-56592-161-5|work=Encyclopedia of Graphics File Formats, 2nd Edition|accessdate=2014-01-01}}
6. ^{{cite web|url=http://extension.nirsoft.net/xpm|title=.xpm Extension|author=Nir Sofer|accessdate=2014-01-12}}
7. ^{{cite web|url=http://shell.windows.com/fileassoc/0409/xml/redir.asp?EXT=xpm|publisher=Microsoft|work=Windows File Association |title=File Type: X Windows Pixmap|year=2013|accessdate=2014-01-12}}
8. ^Gravatar unofficial, no XPM2
9. ^{{cite web|url=http://kinzler.com/picons/ftp/index.html|title=Picons Archive|author=Steve Kinzler|year=2005|quote=picons are in either monochrome XBM format or color XPM and GIF formats|accessdate=2014-01-06}}
10. ^{{cite web|url=http://www.kb.cert.org/vuls/id/537878 | id=VU#537878|title=libXpm library contains multiple integer overflow vulnerabilities|date=2005-10-06|work=US-CERT |accessdate=2014-01-01}}
11. ^{{cite web |url=https://www.ffmpeg.org/index.html#pr3.3 |title=FFmpeg 3.3 "Hilbert" |quote=XPM decoder |publisher=FFmpeg |date=2017-04-13 |accessdate=2017-10-28}}
{{Graphics file formats}}{{DEFAULTSORT:X Pixmap}}

3 : Graphics file formats|X Window System|Computer-related introductions in 1989

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/13 21:10:42