Re: writting out a pixmap file

Steve Lamont (
Wed, 12 Mar 97 10:34:09 PST

To subscribers of the xforms list from (Steve Lamont) :

> what would be the best way to do this ? I have a created pixmap and need
> to generate a file that I can then print, I can't find anyting mt X books
> nor in the manual

By pixmap do you mean an Xpm pixmap or an actual X Pixmap?

The Xpm pixmap is just a collection of character strings. You can
write them out directly with a loop of fprintf()s. There are also Xpm
library functions which allow some data manipulation. Refer to the
Xpm documentation which comes along with the distribution for details.

You can convert the Xpm data to some other format with an external
tool kit such as NETPBM or sxpm (which comes as part of Xpm).
The FAQ document which comes with the Xpm distribution discusses this.

Alternatively, you can interpret the Xpm character strings for
yourself. Again, refer to the Xpm documentation will give you
guidance on how to do this.

Check either ( contrib (Boston, USA) ( pub/xpm (Sophia Antipolis, France)

for the current release of Xpm and its docs.

If you mean a real, honest to goodness X Pixmap, then things may be a
bit more involved. You need to read the Pixmap from the X server with

If the Pixmap is from a TrueColor Visual then all you have to do is
write the data out in your favorite format.

If the Pixmap is from a PseudoColor visual, then you have to remap the
pixels from server Colormap space to RGB space. To do this, you'll
have to get the lookup table from the Colormap using XQueryColors()
and do a table lookup.

Refer to your favorite Xlib manual set for the details.

To unsubscribe, send the message "unsubscribe" to or see
Xforms Home Page:
List Archive: