[comp.windows.x] printing GPX II windows on an LN03

kmware@mit-caf.UUCP (Kurt M. Ware) (08/14/87)

	Earlier I asked for response from people who had addressed the
problem of dumping GPX II windows (color) to an LN03 printer (monochrome).
Receiving none (other than 3 requests for the me to pass on the "solution")
I decided to fiddle with it myself.  I have modified the V10R4 version of 
xwd.c to allow conversion of pixmap windows to bitmap dumps that can then
be processed using xpr or other printer pre-processors.
	In general, this is a non-trivial problem -- how does one
intelligently map many colors to two?  I side-stepped all of this by
inducing xwd to gather an XYPixmap, and then simply dump the least
significant bit plane, mapping every other color to WhitePixel and the
rest to BlackPixel.  For application that stick to a few colors, this
seems to work reasonably well (e.g. xterm).  I have attached a "diff"
output to get from the V10R4 source for xwd.c to the modified version.
	An additional option is thereby added to xwd.c: -coerce.  When
the -coerce option is used with the -xy option, bitmap output is
generated, and the number of planes field in the output file is set to
0 (indicating a bitmap output).  It is simple to mimic the xdpr shell
script, making something like:
	xwd -xy -coerce | xpr | lpr
(Appropriate modification of xdpr is left as an exercise to the
reader.)  Here are is the diff output:

-------------   Diff to add -coerce option to X.V10R4 xwd.c:
79a80
>     Bool coerce = FALSE;
109a111,114
> 	if (strncmp(argv[i], "-coerce", 7) == 0) {
> 	    coerce = TRUE;
> 	    continue;
> 	}
357a363,364
>     if (coerce) ncolors = 0;
> 
389c396,402
<     (void) fwrite(buffer, (int) buffer_size, 1, out_file);
---
>     if (coerce)
>       (void) fwrite((char *)
> 		    (buffer+buffer_size*(DisplayPlanes()-1)/DisplayPlanes()),
> 		    (int) buffer_size/DisplayPlanes(), 1, out_file);
>     else
>       (void) fwrite(buffer, (int) buffer_size, 1, out_file);
> 
------------
Kurt Ware
Microsystems Technology Laboratory, M.I.T.
"If it works, don't fix it -- unless of course it doesn't work well enough..."