

Sooper-xwd


Sxwd is a utility for inspecting and modifying 8-bit pseudocolor (paletted)
XWD images.  It was initially written to deal with colormap issues, for 
example to dump the colormap, identify duplicate cells, set RGB values.


COLORMAP
$ sxwd -in white8.xwd -cmap    
$ sxwd -in white8.xwd -check    
$ sxwd -in white8.xwd -header
$ sxwd -in white8.xwd -addColor DarkSlateBlue -write
$ sxwd -in white8.xwd -check -c16

$ wget http://cloud.insideidaho.org/data/imageryBaseMapsEarthCover/topographicMaps/drg_24k_idaho/46/drg24k_46114a1_usgs.tif
$ mv drg24k_46114a1_usgs.tif o46114a1.tif
$ convert o46114a1.tif o46114a1.xwd
$ sxwd -in o46114a1.xwd -check
$ sxwd -in o46114a1.xwd -c16

There we see the 13 colors we are looking for.

Many images use less than 256 colors but most programs seem to want to 
write a full 256 cells: 

$ sxwd -in o46114a1.xwd -cmap

We can recover the cells:

$ ./sxwd -in o46114a1.xwd -over15
$ ./sxwd -in o46114a1.xwd -trunc 16 -write
$ ./sxwd -in o46114a1.xwd -check -c16


GENERAL
If we have two images we wish to combine, we could concatenate their
colormaps together blindly, we could merge them or attempt to merge them,
or we could remap the colors in one of them to those in the other.

$ ./sxwd -in o38119h8.xwd -patch doug.xwd -x 100 -y 100 -write
$ ./sxwd -in o38119h8.xwd -patchCentered doug.xwd -x 100 -y 100 -write
$ ./sxwd -in o38119h8.xwd -mapTo o38119a1.xwd -write

Some other basic features include getting and setting pixels, drawing 
lines and rectangles, clipping and resizing.  These are barebones;
no pen thickness and no anti-aliasing, leaving the -scale option useless.
The -new option will create a new 8-bit Pseudocolor XWD image, 8x8 in size, 
and fill it with white.

Sxwd processes commandline options in the order they are given; therefore:
- commands usually begin with -in
- options -x and -y must appear before -text

Option parameter syntax is not 100% consistent at present as seen above - the
-resize option expects the width and height to follow it, but the -text
option does not allow the x and y to follow it; it expects that they have
already been specified with -x and -y.


LETTERING 
Lettering was added make banner images more quickly than with mogrify:

$ cp white8.xwd w.xwd
$ ./sxwd -in w.xwd -resize 500 100 -set -write
$ ./sxwd -in w.xwd -fontPath /opt/source/sxwd/X11/fonts/bdf -fontDPI misc -font 7x14 -x 10 -y 10 -alignment Left -text "This is the 7x14 font"   -write
$ ./sxwd -in w.xwd -fontPath /opt/source/sxwd/X11/fonts/bdf -fontDPI 100dpi -font helvR12 -x 10 -y 10 -alignment Left -text "This is the helvR12 font"   -write
$ ./sxwd -new -name banner.xwd -fontPath /opt/source/sxwd/X11/fonts/bdf -fontDPI 100dpi -font helvI24 -x 10 -y 10 -alignment center -text "This is the helvI24 font"   -write


BUILDING
$ make ; sudo make install

CREDITS
Line drawing is from "Computer Graphics: Principles and Practice" by Foley and Van Dam
Text rendering is from ppmcaption-1.0 by jwz 


