[comp.windows.x] XPM information

david@lta.COM (David B. Lewis) (12/15/90)

There have been several recent queries on the XPM format and related information.
Here are some pointers. 

In article <9012131908.AA25680@fandago>, jcoco@fandago.ctc.tasc.COM (Joe Coco xwindows) writes:
|> 
|> 	I just obtained a copy of the xloadimage program and
|> I read that one of the image formats it loads is X Pixmap File
|> format.  Where could I find the definition of this file type?
|> I understand what pixmaps are, but dont know what a pixmap file
|> looks like.

XPM (X PixMap) is a format for storing/retrieving X pixmaps to/from ascii
files. It is a C-includable format which is easy to parse by machine and easy
to modify by hand.

The original XPM was done by Colas Nahaboo, Daniel Dardailler, and friends, of Bull RC, if I recall, and was eventually reworked and redistributed by 
Richard Hess of Consilium.  A more recent version, XPM2, was recently posted
by Arnaud Le Hors. The README for that version follows below.

>While I'm on the subject, incidentally, are there any decent color pixmap
>editors? I'm thinking of something along the lines of bitmap or iconedit,
>not a drawing program like xfig. It's about time for someone to write
>the XPM version of iconedit if it hasn't already been done....
>                 Laurence R. Brothers (quasar@bellcore.com)

I believe Bull developed such an editor; check inria.inria.fr. In addition,
James Bash of AT&T developed olpixmap, which was distributed with the AT&T
Open Look Toolkit Version 2 and may be distributed with Sun's OLIT. In addition,
the ICS Builder Xcessory interface-builder tool allows the construction of
labelPixmap, backgroundPixmap, etc., resources and puts out the pixmap as XPM;
the excess C code could be trimmed away.  Various people have contributed
programs which convert to PPM format, which display XPM files, which set the
background to an XPM file (very nice to have multicolor pictures), and which
set up a converter to parse XPM format for widget resources that take pixmaps.



README for XPM2 follows:
------------------------------------

$Id: xpm.shar,v 2.1 90/08/24 19:07:31 lehors Exp $

				XPM Version 2

WHAT IS XPM?
============

XPM (X PixMap) is a format for storing/retrieving X pixmaps to/from ascii
files.

Here is provided a library containing a set of three functions, similar to the
X bitmap functions as defined in the Xlib: XCreatePixmapFromData,
XReadPixmapFile and XWritePixmapFile for respectively including, reading and
writing this format.

This new version provides different types of format: a natural one which will
be preferably used for manual editing (with emacs, vi, ...), a C includable
format and a Lisp includable format. It provides defaults for different types
of display: monochrome/color/grayscale, and symbol names for colors for
overriding default colors when creating the pixmap. Finally it provides a
structure for storing information while reading a file which is re-used while
writing. This way comments, default colors and symbol names aren't lost.

See the XPM Manual for more details.

INSTALLATION:
============

To obtain the XPM library, first execute the shell archive file in an
approriate directory. Then just do:

		      make all 
	   or	      make libxpm.a

NOTE:   if you compile  with gcc, use "gcc -traditional", otherwise you will
        have compilation warnings (but the code will work Ok)

DEMO:
====

In addition to the library a demo is provided. If you have previously done 
'make all' you should have it yet, otherwise just do:

		      make demo

This demo shows you all the features of XPM and the three provided functions.

By executing 'demo' without any option you will see a demo of the 
XCreatePixmapFromData function. The pixmap is created from the static variable
plaid defined in the demo.c file. Demo will end when you click in the created
window.

Executing 'demo -s lines_in_mix blue' will show the feature of color symbols.

Then you should try 'demo -o output' to get an output file using the
XWritePixmapFile function. This is a natural type format file, other types can
be obtained by adding the option '-t C' or '-t Lisp'.

To end you should try 'demo -i plaid' or 'demo -i plaid_c' or 
'demo -i plaid_ll' to use the XReadPixmapFile function.

Of course, other combinations are allowed and should be tried. Thus, 
'demo -i plaid -o output -t C' will show you how a natural type format is
translated to a C type format.

The XCreatePixmapFromData function is on purpose called without any Xpminfo 
pointer to show the utility of this one. Indeed, compare the color section of
the two files foo and bar obtained from 'demo -o foo' and 
'demo -i plaid -o bar'.

KNOWN BUG:
=========

XWritePixmapFile:
Writing out multilines comment to a single line comment is not handled. Thus,
translating a C multilines comment to Lisp will result to an invalid file.

DISCUSSION:
==========

Any discussion should be made on the comp.windows.x newsgroup. The subject
line will preferably begin by the word XPM.

COPYRIGHT:
==========

  Copyright 1990 GROUPE BULL -- See licence conditions in file COPYRIGHT
  See the COPYRIGHT file in the XPM distribution

Please mail any bug reports or modifications done, comments, suggestions,
requests for updates or patches to port on another machine to:

lehors@mirsa.inria.fr		(INTERNET)

33 (FRANCE) 93.65.77.71		(VOICE PHONE)

Arnaud Le Hors			(SURFACE MAIL)
INRIA
2004, Route des lucioles
Sophia Antipolis
06565 VALBONNE
FRANCE

------------------------------------------ 
sample files plaid_c and plaid_ll from the XPM2 distribution follow
-------------------------------------------

/* XPM2 C */
static char * plaid[] = {
/* plaid pixmap 
 * width height ncolors chars_per_pixel */
"22 22 4 2 ",
/* colors 
 */
"   c red 	m white  s light_color ",
"Y  c yellow	m black  s lines_in_mix ",
"+  c yellow	m white  s lines_in_dark ",
"x 		m black  s dark_color ",
/* pixels */
"x   x   x x x   x   x x x x x x + x x x x x ", 
"  x   x   x   x   x   x x x x x x x x x x x ", 
"x   x   x x x   x   x x x x x x + x x x x x ", 
"  x   x   x   x   x   x x x x x x x x x x x ", 
"x   x   x x x   x   x x x x x x + x x x x x ", 
"Y Y Y Y Y x Y Y Y Y Y + x + x + x + x + x + ", 
"x   x   x x x   x   x x x x x x + x x x x x ", 
"  x   x   x   x   x   x x x x x x x x x x x ", 
"x   x   x x x   x   x x x x x x + x x x x x ", 
"  x   x   x   x   x   x x x x x x x x x x x ", 
"x   x   x x x   x   x x x x x x + x x x x x ", 
"          x           x   x   x Y x   x   x ", 
"          x             x   x   Y   x   x   ",
"          x           x   x   x Y x   x   x ", 
"          x             x   x   Y   x   x   ", 
"          x           x   x   x Y x   x   x ", 
"x x x x x x x x x x x x x x x x x x x x x x ", 
"          x           x   x   x Y x   x   x ", 
"          x             x   x   Y   x   x   ", 
"          x           x   x   x Y x   x   x ", 
"          x             x   x   Y   x   x   ", 
"          x           x   x   x Y x   x   x "
} ;


; XPM2 Lisp 
(setq plaid '(
; width height ncolors chars_per_pixel  
"22 22 4 2"
; colors 
"   c red 	m white  s light_color"
"Y  c yellow	m black  s lines_in_mix"
"+  c yellow	m white  s lines_in_dark"
"x 		m black  s dark_color"
; pixels 
"x   x   x x x   x   x x x x x x + x x x x x " 
"  x   x   x   x   x   x x x x x x x x x x x " 
"x   x   x x x   x   x x x x x x + x x x x x " 
"  x   x   x   x   x   x x x x x x x x x x x " 
"x   x   x x x   x   x x x x x x + x x x x x " 
"Y Y Y Y Y x Y Y Y Y Y + x + x + x + x + x + " 
"x   x   x x x   x   x x x x x x + x x x x x " 
"  x   x   x   x   x   x x x x x x x x x x x " 
"x   x   x x x   x   x x x x x x + x x x x x " 
"  x   x   x   x   x   x x x x x x x x x x x " 
"x   x   x x x   x   x x x x x x + x x x x x " 
"          x           x   x   x Y x   x   x " 
"          x             x   x   Y   x   x   "
"          x           x   x   x Y x   x   x " 
"          x             x   x   Y   x   x   " 
"          x           x   x   x Y x   x   x " 
"x x x x x x x x x x x x x x x x x x x x x x " 
"          x           x   x   x Y x   x   x " 
"          x             x   x   Y   x   x   " 
"          x           x   x   x Y x   x   x " 
"          x             x   x   Y   x   x   " 
"          x           x   x   x Y x   x   x "
))




-- 
David B. Lewis  			Lewis, Trachtenberg & Associates (LTA)
Note new address!:  david@lta.com	+1 617 225 0366