[comp.windows.x] Dumping a color Window to PostScript

harald@ruuinf.cs.ruu.nl (Harald Vogt) (08/25/89)

We had the same problem on our HP's. This is my solution:
   Get the sources of xwd and xpr from the X11v3 release.
   Install xpr. 
   Make a new command xwdmono which is a patched
   version of xwd (patches follow). 
   
xwdmono dumps only the first plane.

Dumping a window now proceeds as follows:
   xwdmono -xy | xpr -device ps > win.ps

Have a nice dump,
			Harald Vogt

------------------patch to make xwdmono.c ------------------
*** xwd.c	Fri Aug 25 13:41:44 1989
--- xwdmono.c	Fri Aug 25 13:42:10 1989
***************
*** 211,217 ****
      bw = nobdrs ? 0 : win_info.border_width;
      x = absx - win_info.x - bw;
      y = absy - win_info.y - bw;
!     image = XGetImage (dpy, window, x, y, width, height, AllPlanes, format);
      if (!image) {
  	fprintf (stderr, "%s:  unable to get image at %dx%d+%d+%d\n",
  		 program_name, width, height, x, y);
--- 211,219 ----
      bw = nobdrs ? 0 : win_info.border_width;
      x = absx - win_info.x - bw;
      y = absy - win_info.y - bw;
! /* HV image = XGetImage (dpy, window, x, y, width, height, AllPlanes, format);
! */
!     image = XGetImage (dpy, window, x, y, width, height, 1L, format);
      if (!image) {
  	fprintf (stderr, "%s:  unable to get image at %dx%d+%d+%d\n",
  		 program_name, width, height, x, y);
***************
*** 227,233 ****
  
      if (debug) outl("xwd: Getting Colors.\n");
  
!     ncolors = Get_XColors(&win_info, &colors);
  
      /*
       * Inform the user that the image has been retrieved.
--- 229,236 ----
  
      if (debug) outl("xwd: Getting Colors.\n");
  
! /* HV    ncolors = Get_XColors(&win_info, &colors); */
!     ncolors = 0; /* HV to let xpr work right */
  
      /*
       * Inform the user that the image has been retrieved.
-------------------end of patch-----------------------

bchen@esvax.berkeley.edu (Benjamin Chen) (08/26/89)

>xwdmono dumps only the first plane.

>Dumping a window now proceeds as follows:
>   xwdmono -xy | xpr -device ps > win.ps

Does this really give good results?  I would imagine you would get some
sort of "ghostlike" image.

	BC

Benjamin Chen
Office:   550-A4 Cory Hall, 2-4332
UUCP:     !ucbvax!esvax!bchen               
HEPNET:   LBL::"bchen@esvax.Berkeley.EDU"

jdm@gssc.UUCP (John D. Miller) (08/26/89)

a better solution is to junk xpr and translate the X window dump
into PostScript directly, using the PostScript "image" operator.  
PostScript images can be rendered in 1, 2, 4, or 8 bits, even on 
monochrome laserprinters (PostScript does the half-toning).

this program, (call it "xpsimage" or some such) would need to convert
from RGB to grayscale:

	i = (R * .30) + (G * .59) + (B * .11)

see the PostScript "Red Book" for info on the "image" operator, or give me
a call.

-- jdm

ps - if someone writes this utility, i'd like a copy.  i'd do it myself, but i
am way overcommited as it is.

...!{tektronix!verdix}!sequent!gssc!jdm                John David Miller
(503) 641-2200                                         Graphic Software Systems
* This space intentionally  *                          9590 S.W. Gemini Dr.
* left blank.               *                          Beaverton, OR  97005