Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
X PixMap
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Image file format}} {{Infobox file format | name = X PixMap | screenshot = Screenshot-xterm-linux.xpm-GVIM.png | screenshot_size = 240px | caption = Some [[text editors]], for example [[gvim]], can display xpm images in graphical form. | extension = <code>.xpm</code> | mime = image/x-xpixmap<ref name="iana">.xpm [[MIME]] type not [https://www.iana.org/assignments/media-types/media-types.xhtml#image registered] at [[Internet Assigned Numbers Authority|IANA]]</ref> | owner = BULL Research | creatorcode = | genre = [[Image file formats]] | containerfor = | containedby = | extendedfrom = [[X BitMap|XBM]] | extendedto = | open = yes }} '''X PixMap''' ('''XPM''') is an [[Image file formats|image file format]] used by the [[X Window System]], created in 1989 by Daniel Dardailler and Colas Nahaboo working at [[Groupe Bull|Bull Research Center]] at [[Sophia Antipolis]], France, and later enhanced by Arnaud Le Hors.<ref name="xpm1">{{cite book|last1= Le Hors |first1= Arnaud |title= XPM Manual: The X PixMap Format |url= http://www.xfree86.org/current/xpm.pdf|access-date= 2014-01-01 |date= 1996-02-01 |publisher= [[Groupe Bull]] |pages=7β8 |ref= CITEREFLeHors1996 }}</ref><ref>{{cite web|url= http://www.w3.org/People/danield/xpm_story.html |archive-url= https://web.archive.org/web/19970607024723/http://www.w3.org/People/danield/xpm_story.html |url-status= dead |archive-date= 1997-06-07 |title= The XPM Story |author=Daniel Dardailler|others= Colas Nahaboo and Arnaud Le Hors |date=1996-07-15|access-date=2014-01-01 }}</ref> It is intended primarily for creating [[computer icon|icon]] [[pixmap]]s, and supports [[Transparency (graphic)#Transparent pixels|transparent pixels]]. Derived from the earlier [[X BitMap|XBM]] syntax, it is a [[plain text]] file in the XPM2 format or of a [[C (programming language)|C programming language]] syntax, which can be included in a C program file.<ref name="xpm1" /> == History == === XPM1 === The first (1989) XPM format is relatively similar to the XBM format.{{efn|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.}} 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. <syntaxhighlight lang="C"> #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[] = { "a", "#ffffff", "b", "#000000" }; static char *XFACE_pixels[] = { "abaabaababaaabaabababaabaabaababaabaaababaabaaab", // and so on for 48 rows with 48 pixels </syntaxhighlight> === XPM2 === XPM2 (1990) simplifies the format by removing all [[C (programming language)|C]] code.{{efn|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.}}{{efn|For references on this syntax, see https://gitlab.freedesktop.org/xorg/lib/libxpm/-/blob/master/NEWS.old and the "history" section of libXpm 3.4 manual.}} The structure is simplified to <pre> ! XPM2 <Values> <Colors> <Pixels> <Optional Extensions> </pre> * The value section describes the overall dimension of the image similar to the <code>#define</code> 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: <pre> ! XPM2 48 4 2 1 a c #FFFFFF b c #000000 abaabaababaaabaabababaabaabaababaabaaababaabaaab abaabaababaaabaabababaabaabaababaabaaababaabaaab abaabaababaaabaabababaabaabaababaabaaababaabaaab abaabaababaaabaabababaabaabaababaabaaababaabaaab </pre> ==== Colors ==== In addition to hexcodes, the colors can be any of the [[X11 color names]]. In addition, <code>None</code> indicates transparency.<ref>{{cite web|url=http://www.ibiblio.org/pub/X11/contrib/libraries/xpm.FAQ|title=The XPM FAQ|publisher=[[X.Org Foundation]]|year=1996|access-date=2016-03-12}}</ref><ref>{{cite book|url=https://archive.org/details/mac_Graphics_File_Formats_Second_Edition_1996|title=XPM File Format Summary|isbn=1-56592-161-5|work=Encyclopedia of Graphics File Formats, 2nd Edition|access-date=2014-01-01|url-access=registration |last1=Murray |first1=James D. |last2=Vanryper |first2=William |date=1996 |publisher=O'Reilly & Associates }}</ref> The "symbolic" feature permits adjusting colors depending on the context where they are used. Code such as <code>s border c blue</code> 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 10<sup>9</sup> = {{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 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. <syntaxhighlight lang="C"> /* XPM */ static char * XFACE[] = { "48 4 2 1", "a c #ffffff", "b c #000000", "abaabaababaaabaabababaabaabaababaabaaababaabaaab", "abaabaababaaabaabababaabaabaababaabaaababaabaaab", "abaabaababaaabaabababaabaabaababaabaaababaabaaab", "abaabaababaaabaabababaabaabaababaabaaababaabaaab" }; </syntaxhighlight> 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 == [[File:Blarg.xbm.png|right|thumb|Blarg file opened in program window]] The following code displays the same blarg file in the [[X BitMap|XBM]], XPM and [[Netpbm format|PBM]] formats. XBM version: <syntaxhighlight lang="C"> #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 }; </syntaxhighlight> [[File:Blarg.xpm.png|right|thumb|Blarg.xpm (XPM2) rendered by XnView]] XPM2 version: <pre> ! XPM2 16 7 2 1 * c #000000 . c #ffffff **..*........... *.*.*........... **..*..**.**..** *.*.*.*.*.*..*.* **..*..**.*...** ...............* .............**. </pre> XPM3 version: <syntaxhighlight lang="C"> /* XPM */ static char * blarg_xpm[] = { "16 7 2 1", "* c #000000", ". c #ffffff", "**..*...........", "*.*.*...........", "**..*..**.**..**", "*.*.*.*.*.*..*.*", "**..*..**.*...**", "...............*", ".............**." }; </syntaxhighlight> PBM file: <pre> 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 </pre> ==Application support== [[ACDSee]], [[Amaya (web editor)|Amaya]], [[CorelDRAW]], [[GIMP]], [[ImageMagick]], [[IrfanView]] (formats plugin), [[PaintShop Pro]], [[PMView]], [[Adobe Photoshop|Photoshop]] (plugins), and [[XnView]] among others support XPM.<ref>{{cite web|url=http://extension.nirsoft.net/xpm|title=.xpm Extension|author=Nir Sofer|access-date=2014-01-12}}</ref><ref>{{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|access-date=2014-01-12}}</ref> [[Gravatar]] also supports XPM.<ref>[[Gravatar]] unofficial, no XPM2</ref><ref>{{cite web|url=http://kinzler.com/picons/ftp/index.html|title=Picons Archive|author=Steve Kinzler|author-link=Steve Kinzler|year=2005|quote=picons are in either monochrome XBM format or color XPM and GIF formats|access-date=2014-01-06}}</ref> An [[X Window System|X11]] libXpm [[vulnerability (computing)|vulnerability]] was fixed in 2005,<ref>{{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=[[United States Computer Emergency Readiness Team|US-CERT]] |access-date=2014-01-01}}</ref> and three more in 2023.<ref>{{cite web|url=https://lists.x.org/archives/xorg-announce/2023-January/003312.html |title=X.Org Security Advisory: Issues handling XPM files in libXpm prior to 3.5.15|date=2023-01-17}}</ref> [[FFmpeg]] version 3.3 or later can decode XPM.<ref>{{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 |access-date=2017-10-28}}</ref> {{-}} == See also == * {{Annotated link|Netpbm}} * {{Annotated link|CLUT}} * {{Annotated link|X BitMap}} == Notes == {{notelist}} ==References== {{Reflist}} == See also == * [[X Window System]] (X11) and [[X11 color names]] * [[Netpbm format|<abbr title="portable bitmap">PBM</abbr>]] (mono), [[Netpbm format|<abbr title="portable graymap">PGM</abbr>]] (grayscale), [[Netpbm format|<abbr title="portable pixmap">PPM</abbr>]] (color), [[Netpbm format|<abbr title="portable anymap">PNM</abbr>]] (any) * [[X BitMap]] == External links == * [https://gitlab.freedesktop.org/xorg/lib/libxpm libXpm - X Pixmap (XPM) image file format library] {{Graphics file formats}} {{DEFAULTSORT:X Pixmap}} [[Category:Graphics file formats]] [[Category:X Window System]] [[Category:Computer-related introductions in 1989]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:-
(
edit
)
Template:Annotated link
(
edit
)
Template:Cite book
(
edit
)
Template:Cite web
(
edit
)
Template:Efn
(
edit
)
Template:Graphics file formats
(
edit
)
Template:Infobox file format
(
edit
)
Template:Notelist
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Val
(
edit
)