[comp.windows.x] colour bitmap program file formats

david@ics.COM (David B. Lewis) (07/11/90)

In article <37473@ucbvax.BERKELEY.EDU>, welch@earthquake.Berkeley.EDU
(Sean N. Welch) writes:
|>I am interested in adding color to an existing bitmap editing program
|>and would like to know what standards, if any, are spelled out by X 
|>for the storage of data that makes up a multi plane pixmap.  In 
|>particular I know that AT&T has a pixmap editor that they were showing 
|>off at Xhibition and wanted to know if it has been released, and if so, 
|>what format they use.

The current "standard" is the XPM format from Group Bull and distributed
by rhess@cimshop.uu.net; a recent version is also available on expo.

olpixmap by James Bash of ATT uses this format, as does a home-brew
which we use
and may soon make available. I believe the format is also supported as an icon
format by newer versions of the gwm window manager and other Bull software.

We've found the format very easy to work with.

(Other formats which you could use include raw "xwd" format or the icon
format from OSF/Motif's UIL language.)

A somewhat outdated README describing the XPM format follows.

XPM Pixmap File Convention Support
==================================

The XPM (X PixMap) file format is a convention for storing pixmaps
on disk in a portable (ASCII), device-independent (no depth or color
limitations), #include'able format, similar to MIT's standard X11
bitmap file format.  The convention was developed out of need by
the X community (GROUPE BULL in particular); it is our hope that
it will soon become part of standard X11 from MIT.  This doesn't
need to happen for you to start using the format today, though,
as all the support you need can be found here.  Your application
will, in a sense, live in a vacuum.

The two source files xpm.c and xpm.h provide support for managing
XPM-format files.  Link these into your application and call the
routines below as appropriate:

    Pixmap XCreatePixmapFromData(display, drawable, colormap,
				 width, height, depth,
				 ncolors, chars_per_pixel, colors, pixels)

    int    XReadPixmapFile(display, drawable, colormap, filename,
			   w_return, h_return, depth, pixmap_return)

    int    XWritePixmapFile(display, colormap, filename,
			    pixmap, width, height)


The XPM file format looks like this:

#define foo_format 1
#define foo_width 16
#define foo_height 16
#define foo_ncolors 4
#define foo_chars_per_pixel 1
static char * foo_colors[] = {
" " , "#FFFFFFFFFFFF",
"." , "SkyBlue",
"X" , "#000000",
"o" , "ForestGreen"
} ;
static char * foo_pixels[] = {
"X..X           X",
" X..X          X",
"  X..X        X ",
"   X..X      X  ",
"   X..X     X   ",
"    X..X   X    ",
"     X..X  X    ",
"      X.. X     ",
"      XX X      ",
"      X ooX     ",
"     X  XooX    ",
"     X   XooX   ",
"    X    XooX   ",
"   X      XooX  ",
"  X        XooX ",
" X          XooX"
} ;

So, the most typical application usage of the XPM support routines
is similar to how bitmap files are incorporated:

	#include "foo.xpm"

	...
 	Pixmap foo = XCreatePixmapFromData(DISPLAY, DRAWABLE, COLORMAP,
					   foo_width, foo_height, DEPTH,
					   foo_ncolors, foo_chars_per_pixel,
					   foo_colors, foo_pixels);
	...

Colors will be allocated from the supplied colormap as necessary,
and the pixmap foo (which will be created with the specified depth)
could then be used like any normal X pixmap.

                    
David B. Lewis  david@ics.com  david%ics.UUCP@bu.edu  ...!uunet!ics.com!david

Bring back the shine mark!