Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 History  



1.1  XPM1  





1.2  XPM2  



1.2.1  Colors  





1.2.2  Many-color encoding  







1.3  XPM3  







2 Comparison with other formats  





3 Application support  





4 See also  





5 Notes  





6 References  





7 See also  





8 External links  














X PixMap






Čeština
Deutsch
Español
Français

Italiano

Русский
Suomi
Svenska
Українська

 

Edit links
 









Article
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Cite this page
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 




In other projects  



Wikimedia Commons
 
















Appearance
   

 






From Wikipedia, the free encyclopedia
 


X PixMap
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 formatImage file formats
Extended fromXBM
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 CenteratSophia 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]

History[edit]

XPM1[edit]

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

XPM2[edit]

XPM2 (1990) simplifies the format by removing all C code.[b][c] 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[edit]

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[edit]

One tool is known to use only atop 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[edit]

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 */
static char * 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[edit]

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 7
static char test_bits[] = {
0x13, 0x00, 0x15, 0x00, 0x93, 0xcd, 0x55, 0xa5, 0x93, 0xc5, 0x00, 0x80,
0x00, 0x60 };
Blarg.xpm (XPM2) rendered by XnView

XPM2 version:

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

XPM3 version:

/* XPM */
static char * 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[edit]

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]

AnX11 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[edit]

Notes[edit]

  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.
  • ^ 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.
  • ^ 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.
  • References[edit]

    1. ^ .xpm MIME type not registeredatIANA
  • ^ a b Le Hors, Arnaud (1996-02-01). XPM Manual: The X PixMap Format (PDF). Groupe Bull. pp. 7–8. Retrieved 2014-01-01.
  • ^ 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.
  • ^ "The XPM FAQ". X.Org Foundation. 1996. Retrieved 2016-03-12.
  • ^ Murray, James D.; Vanryper, William (1996). XPM File Format Summary. O'Reilly & Associates. ISBN 1-56592-161-5. Retrieved 2014-01-01. {{cite book}}: |work= ignored (help)
  • ^ Nir Sofer. ".xpm Extension". Retrieved 2014-01-12.
  • ^ "File Type: X Windows Pixmap". Windows File Association. Microsoft. 2013. Retrieved 2014-01-12.
  • ^ Gravatar unofficial, no XPM2
  • ^ Steve Kinzler (2005). "Picons Archive". Retrieved 2014-01-06. picons are in either monochrome XBM format or color XPM and GIF formats
  • ^ "libXpm library contains multiple integer overflow vulnerabilities". US-CERT. 2005-10-06. VU#537878. Retrieved 2014-01-01.
  • ^ "X.Org Security Advisory: Issues handling XPM files in libXpm prior to 3.5.15". 2023-01-17.
  • ^ "FFmpeg 3.3 "Hilbert"". FFmpeg. 2017-04-13. Retrieved 2017-10-28. XPM decoder
  • See also[edit]

    External links[edit]


    Retrieved from "https://en.wikipedia.org/w/index.php?title=X_PixMap&oldid=1225614982"

    Categories: 
    Graphics file formats
    X Window System
    Computer-related introductions in 1989
    Hidden categories: 
    CS1 errors: periodical ignored
    Articles with short description
    Short description matches Wikidata
    Pages displaying short descriptions of redirect targets via Module:Annotated link
     



    This page was last edited on 25 May 2024, at 16:16 (UTC).

    Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



    Privacy policy

    About Wikipedia

    Disclaimers

    Contact Wikipedia

    Code of Conduct

    Developers

    Statistics

    Cookie statement

    Mobile view



    Wikimedia Foundation
    Powered by MediaWiki