Home

XPM

XPM, short for X PixMap, is a plain-text image format used by the X Window System. It is designed to store small icons and cursors in a human-readable form that can be embedded directly in C source code or header files, facilitating easy inclusion in applications without separate image loading.

The format is ASCII-based. The first line of an XPM image specifies width, height, number of colors,

XPM data are typically stored as a C array of strings, which enables icons to be compiled

static char * icon_xpm[] = {

"4 4 2 1",

"a c None",

"b c #000000",

"bbbb",

"bbab",

"bbba",

"bbbb"

};

This format supports embedding, easy version control, and straightforward editing with text tools. It is widely

History and usage: XPM was introduced in the late 1980s for the X Window System and became

Limitations and related tools: As a text-based format, XPM is easy to inspect and diff but inefficient

and
the
number
of
characters
per
pixel
(cpp).
This
is
followed
by
color
definition
lines
that
map
single-character
symbols
to
color
values
or
to
None
for
transparency.
The
remaining
lines
contain
the
pixel
data,
with
each
character
representing
one
pixel.
Because
the
data
are
encoded
as
characters,
XPM
images
are
compact
for
simple
icons
but
not
optimal
for
photographic
content.
into
applications.
A
small
example
in
C
form
might
look
like:
supported
by
the
libXpm
library
and
various
X11
toolkits,
and
can
be
converted
to
other
formats
using
image
conversion
tools
such
as
ImageMagick
or
GIMP.
a
common
choice
for
icons
and
cursors
in
early
X11
environments.
While
binary
formats
like
PNG
have
largely
supplanted
XPM
for
many
applications,
XPM
remains
available
for
compatibility
and
for
scenarios
where
source-code
embedding
is
desirable.
for
large
images
and
lacks
rich
metadata.
Creating
or
converting
XPM
images
is
supported
by
tools
such
as
Xpm,
ImageMagick,
and
GIMP.