[comp.sources.x] v09i026: xgrabsc, Patch1, Part01/01

bruce@SLC.COM (Bruce Schuchardt) (09/12/90)

Submitted-by: bruce@SLC.COM (Bruce Schuchardt)
Posting-number: Volume 9, Issue 26
Archive-name: xgrabsc/patch1
Patch-To: xgrabsc: Volume 8, Issue 75,76

This is the first patch set for xgrabsc.  See the file README.patch1
for a description of the changes introduced by this set.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Bruce Schuchardt          Ph: (503) 629-8383
  Servio Corp.              bruce@SLC.COM
  Beaverton, OR



------------------CUT HERE--------------------------------------------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 1)."
# Contents:  README.patch1 patch1
# Wrapped by owner@spruce on Mon Sep 10 08:25:19 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README.patch1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README.patch1'\"
else
echo shar: Extracting \"'README.patch1'\" \(3623 characters\)
sed "s/^X//" >'README.patch1' <<'END_OF_FILE'
X*========================================================================
X*
X* Name - README.patch1
X*
X* Version:	1.2
X*
X* ccsid:	@(#)README.patch1	1.2 - 9/10/90 08:21:46
X* from: 	ccs/s.README.patch1
X* date: 	9/10/90 08:22:05
X*
X* 
X*  
X* Description: notes on patch kit #1
X*
X*========================================================================*
X
X
XOPTIONS:
X
XNew options added in patch 01 are
X
X    alternate input selection mechanisms:
X
X    -r      selects the root window
X    -i id   selects window #id
X    -w      selects the window in the same manner as xwd
X    
X    -c      forces run-length encoding off for Postscript output
X    -E      output Encapsulated Postscript
X
X    both the "c" and "E" options also select Postscript output format
X
XThe rubber-band selection mechanism now uses upper-left and lower-right
Xangle cursors.  You can still drag any way you want, but there were
Xenough requests to use these instead of the cross-hair cursor that I
Xmade the change.
X
XThe program now sounds the X bell once before pulling the image and twice
Xafter pulling it.
X
XThe Postscript encoding was completely revamped.  The new RLE code is 
Xsimilar to that used in MacPaint files and provides better compression for 
Ximages in general. The new "-c" switch can be used to turn off encoding.  
X
XSeveral people have asked for, and I've attempted to create, encapsulated 
XPostscript output.  Use the new "-E" option to generate this form of 
XPostscript output.  I have no gear to test it with; if it doesn't work and 
Xyou know how to fix it, please let me know.
X
X
XBUILDING:
X
X
XThe imake and make files were changed to follow accepted conventions.
XA new target was added for man page installation (install.man).
X
XThe compilation flag -DNO_RLE_CHECKS will eliminate a pass that xgrabsc
Xmakes over the source image to determine whether compression of Postscript
Xoutput will actually result in size savings.
X
XFor machines with no memcpy() or memset() routines in their standard
Xlibraries, conditionally compiled routines were added to xgrabsc.c.
XCompile with -DMEMCPY to use these routines.
X
X
XKNOWN BUGS:
X
X
XI've tried to respond to all problem reports.  If you did not receive a
Xresponse, your mail either did not reach me or I could not reach you with
Xa reply.
X
X1) While xgrabsc can create puzzle picture files from monochrome screens, the
X   puzzle program will not display pictures with "-picture" on monochrome
X   systems. This is not a "bug" in xgrabsc, but is a "confusing feature".
X
X2) If you run xgrabsc from a Twm menu, be sure to end your exec command with
X   "&". The program may not be able to grab the pointer or server unless you
X   do this.  This will likely happen with any window manager, but has been
X   reported onlyfor Twm.
X
X3) The xwdtoppm program appears to have problems reading xgrabsc XWD output.  I've
X   looked into this problem a bit but have no quick solution for all platforms and
X   compilers.  If "xwd | xwdtoppm | ppmtoxwd | xwud" works on your machine, you
X   may try the simple fix of correcting the color-reading loop in xwdtoppm.c to
X   terminate on reaching "ncolors" instead of "colormap-entries".  You should
X   be able to use xgrabsc output once this is done.  The ppm bugs have been
X   reported to the owner of that project.
X
X
XACKNOWLEDGMENTS:
X
X
XThanks to
X    David Lawrence for the memcpy() and memset() functions
X    
X    Alan Kent for help with 4-plane problems, encapsulated postscript
X    suggestions, and for testing the patch kit
X
X
X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
X  Bruce Schuchardt          Ph: (503) 629-8383
X  Servio Corp.              bruce@SLC.COM
X  Beaverton, OR
X
END_OF_FILE
if test 3623 -ne `wc -c <'README.patch1'`; then
    echo shar: \"'README.patch1'\" unpacked with wrong size!
fi
# end of 'README.patch1'
fi
if test -f 'patch1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'patch1'\"
else
echo shar: Extracting \"'patch1'\" \(46079 characters\)
sed "s/^X//" >'patch1' <<'END_OF_FILE'
XPrereq: 0
X*** rls1/xgrabsc.c	Mon Sep 10 08:24:25 1990
X--- xgrabsc.c	Mon Sep 10 08:22:05 1990
X***************
X*** 2,12 ****
X   *
X   * Name - xgrabsc.c
X   *
X!  * Version:	1.4
X   *
X!  * ccsid:	@(#)xgrabsc.c	1.4 - 8/20/90 09:55:19
X   * from: 	ccs/s.xgrabsc.c
X!  * date: 	8/20/90 09:56:02
X   *
X   * Copyright (c) 1990 Bruce Schuchardt.
X   * Read the file cpyright.h for full copyright information.
X--- 2,12 ----
X   *
X   * Name - xgrabsc.c
X   *
X!  * Version:	1.7
X   *
X!  * ccsid:	@(#)xgrabsc.c	1.7 - 9/10/90 08:21:51
X   * from: 	ccs/s.xgrabsc.c
X!  * date: 	9/10/90 08:22:04
X   *
X   * Copyright (c) 1990 Bruce Schuchardt.
X   * Read the file cpyright.h for full copyright information.
X***************
X*** 38,43 ****
X--- 38,44 ----
X  #define TRUE  1
X  #define FALSE 0
X  
X+ 
X  typedef unsigned char byte;
X  typedef unsigned long dw;
X  typedef unsigned int  word;
X***************
X*** 52,57 ****
X--- 53,65 ----
X  } imageInfo;
X  
X  
X+ 
X+ #ifdef MEMCPY
X+ char *memcpy();
X+ char *memset();
X+ #endif
X+ 
X+ 
X  Display *hDisplay;
X  int      hScreen;
X  Window   hRoot;
X***************
X*** 59,64 ****
X--- 67,73 ----
X  char    *programName;
X  char    *imageName;
X  
X+ char    *version    = XGRABSC_VERSION;
X  int      patchLevel = XGRABSC_PATCHLEVEL;
X  int      verbose;
X  
X***************
X*** 68,74 ****
X  
X  
X  
X- 
X  /*
X   * Alter colors by setting or clearing bits in rgb values.
X   * This effectively reduces the depth of the image, causing the
X--- 77,82 ----
X***************
X*** 303,311 ****
X   * TRUE is returned if an image was successfully grabbed, and FALSE
X   * otherwise.
X   */
X! getImage(xrect, image)
X    XRectangle *xrect;
X    imageInfo *image;
X  {
X    XImage *ximage;
X    int depth, ncolors, cmapSize, numCmaps;
X--- 311,320 ----
X   * TRUE is returned if an image was successfully grabbed, and FALSE
X   * otherwise.
X   */
X! getImage(xrect, image, window)
X    XRectangle *xrect;
X    imageInfo *image;
X+   Window window;
X  {
X    XImage *ximage;
X    int depth, ncolors, cmapSize, numCmaps;
X***************
X*** 318,324 ****
X      return FALSE;
X  
X    depth  = DefaultDepth(hDisplay, hScreen);
X!   ximage = XGetImage(hDisplay, hRoot,
X              xrect->x, xrect->y, xrect->width, xrect->height, AllPlanes,
X              depth==1 ? XYPixmap : ZPixmap);
X    image->ximage = ximage;
X--- 327,333 ----
X      return FALSE;
X  
X    depth  = DefaultDepth(hDisplay, hScreen);
X!   ximage = XGetImage(hDisplay, window,
X              xrect->x, xrect->y, xrect->width, xrect->height, AllPlanes,
X              depth==1 ? XYPixmap : ZPixmap);
X    image->ximage = ximage;
X***************
X*** 325,337 ****
X  
X    /* get the colormap info too */
X  
X!   cmaps = XListInstalledColormaps(hDisplay, hRoot, &numCmaps);
X    if (numCmaps == 0)
X      cmap = DefaultColormap(hDisplay, hScreen);
X    else {
X      cmap = *cmaps;
X      if (numCmaps > 1)
X!       printf(stderr,
X          "%s: more than one colormap found - using first encountered",
X          programName);
X    }
X--- 334,346 ----
X  
X    /* get the colormap info too */
X  
X!   cmaps = XListInstalledColormaps(hDisplay, window, &numCmaps);
X    if (numCmaps == 0)
X      cmap = DefaultColormap(hDisplay, hScreen);
X    else {
X      cmap = *cmaps;
X      if (numCmaps > 1)
X!       fprintf(stderr,
X          "%s: more than one colormap found - using first encountered",
X          programName);
X    }
X***************
X*** 382,388 ****
X    XEvent event;
X    unsigned int mask, x, y, rootx, rooty;
X    GC gc;
X!   Cursor pointer;
X    int boxDrawn = False;
X    int rx, ry, rw, rh;
X    Window root, child;
X--- 391,397 ----
X    XEvent event;
X    unsigned int mask, x, y, rootx, rooty;
X    GC gc;
X!   Cursor pointer1, pointer2;
X    int boxDrawn = False;
X    int rx, ry, rw, rh;
X    Window root, child;
X***************
X*** 389,399 ****
X    int discarded;
X    
X    /* get some cursors for rectangle formation */
X!   pointer = XCreateFontCursor(hDisplay, XC_crosshair);
X  
X    /* grab the pointer */
X    if (GrabSuccess != XGrabPointer(hDisplay, hRoot, False, ButtonPressMask,
X!         GrabModeAsync, GrabModeAsync, hRoot, pointer, CurrentTime)) {
X      fprintf(stderr,"%s - could not grab pointer!\n", programName);
X      exit(3);
X    }
X--- 398,409 ----
X    int discarded;
X    
X    /* get some cursors for rectangle formation */
X!   pointer1 = XCreateFontCursor(hDisplay, XC_ul_angle);
X!   pointer2 = XCreateFontCursor(hDisplay, XC_lr_angle);
X  
X    /* grab the pointer */
X    if (GrabSuccess != XGrabPointer(hDisplay, hRoot, False, ButtonPressMask,
X!         GrabModeAsync, GrabModeAsync, hRoot, pointer1, CurrentTime)) {
X      fprintf(stderr,"%s - could not grab pointer!\n", programName);
X      exit(3);
X    }
X***************
X*** 415,421 ****
X    
X    /* get pointer motion events */
X    XChangeActivePointerGrab(hDisplay, ButtonMotionMask | ButtonReleaseMask,
X!         pointer, CurrentTime);
X  
X  
X    /* MAKE_RECT converts the original root coordinates and the event root
X--- 425,431 ----
X    
X    /* get pointer motion events */
X    XChangeActivePointerGrab(hDisplay, ButtonMotionMask | ButtonReleaseMask,
X!         pointer2, CurrentTime);
X  
X  
X    /* MAKE_RECT converts the original root coordinates and the event root
X***************
X*** 444,450 ****
X          MAKE_RECT(xbutton);
X          /* release resources */
X          XFreeGC(hDisplay, gc);
X!         XFreeCursor(hDisplay, pointer);
X          xrect->x      = rx;
X          xrect->y      = ry;
X          xrect->width  = rw;
X--- 454,461 ----
X          MAKE_RECT(xbutton);
X          /* release resources */
X          XFreeGC(hDisplay, gc);
X!         XFreeCursor(hDisplay, pointer1);
X!         XFreeCursor(hDisplay, pointer2);
X          xrect->x      = rx;
X          xrect->y      = ry;
X          xrect->width  = rw;
X***************
X*** 474,480 ****
X--- 485,610 ----
X  
X  
X  
X+ 
X+ 
X  /*
X+  * choose a window as in xwd
X+  */
X+ 
X+ Window getWindow() {
X+   int status;
X+   Cursor cursor;
X+   XEvent event;
X+   Window result;
X+ 
X+   result = None;
X+ 
X+   cursor = XCreateFontCursor(hDisplay, XC_target);
X+ 
X+   status = XGrabPointer(hDisplay, hRoot, FALSE,
X+          ButtonPressMask|ButtonReleaseMask, GrabModeSync,
X+          GrabModeAsync, None, cursor, CurrentTime);
X+   if (status != GrabSuccess) {
X+     fprintf(stderr, "%s: can't grab mouse\n", programName);
X+     exit(3);
X+   }
X+ 
X+   while (TRUE) {
X+     XAllowEvents(hDisplay, SyncPointer, CurrentTime);
X+     XWindowEvent(hDisplay, hRoot, ButtonPressMask|ButtonReleaseMask, &event);
X+   
X+     switch (event.type) {
X+       case ButtonRelease:
X+         result = event.xbutton.subwindow;
X+         if (result == None)
X+           result = hRoot;
X+         XUngrabPointer(hDisplay, CurrentTime);      /* Done with pointer */
X+         return result;
X+         break;
X+     }
X+   }
X+ }
X+ 
X+ 
X+ 
X+ 
X+ 
X+ 
X+ 
X+ #ifdef MEMCPY
X+ 
X+ /* memcpy and memset routines from C News */
X+ 
X+ 
X+ /*
X+  * memcpy - copy bytes
X+  */
X+ 
X+ char *
X+ memcpy(dst, src, size)
X+ char * dst;
X+  char * src;
X+ int size;
X+ {
X+         register char *d;
X+         register  char *s;
X+         register int n;
X+ 
X+         if (size <= 0)
X+                 return(dst);
X+ 
X+         s = src;
X+         d = dst;
X+         if (s <= d && s + (size-1) >= d) {
X+                 /* Overlap, must copy right-to-left. */
X+                 s += size-1;
X+                 d += size-1;
X+                 for (n = size; n > 0; n--)
X+                         *d-- = *s--;
X+         } else
X+                 for (n = size; n > 0; n--)
X+                         *d++ = *s++;
X+ 
X+         return(dst);
X+ }
X+ 
X+ /*
X+  * memset - set bytes
X+  *
X+  * CHARBITS should be defined only if the compiler lacks "unsigned char".
X+  * It should be a mask, e.g. 0377 for an 8-bit machine.
X+  */
X+ 
X+ #ifndef CHARBITS
X+ #       define  UNSCHAR(c)      ((unsigned char)(c))
X+ #else
X+ #       define  UNSCHAR(c)      ((c)&CHARBITS)
X+ #endif
X+ 
X+ char *
X+ memset(s, ucharfill, size)
X+  char * s;
X+ register int ucharfill;
X+ int size;
X+ {
X+         register  char *scan;
X+         register int n;
X+         register int uc;
X+ 
X+         scan = s;
X+         uc = UNSCHAR(ucharfill);
X+         for (n = size; n > 0; n--)
X+                 *scan++ = uc;
X+ 
X+         return(s);
X+ }
X+ #endif /* MEMCPY */
X+ 
X+ 
X+ 
X+ 
X+ 
X+ /*
X   * convert a pixmap image into a bitmap image
X   */
X  pixmap2bitmap(image)
X***************
X*** 583,608 ****
X    0x0, 0x0, 0x0, 0x0
X  };
X  
X- static byte DitherRevBits[GRAYS][4] = {  /* DitherBits with LSBFirst */
X-   0xf, 0xf, 0xf, 0xf,
X-   0x7, 0xf, 0xf, 0xf,
X-   0x7, 0xf, 0xd, 0xf,
X-   0x5, 0xf, 0xd, 0xf,
X-   0x5, 0xf, 0x5, 0xf,
X-   0x5, 0xb, 0x5, 0xf,
X-   0x5, 0xb, 0x5, 0xe,
X-   0x5, 0xa, 0x5, 0xe,
X-   0x5, 0xa, 0x5, 0xa,
X-   0x1, 0xa, 0x5, 0xa,
X-   0x1, 0xa, 0x4, 0xa,
X-   0x0, 0xa, 0x4, 0xa,
X-   0x0, 0xa, 0x0, 0xa,
X-   0x0, 0x2, 0x0, 0xa,
X-   0x0, 0x2, 0x0, 0x8,
X-   0x0, 0x0, 0x0, 0x8,
X-   0x0, 0x0, 0x0, 0x0
X- };
X- 
X  /* halftone or dither a color image, changing it into a monochrome
X   * image
X   */
X--- 713,718 ----
X***************
X*** 647,652 ****
X--- 757,764 ----
X      exit(3);
X    }
X  
X+   /* DitherBits is set up for MSBFirst use, so force this in the image */
X+   newImage->bitmap_bit_order = MSBFirst;
X  
X    /* if the number of possible pixels isn't very large, build an array
X     * which we index by the pixel value to find the dither array index
X***************
X*** 698,711 ****
X           * whether x is odd or not.  an 8x8 array wouldn't even need that,
X           * but blowing an image up by 64x is probably not a feature.
X           */
X!         ditherBits = reversed? &(DitherRevBits[dindex][0])
X!                              : &(DitherBits[dindex][0]);
X          x4 = x * 4;
X          y4 = y * 4;
X          for (h= 0; h < 4; h++) {
X            bits = ditherBits[h];
X            for (w=0; w < 4; w++)
X!             XPutPixel(newImage, x4+w, y4+h, (bits >> 0) & 1);
X          }
X        }
X      }
X--- 810,822 ----
X           * whether x is odd or not.  an 8x8 array wouldn't even need that,
X           * but blowing an image up by 64x is probably not a feature.
X           */
X!         ditherBits = &(DitherBits[dindex][0]);
X          x4 = x * 4;
X          y4 = y * 4;
X          for (h= 0; h < 4; h++) {
X            bits = ditherBits[h];
X            for (w=0; w < 4; w++)
X!             XPutPixel(newImage, x4+w, y4+h, (bits >> w) & 1);
X          }
X        }
X      }
X***************
X*** 773,779 ****
X  
X  
X  
X! /* swap some long ints */
X  swapdws (bp, n)
X    register char *bp;
X    register unsigned n;
X--- 884,890 ----
X  
X  
X  
X! /* swap some long ints.  (n is number of BYTES, not number of longs) */
X  swapdws (bp, n)
X    register char *bp;
X    register unsigned n;
X***************
X*** 817,840 ****
X  
X  
X  
X  /*
X   * Write an image in Postscript format
X   */
X! writePostscript(image, outfile)
X    imageInfo *image;
X  {
X    XImage *ximage = image->ximage;
X    XImage *psimage;
X!   double xdpi, ydpi, xscale, yscale;
X!   byte b, *ptr, lmax;
X!   int lm3;
X!   int x, y, i;
X    int depth, bpl, spb;
X    int reverse;
X-   int rle, firstrle;
X-   byte rlecount, rlebyte;
X-   dw  rletotal;
X    long p;
X    
X    if (verbose)
X      fprintf(stderr, "%s: formatting Postscript output\n", programName);
X--- 928,1022 ----
X  
X  
X  
X+ 
X+ 
X+ /* macros for run-length encoding of Postscript output */
X+ 
X+ #define FLUSH(stream) {                                             \
X+   if (rlecount) {                                                   \
X+     rletotal += 1 + (repeating? 1 : rlecount);                      \
X+     rlecount = 0;                                                   \
X+   }                                                                 \
X+ }
X+ 
X+ 
X+ #define START_ENCODING {                                            \
X+   firstrle   = TRUE;                                                \
X+   rletotal   = 0;                                                   \
X+   widthcount = 0;                                                   \
X+ }
X+ 
X+ 
X+ #define ENCODE(b, stream) {                                         \
X+   if (firstrle) {                                                   \
X+     rlebytes[0] = b;                                                \
X+     rlecount    = 1;                                                \
X+     repeating   = TRUE;                                             \
X+     firstrle    = FALSE;                                            \
X+   }                                                                 \
X+   else if (repeating) {                                             \
X+     if (b != rlebytes[0] || rlecount == 0x80) {                     \
X+       FLUSH(stream);                                                \
X+       repeating   = FALSE;                                          \
X+       rlebytes[0] = b;                                              \
X+       rlecount    = 1;                                              \
X+     }                                                               \
X+     else                                                            \
X+       rlecount++;                                                   \
X+   }                                                                 \
X+   else {                                                            \
X+     if (rlecount && b == rlebytes[rlecount-1]) {                    \
X+       rlecount--;       /* get back the matching byte */            \
X+       FLUSH(stream);                                                \
X+       rlebytes[0] = b;                                              \
X+       rlecount    = 2;                                              \
X+       repeating   = TRUE;                                           \
X+     }                                                               \
X+     else {                                                          \
X+       if (rlecount == 0x80)                                         \
X+         FLUSH(stream);                                              \
X+       rlebytes[rlecount++] = b;                                     \
X+     }                                                               \
X+   }                                                                 \
X+ }
X+ 
X+ #define FINISH_ENCODING(stream) {                                   \
X+   if (!firstrle)                                                    \
X+     FLUSH(stream);                                                  \
X+   if (widthcount)                                                   \
X+     fputc('\n', stream);                                            \
X+ }
X+ 
X+ 
X+ 
X+ 
X+ 
X  /*
X   * Write an image in Postscript format
X   */
X! writePostscript(image, outfile, encode, encapsulate)
X    imageInfo *image;
X+   FILE *outfile;
X+   int encode;       /* TRUE if we're to encode the Postscript output */
X+   int encapsulate;  /* TRUE if encapsulated Postscript output is wanted */
X  {
X+   register byte b, *ptr;
X+   register int i;
X    XImage *ximage = image->ximage;
X    XImage *psimage;
X!   double xdpi, ydpi, xscale, yscale, f;
X!   int lshift, lmask;
X!   int x, y;
X    int depth, bpl, spb;
X    int reverse;
X    long p;
X+   /* rle variables */
X+   int repeating;
X+   int firstrle;
X+   int rlecount;
X+   dw  rletotal;
X+   byte rlebytes[128];
X+   int widthcount;
X    
X    if (verbose)
X      fprintf(stderr, "%s: formatting Postscript output\n", programName);
X***************
X*** 846,851 ****
X--- 1028,1034 ----
X    if (depth < 8 && depth > 4) depth = 8;
X    if (depth == 3) depth = 4;
X  
X+ 
X    bpl = ((ximage->width * depth) + 7) / 8;
X  
X    if (depth == 1)
X***************
X*** 854,860 ****
X      /* colors have to be changed to luminescence */
X      ptr = (byte *)malloc(ximage->height * bpl);
X      psimage = XCreateImage(hDisplay, DefaultVisual(hDisplay, hScreen),
X!                   depth, depth>1? ZPixmap : XYPixmap,
X                    0, ptr,
X                    ximage->width, ximage->height,
X                    0, bpl);
X--- 1037,1043 ----
X      /* colors have to be changed to luminescence */
X      ptr = (byte *)malloc(ximage->height * bpl);
X      psimage = XCreateImage(hDisplay, DefaultVisual(hDisplay, hScreen),
X!                   depth, ZPixmap,
X                    0, ptr,
X                    ximage->width, ximage->height,
X                    0, bpl);
X***************
X*** 863,927 ****
X          programName);
X        exit(3);
X      }
X    }
X    
X    spb = 8 / psimage->bits_per_pixel;    /* samples per byte */
X  
X    if (depth > 1) {
X!     /* translate colors into luminescence */
X!     lmax = (1 << psimage->bits_per_pixel) - 1;
X!     lm3   = 3 * lmax;
X      for (y = 0; y < ximage->height; y++) {
X        for (x = 0; x < ximage->width; x++) {
X          p = XGetPixel(ximage, x, y);
X          i = (dw)image->red[p]+(dw)image->green[p]+(dw)image->blue[p];
X!         i = (i * lmax) / lm3;
X          XPutPixel(psimage, x, y, i);
X        }
X      }
X    }
X!   
X!   /* see if the image will benefit from run-length encoding */
X!   rlecount = 0xff;
X!   rletotal = 0;
X!   for (y=0; y<psimage->height; y++) {
X!     for (x=0, ptr=(byte *)(psimage->data+(y * psimage->bytes_per_line));
X!          x<psimage->width;
X!          x+=spb, ptr++) {
X!       b = *ptr;
X!       if (b != rlebyte || rlecount == 0xff) {
X!         rletotal += 2;
X!         rlecount = 0;
X!         rlebyte  = b;
X        }
X!       else
X!         rlecount++;
X!     }
X    }
X!   rle = rletotal < psimage->height * bpl;
X  
X-   fprintf(outfile, "%%!\n");
X-   fprintf(outfile, "%%\n");
X-   fprintf(outfile, "%% Xgrabsc Postscript dump of image '%s'\n", imageName);
X-   fprintf(outfile, "%%\n");
X-   fprintf(outfile, "%%\n");
X  
X!   if (rle) {
X!     fprintf(outfile, "%% run-length encoded.  Savings = %d bytes\n",
X!             (psimage->height * bpl - rletotal) * 2);
X!     fprintf(outfile, "%%\n");
X!     fprintf(outfile, "%%\n");
X    }
X  
X    /* standard inch procedure */
X    fputs("/inch {72 mul} def\n", outfile);
X  
X-   /* define a string to hold image lines */
X-   fprintf(outfile, "/picstr %d string def\n", bpl);
X    
X!   /* define a string to hold run-length-encoded pairs */
X!   if (rle)
X!     fputs("/rlebuffer 2 string def\n", outfile);
X  
X    /* define the image plotting procedure */
X    fputs("/plotimage\n", outfile);
X--- 1046,1121 ----
X          programName);
X        exit(3);
X      }
X+     /* force the bits_per_pixel to be what is needed */
X+     psimage->bits_per_pixel = depth;
X    }
X    
X    spb = 8 / psimage->bits_per_pixel;    /* samples per byte */
X  
X    if (depth > 1) {
X!     /* translate colors into grays */
X!     lshift = 16 - psimage->bits_per_pixel;
X!     lmask  = (1 << psimage->bits_per_pixel) - 1;
X      for (y = 0; y < ximage->height; y++) {
X        for (x = 0; x < ximage->width; x++) {
X          p = XGetPixel(ximage, x, y);
X          i = (dw)image->red[p]+(dw)image->green[p]+(dw)image->blue[p];
X!         i = ((i / 3) >> lshift) & lmask;
X          XPutPixel(psimage, x, y, i);
X        }
X      }
X    }
X! 
X! 
X! #ifndef NO_RLE_CHECKS
X!   if (encode) {
X!     START_ENCODING
X!     for (y=0; y<psimage->height; y++)
X!       for (x=0, ptr=(byte *)(psimage->data + (y * psimage->bytes_per_line));
X!            x<psimage->width; x+=spb, ptr++) {
X!         b = *ptr;
X!         ENCODE(b, outfile)
X        }
X!     FINISH_ENCODING(outfile)
X!     f = (float)(rletotal) / (float)(psimage->height*bpl);
X!     if (verbose)
X!       fprintf(stderr, "%s: encoding would change to %5.1f%% of orig size\n",
X!             programName, f * 100.0);
X!     encode = f <= 0.95;
X    }
X! #endif
X  
X  
X! 
X!   if (verbose)
X!     fprintf(stderr, "%s: image will %sbe encoded\n", programName,
X!             encode? "" : "not ");
X! 
X!   if (encapsulate) {
X!     fprintf(outfile, "%%!PS-Adobe-2.0 EPSF-1.2\n");
X!     fprintf(outfile, "%%%%BoundingBox: %d %d %d %d\n",
X!                 0, 0, psimage->width, psimage->height);
X    }
X+   else
X+     fprintf(outfile, "%%!\n");
X  
X+   fprintf(outfile, "%%%%Creator: xgrabsc\n");
X+   fprintf(outfile, "%%%%Title: %s\n", imageName);
X+   time(&p);
X+   fprintf(outfile, "%%%%CreationDate: %s", ctime(&p));
X+   fprintf(outfile, "%%%%EndComments\n");
X+   fprintf(outfile, "%%\n");
X+   fprintf(outfile, "%%\n");
X+ 
X    /* standard inch procedure */
X    fputs("/inch {72 mul} def\n", outfile);
X  
X    
X!   /* define a string to hold image bytes */
X!   if (encode)
X!     fputs("/rlebuffer 1 string def\n", outfile);
X!   else
X!     fprintf(outfile, "/picstr %d string def\n", bpl);
X  
X    /* define the image plotting procedure */
X    fputs("/plotimage\n", outfile);
X***************
X*** 932,949 ****
X            psimage->width, psimage->height, psimage->height);
X    
X      /* line reading function  */
X!     if (rle) {
X!       fputs("  { currentfile rlebuffer readhexstring pop pop\n", outfile);
X!       fputs("    /nsamples rlebuffer 0 get 1 add store\n", outfile);
X!       fputs("    /lum      rlebuffer 1 get store\n", outfile);
X!       fputs("    /samples  nsamples string store\n", outfile);
X!       fputs("    0 1 nsamples -1 add { samples exch lum put } for\n",
X!             outfile);
X!       fputs("    samples\n", outfile);
X!       fputs("  }\n", outfile);
X!     }
X!     else
X!       fputs("  {currentfile picstr readhexstring pop}\n", outfile);
X    
X    fputs("  image\n} def\n", outfile);
X    
X--- 1126,1155 ----
X            psimage->width, psimage->height, psimage->height);
X    
X      /* line reading function  */
X! 
X!   if (encode) {
X!     fputs("% run-length decoding block\n", outfile);
X!     fputs("  { currentfile rlebuffer readhexstring pop pop\n", outfile);
X!     fputs("%   top bit of first byte states whether the following byte\n", outfile);
X!     fputs("%   is repeated, or if there is a run of non-repeated bytes\n", outfile);
X!     fputs("    rlebuffer 0 get dup /nsamples exch store\n", outfile);
X!     fputs("    -7 bitshift 1 eq {\n", outfile);
X!     fputs("%     run of unrepeated bytes\n", outfile);
X!     fputs("      /samples  nsamples 127 and 1 add string store\n", outfile);
X!     fputs("      currentfile samples readhexstring pop \n", outfile);
X!     fputs("    } {\n", outfile);
X!     fputs("%     repeated byte\n", outfile);
X!     fputs("      /nsamples nsamples 1 add store\n", outfile);
X!     fputs("      currentfile rlebuffer readhexstring pop pop\n", outfile);
X!     fputs("      /lum      rlebuffer 0 get store\n", outfile);
X!     fputs("      /samples  nsamples string store\n", outfile);
X!     fputs("      0 1 nsamples -1 add { samples exch lum put } for\n", outfile);
X!     fputs("      samples\n", outfile);
X!     fputs("    } ifelse\n", outfile);
X!     fputs("  }\n", outfile);
X!   }
X!   else
X!     fputs("  {currentfile picstr readhexstring pop}\n", outfile);
X    
X    fputs("  image\n} def\n", outfile);
X    
X***************
X*** 951,982 ****
X    /* save context and move to a nice origin */
X    fputs("gsave\n", outfile);
X    
X! 
X!   /* scale the image */
X!   xdpi = (((double)DisplayWidth(hDisplay,hScreen)) * 25.4) /
X!           ((double)DisplayWidthMM(hDisplay,hScreen));
X!   ydpi = (((double)DisplayHeight(hDisplay,hScreen)) * 25.4) /
X!           ((double)DisplayHeightMM(hDisplay,hScreen));
X!   xscale = ((double)psimage->width) / xdpi;
X!   yscale = ((double)psimage->height) / ydpi;
X!   if (xscale > 7.5) {
X!     yscale *= 7.5 / xscale;
X!     xscale = 7.5;
X    }
X!   else if (yscale > 10.0) {
X!     xscale *= 10.0 / yscale;
X!     yscale = 10.0;
X    }
X!   fprintf(outfile, "%1.2g inch %1.2g inch translate\n",
X!                 (8.5 - xscale) / 2.0, (11.0 - yscale) / 2.0);
X!   fprintf(outfile, "%1.2g inch %1.2g inch scale\n", xscale, yscale);
X!   
X    fputs("plotimage\n", outfile);
X    
X  
X    reverse = depth == 1? BlackPixel(hDisplay,hScreen)==1 : FALSE;
X!   rletotal = 0;
X!   rlecount = 0xff;
X    for (y=0; y<psimage->height; y++) {
X      for (x=0, ptr=(byte *)(psimage->data+(y * psimage->bytes_per_line));
X           x<psimage->width;
X--- 1157,1226 ----
X    /* save context and move to a nice origin */
X    fputs("gsave\n", outfile);
X    
X!   if (encapsulate) {
X!     /* for encapsulated postscript, we need a scale factor that is equal
X!      * to the image width/height in samples */
X!     fprintf(outfile, "%d %d scale\n", psimage->width, psimage->height);
X    }
X!   else {
X!     /* For physical output we need a scale factor that will create
X!      * the same size image, and we need to center it on the page.
X!      *   -Figure out the physical dimensions on the screen
X!      *    and make it come out the same on the printer.
X!      *   -Use inch units and assume the paper is 8.5x11.0.
X!      *   (future change: allow selection of paper size and margins)        */
X!     xdpi = (((double)DisplayWidth(hDisplay,hScreen)) * 25.4) /
X!             ((double)DisplayWidthMM(hDisplay,hScreen));
X!     ydpi = (((double)DisplayHeight(hDisplay,hScreen)) * 25.4) /
X!             ((double)DisplayHeightMM(hDisplay,hScreen));
X!     xscale = ((double)psimage->width) / xdpi;
X!     yscale = ((double)psimage->height) / ydpi;
X!     if (xscale > 7.5) {
X!       yscale *= 7.5 / xscale;
X!       xscale = 7.5;
X!     }
X!     else if (yscale > 10.0) {
X!       xscale *= 10.0 / yscale;
X!       yscale = 10.0;
X!     }
X!     fprintf(outfile, "%1.2g inch %1.2g inch translate\n",
X!                   (8.5 - xscale) / 2.0, (11.0 - yscale) / 2.0);
X!     fprintf(outfile, "%1.2g inch %1.2g inch scale\n", xscale, yscale);
X    }
X! 
X    fputs("plotimage\n", outfile);
X    
X  
X+ 
X+ /* redefine the flush macro to do some actual writing now */
X+ #undef FLUSH
X+ #define FLUSH(stream) {                                             \
X+   if (rlecount && widthcount > 40) {                                \
X+     fputc('\n', stream);                                            \
X+     widthcount = 0;                                                 \
X+   }                                                                 \
X+   if (rlecount) {                                                   \
X+     fprintf(stream, "%02x", (rlecount-1) | (repeating? 0 : 0x80));  \
X+     if (repeating) {                                                \
X+       fprintf(stream, "%02x", rlebytes[0]);                         \
X+       widthcount += 2;                                              \
X+     }                                                               \
X+     else {                                                          \
X+       for (i=0; i<rlecount; i++)                                    \
X+         fprintf(stream, "%02x", rlebytes[i]);                       \
X+       widthcount += 1 + rlecount;                                   \
X+     }                                                               \
X+   }                                                                 \
X+   if (rlecount) {                                                   \
X+     rletotal += 1 + (repeating? 1 : rlecount);                      \
X+     rlecount = 0;                                                   \
X+   }                                                                 \
X+ }
X+ 
X+ 
X    reverse = depth == 1? BlackPixel(hDisplay,hScreen)==1 : FALSE;
X!   if (encode)
X!     START_ENCODING
X    for (y=0; y<psimage->height; y++) {
X      for (x=0, ptr=(byte *)(psimage->data+(y * psimage->bytes_per_line));
X           x<psimage->width;
X***************
X*** 985,1012 ****
X        if (reverse) b = ~b;
X        if (depth == 1  &&  psimage->bitmap_bit_order == LSBFirst)
X          b = swapbits(b);
X!       if (rle) {
X!         if (b != rlebyte  ||  rlecount == 0xff) {
X!           if (rletotal)  /* == 0 first time through main loop */
X!             fprintf(outfile, "%02x%02x", rlecount, rlebyte);
X!           rletotal += 2;
X!           if (rletotal % 200 == 0)
X!             fputs("\n", outfile);
X!           rlecount = 0;
X!           rlebyte  = b;
X!         }
X!         else
X!           rlecount++;
X!       }
X        else
X          fprintf(outfile, "%02x", b);
X      }
X!     if (!rle)
X        fputs("\n", outfile);
X    }
X-   if (rle  &&  rletotal)
X-     fprintf(outfile, "%02x%02x\n", rlecount, rlebyte);
X  
X    fputs("\n\n\ngrestore\nshowpage\n", outfile);
X  
X  
X--- 1229,1251 ----
X        if (reverse) b = ~b;
X        if (depth == 1  &&  psimage->bitmap_bit_order == LSBFirst)
X          b = swapbits(b);
X!       if (encode)
X!         ENCODE(b,outfile)
X        else
X          fprintf(outfile, "%02x", b);
X      }
X!     if (!encode)
X        fputs("\n", outfile);
X    }
X  
X+   if (encode) {
X+     FINISH_ENCODING(outfile)
X+     fputs("%\n", outfile);
X+     fprintf(outfile, "%% Run-length encoding savings = %5.1f%%\n",
X+           100.0 - ((float)(rletotal) * 100.0 / (float)(psimage->height * bpl)));
X+     fputs("%\n", outfile);
X+   }
X+ 
X    fputs("\n\n\ngrestore\nshowpage\n", outfile);
X  
X  
X***************
X*** 1131,1138 ****
X      color.blue  = image->blue[i];
X      color.flags = visMask;
X      color.pad   = 0;
X!     if (*(char *) &swaptest)
X!       swapwords(&color, sizeof(XColor));
X      fwrite(&color, sizeof(XColor), 1, outfile);
X    }
X  
X--- 1370,1379 ----
X      color.blue  = image->blue[i];
X      color.flags = visMask;
X      color.pad   = 0;
X!     if (*(char *) &swaptest) {
X!       swapdws(&color.pixel, sizeof(color.pixel));
X!       swapwords(&color.red, 3 * sizeof(color.red)); /* assume g and b follow r */
X!     }
X      fwrite(&color, sizeof(XColor), 1, outfile);
X    }
X  
X***************
X*** 1261,1282 ****
X    int argc;
X    char *argv[];
X  {
X    FILE *outfile;
X    char *outfileName;
X    XRectangle xrect;
X    imageInfo image;
X!   int doAnd, doOr, depth;
X    int puzzle, xWD, brighten, postscript;
X    int forceBitmap, grabServer;
X    int dither, halftone;
X    int sleepSeconds;
X    int andBits, orBits;
X!   char c;
X    char *ptr;
X    char *display;
X!   int i, nr, nc;
X!   extern char *optarg;
X    int brightenFactor;
X    
X    outfile     = stdout;
X    outfileName = NULL;
X--- 1502,1529 ----
X    int argc;
X    char *argv[];
X  {
X+   extern char *optarg;
X    FILE *outfile;
X    char *outfileName;
X    XRectangle xrect;
X    imageInfo image;
X!   int doAnd, doOr;
X!   int depth;
X    int puzzle, xWD, brighten, postscript;
X    int forceBitmap, grabServer;
X    int dither, halftone;
X+   int compress;
X    int sleepSeconds;
X    int andBits, orBits;
X!   int encapsulate;
X!   int sourceRoot, sourceId, sourceWd;
X!   Window sourceWindow;
X!   long ignored;
X    char *ptr;
X    char *display;
X!   int x, y, width, height, border, i, nr, nc;
X    int brightenFactor;
X+   int c;
X    
X    outfile     = stdout;
X    outfileName = NULL;
X***************
X*** 1289,1301 ****
X    dither      = FALSE;
X    grabServer  = TRUE;
X    postscript  = FALSE;
X    doAnd       = FALSE;
X    doOr        = FALSE;
X    sleepSeconds= 0;
X    display     = NULL;
X    verbose     = FALSE;
X    
X!   while ((c = getopt(argc, argv, "d:no:s:v b:A:BDHO: PWZ")) != EOF)
X      switch (c) {
X        case 'd':
X          display = optarg;
X--- 1536,1554 ----
X    dither      = FALSE;
X    grabServer  = TRUE;
X    postscript  = FALSE;
X+   encapsulate = FALSE;
X+   compress    = TRUE;
X    doAnd       = FALSE;
X    doOr        = FALSE;
X    sleepSeconds= 0;
X    display     = NULL;
X    verbose     = FALSE;
X+   sourceId    = FALSE;
X+   sourceWd    = FALSE;
X+   sourceRoot  = FALSE;
X    
X! 
X!   while ((c = getopt(argc, argv, "d:no:s:v cri:w b:A:BDHO: EPWZ")) != EOF)
X      switch (c) {
X        case 'd':
X          display = optarg;
X***************
X*** 1315,1322 ****
X--- 1568,1613 ----
X          break;
X  
X  
X+       case 'c':
X+         compress = FALSE;
X+         goto pslabel;
X+         break;
X+       case 'r':
X+         sourceRoot = TRUE;
X+         if (sourceWd || sourceId) {
X+           fprintf(stderr,
X+             "%s: multiple window sources not allowed - using root window\n",
X+             programName);
X+           sourceWd = sourceId = FALSE;
X+         }
X+         break;
X+       case 'i':
X+         sourceId = TRUE;
X+         if (sourceRoot || sourceWd) {
X+           fprintf(stderr,
X+             "%s: multiple window sources not allowed - using window id\n",
X+             programName);
X+           sourceRoot = sourceWd = FALSE;
X+         }
X+         sourceWindow = 0;
X+         if (!sscanf(optarg, "0x%lx", &sourceWindow))
X+           if (!sscanf(optarg, "%ld", &sourceWindow)) {
X+             sprintf(stderr, "%s: invalid window id\n", programName);
X+             exit(3);
X+           }
X+         break;
X+       case 'w':
X+         sourceWd = TRUE;
X+         if (sourceRoot || sourceId) {
X+           fprintf(stderr,
X+             "%s: multiple window sources not allowed - using xwd-style\n",
X+             programName);
X+           sourceRoot = sourceId = FALSE;
X+         }
X+         break;
X  
X  
X+ 
X        case 'A':
X          andBits = atoi(optarg);
X          doAnd = TRUE;
X***************
X*** 1359,1365 ****
X--- 1650,1659 ----
X  
X  
X  
X+       case 'E':
X+         encapsulate = TRUE;
X        case 'P':
X+ pslabel:
X          postscript = TRUE;
X          if (xWD | puzzle) {
X            fprintf(stderr,
X***************
X*** 1372,1378 ****
X          xWD = TRUE;
X          if (puzzle | postscript) {
X            fprintf(stderr,
X!             "%s: can't do both puzzle and XWD output.  Using XWD.\n",
X              programName);
X            puzzle = postscript = FALSE;
X          }
X--- 1666,1672 ----
X          xWD = TRUE;
X          if (puzzle | postscript) {
X            fprintf(stderr,
X!             "%s: only one output format allowed.  Using XWD.\n",
X              programName);
X            puzzle = postscript = FALSE;
X          }
X***************
X*** 1413,1434 ****
X    if (grabServer)
X      XGrabServer(hDisplay);
X  
X!   /* let the user drag out a rectangle on the screen */
X!   if (!getRectangle(&xrect)) {
X      XCloseDisplay(hDisplay);
X      exit(3);
X    }
X    
X    /* get the image bounded by the rectangle */
X!   if (!getImage(&xrect, &image)) {
X      XCloseDisplay(hDisplay);
X      exit(3);
X    }
X  
X!   if (grabServer) {
X      XUngrabServer(hDisplay);
X!     XFlush(hDisplay);
X!   }
X  
X    /* do color image processing/conversions */
X    if (depth >= 2) {
X--- 1707,1760 ----
X    if (grabServer)
X      XGrabServer(hDisplay);
X  
X! 
X! 
X!   /* get the source rectangle */
X!   sourceWindow = hRoot;
X!   if (sourceRoot) {
X!     xrect.x = xrect.y = 0;
X!     xrect.width  = DisplayWidth(hDisplay, hScreen);
X!     xrect.height = DisplayHeight(hDisplay, hScreen);
X!   }
X!   else if (sourceId || sourceWd) {
X!     if (sourceWd && !(sourceWindow=getWindow())) {
X!       fprintf(stderr, "%s: unable to find source window\n", programName);
X!       XCloseDisplay(hDisplay);
X!       exit(3);
X!     }
X!     /* get window widthXheight */
X!     if (!XGetGeometry(hDisplay, sourceWindow, &ignored,
X!          &ignored, &ignored, &width, &height, &ignored, &border)) {
X!       fprintf(stderr, "%s: unable to get window coordinates\n", programName);
X!       XCloseDisplay(hDisplay);
X!       exit(3);
X!     }
X!     xrect.width  = width;
X!     xrect.height = height;
X!     xrect.x      = 0;
X!     xrect.y      = 0;
X!   }
X!   else if (!getRectangle(&xrect)) {
X      XCloseDisplay(hDisplay);
X      exit(3);
X    }
X+ 
X+ 
X+ 
X    
X    /* get the image bounded by the rectangle */
X!   XBell(hDisplay, 50);
X!   if (!getImage(&xrect, &image, sourceWindow)) {
X      XCloseDisplay(hDisplay);
X      exit(3);
X    }
X  
X!   if (grabServer)
X      XUngrabServer(hDisplay);
X!   
X!   XBell(hDisplay, 50);
X!   XBell(hDisplay, 50);
X!   XFlush(hDisplay);
X  
X    /* do color image processing/conversions */
X    if (depth >= 2) {
X***************
X*** 1470,1476 ****
X  
X    /* garbage in --> garbage out */
X    if (postscript)
X!     writePostscript(&image, outfile);
X    else if (xWD)
X      writeXWD(&image, outfile);
X    else if (puzzle)
X--- 1796,1802 ----
X  
X    /* garbage in --> garbage out */
X    if (postscript)
X!     writePostscript(&image, outfile, compress, encapsulate);
X    else if (xWD)
X      writeXWD(&image, outfile);
X    else if (puzzle)
X*** rls1/xgrabsc.man	Mon Sep 10 08:24:26 1990
X--- xgrabsc.man	Tue Sep  4 16:40:50 1990
X***************
X*** 2,12 ****
X  .\"
X  .\" Name - xgrabsc.man
X  .\"
X! .\" Version:	1.2
X  .\"
X! .\" ccsid:	@(#)xgrabsc.man	1.2 - 8/17/90 09:07:01
X  .\" from: 	ccs/s.xgrabsc.man
X! .\" date: 	8/20/90 09:56:03
X  .\"
X  .\" Copyright (C) 1990, Bruce Schuchardt
X  .\" See the end of this document for full copyright information.
X--- 2,12 ----
X  .\"
X  .\" Name - xgrabsc.man
X  .\"
X! .\" Version:	1.3
X  .\"
X! .\" ccsid:	@(#)xgrabsc.man	1.3 - 9/4/90 16:36:48
X  .\" from: 	ccs/s.xgrabsc.man
X! .\" date: 	9/4/90 16:40:09
X  .\"
X  .\" Copyright (C) 1990, Bruce Schuchardt
X  .\" See the end of this document for full copyright information.
X***************
X*** 38,43 ****
X--- 38,46 ----
X  -d \fIdisplayName\fP
X  Use an alternate display.
X  .TP
X+ -i \fIwindow ID\fP
X+ Dump the window with the given ID.
X+ .TP
X  -n
X  Inhibit server grabs.  Normally xgrabsc will "grab" the server so
X  that the screen is frozen while a rectangle is selected and the image
X***************
X*** 47,52 ****
X--- 50,58 ----
X  -o \fIoutput-file\fP
X  Write output to \fIoutput-file\fP instead of standard output.
X  .TP
X+ -r
X+ Dump the entire screen (root window).
X+ .TP
X  -s \fIseconds\fP
X  Sleep for \fIseconds\fP seconds before commencing operation.  This
X  should be used if you need some time to get the target image ready.
X***************
X*** 53,58 ****
X--- 59,67 ----
X  .TP
X  -v
X  Display processing information on standard error output (stderr).
X+ .TP
X+ -w
X+ Use \fIxwd\fP style window selection and dump selected window.
X  .sp 3
X  .TP
X  -b \fIpercent\fR
X***************
X*** 88,98 ****
X--- 97,116 ----
X  a factor of four on both axes.
X  .sp 3
X  .TP
X+ -E
X+ Create Encapsulated Postscript output, rather than normal vanilla 
X+ Postscript.  This adds EPSF header comments and removes all scaling and 
X+ translation of the image, but otherwise acts like the \fIP\fP option.
X+ .TP
X  -P
X  Write output in \fIPostscript\fP format.  Output will be run-length-encoded
X  if encoding will result in any savings.  The number of bits per
X  Postscript sample is determined by the depth of the image.
X  .TP
X+ -c
X+ Suppress Postscript image run-length encoding.  This option is ignored
X+ unless the \fI-P\fP Postscript-output option is also specified.
X+ .TP
X  -W
X  Write output in \fIxwd\fP format.
X  .TP
X***************
X*** 144,154 ****
X  xgrabsc -Pb 130 | lpr
X  .sp
X  .PP
X! To write output in \fIpuzzle\fP format and read into the puzzle
X! program, use the commands
X  .sp
X  .ti +5
X! xgrabsc -Z >outfile.pzl
X  .br
X  .ti +5
X  puzzle -picture outfile.pzl
X--- 162,172 ----
X  xgrabsc -Pb 130 | lpr
X  .sp
X  .PP
X! To select an entire window, write output in \fIpuzzle\fP format 
X! and read into the puzzle program, use the commands
X  .sp
X  .ti +5
X! xgrabsc -wZ >outfile.pzl
X  .br
X  .ti +5
X  puzzle -picture outfile.pzl
X***************
X*** 191,201 ****
X  .sp
X  .SH AUTHOR
X  .nf
X! +----------------------------+
X! |     Bruce Schuchardt       |
X! |    Servio Corporation      |
X! |      bruce@slc.com         |
X! +----------------------------+
X  .fi
X  .sp 2
X  .SH ACKNOWLEGEMENTS
X--- 209,217 ----
X  .sp
X  .SH AUTHOR
X  .nf
X!      Bruce Schuchardt
X!     Servio Corporation
X!       bruce@slc.com
X  .fi
X  .sp 2
X  .SH ACKNOWLEGEMENTS
X*** rls1/patchlevel.h	Mon Sep 10 08:24:31 1990
X--- patchlevel.h	Tue Sep  4 16:42:21 1990
X***************
X*** 4,14 ****
X  *
X  * Name - patchlevel.h
X  *
X! * Version:	1.1
X  *
X! * ccsid:	@(#)patchlevel.h	1.1 - 8/16/90 09:12:36
X  * from: 	ccs/s.patchlevel.h
X! * date: 	8/20/90 09:56:01
X  *
X  * Copyright (C), 1990 Bruce Schuchardt
X  * See cpyright.h for full copyright information.
X--- 4,14 ----
X  *
X  * Name - patchlevel.h
X  *
X! * Version:	1.3
X  *
X! * ccsid:	@(#)patchlevel.h	1.3 - 9/4/90 16:41:35
X  * from: 	ccs/s.patchlevel.h
X! * date: 	9/4/90 16:41:40
X  *
X  * Copyright (C), 1990 Bruce Schuchardt
X  * See cpyright.h for full copyright information.
X***************
X*** 17,23 ****
X  *
X  *========================================================================*/
X  
X! #define XGRABSC_PATCHLEVEL 0
X  
X! 
X  #endif
X--- 17,23 ----
X  *
X  *========================================================================*/
X  
X! #define XGRABSC_PATCHLEVEL 1
X  
X! #define XGRABSC_VERSION "1.0 9/4/90 16:41:40"
X  #endif
X*** rls1/Imakefile	Mon Sep 10 08:24:22 1990
X--- Imakefile	Tue Sep  4 16:40:47 1990
X***************
X*** 2,12 ****
X   *
X   * Name - Imakefile
X   *
X!  * Version:	1.3
X   *
X!  * ccsid:	@(#)Imakefile	1.3 - 8/20/90 09:54:45
X   * from: 	ccs/s.Imakefile
X!  * date: 	8/20/90 09:55:58
X   *
X   * Description: imake file to build xgrabsc.  Use simple.mak if you
X   *              don't have imake.
X--- 2,12 ----
X   *
X   * Name - Imakefile
X   *
X!  * Version:	1.4
X   *
X!  * ccsid:	@(#)Imakefile	1.4 - 9/4/90 16:35:19
X   * from: 	ccs/s.Imakefile
X!  * date: 	9/4/90 16:40:06
X   *
X   * Description: imake file to build xgrabsc.  Use simple.mak if you
X   *              don't have imake.
X***************
X*** 14,34 ****
X   *========================================================================
X   */
X  
X- /* change INSTALL_PATH to the directory in which you want xgrabsc installed */
X- INSTALL_PATH    = /usr/bin/X11
X- 
X- /* change MAN_PATH to point to your man page top directory */
X- MAN_PATH        = /usr/man
X- /* change MAN_EXT to the section for xgrabsc */
X- MAN_EXT         = 1
X- 
X- /* if you trust your optimizer, change 'g' to 'O' */
X- CDEBUGFLAGS     = -g
X  LOCAL_LIBRARIES = $(XLIB)
X  
X  SimpleProgramTarget(xgrabsc)
X  
X- install::
X- 	$(INSTALL) -c -s xgrabsc $(INSTALL_PATH)
X- 	$(INSTALL) -c -m 644 xgrabsc.man \
X- 		$(MAN_PATH)/man$(MAN_EXT)/xgrabsc.$(MAN_EXT)X
X--- 14,20 ----
X*** rls1/README	Mon Sep 10 08:24:21 1990
X--- README	Tue Sep  4 16:40:48 1990
X***************
X*** 2,12 ****
X  *
X  * Name - README
X  *
X! * Version:	1.3
X  *
X! * ccsid:	@(#)README	1.3 - 8/20/90 09:55:04
X  * from: 	ccs/s.README
X! * date: 	8/20/90 09:55:59
X  *
X  * Copyright (C) 1990, Bruce Schuchardt
X  * See either the man page or the file cpyright.h for full copyright
X--- 2,12 ----
X  *
X  * Name - README
X  *
X! * Version:	1.4
X  *
X! * ccsid:	@(#)README	1.4 - 9/4/90 16:39:38
X  * from: 	ccs/s.README
X! * date: 	9/4/90 16:40:07
X  *
X  * Copyright (C) 1990, Bruce Schuchardt
X  * See either the man page or the file cpyright.h for full copyright
X***************
X*** 30,63 ****
X  The Postscript dumps will use run-length encoding if it results in
X  any savings in size.  A typical xterm window dump on a mono system
X  runs around 40K bytes.  An xwd dump on the same screen will be around
X! 650K bytes.
X  
X  The program should build easily enough.  If you don't have imake,
X! use simple.mak (i.e., make -f simple.mak).  For building, you 
X! should only have to alter the makefiles if your include files or 
X! libraries are in a non-standard location (/usr/include/X11, /usr/
X! lib).
X  
X! The makefiles will install xgrabsc in /usr/bin/X11 and the man page in
X! /usr/man/man1.  Change the makefile before installing if you don't like
X! these locations.
X  
X  
X  Please send comments, bugs and enhancements to bruce@slc.com.
X  
X  
X! Manifest
X! --------
X! README              this file
X  
X! Imakefile           Input for "imake" program
X! simple.mak          Simpler input for standard "make"
X  
X! cpyright.h          Copyright notice for this software (READ IT)
X! patchlevel.h        Current patch level
X! xgrabsc.c           Program source
X  
X! xgrabsc.man         Man page for xgrabsc
X  
X  
X  
X--- 30,65 ----
X  The Postscript dumps will use run-length encoding if it results in
X  any savings in size.  A typical xterm window dump on a mono system
X  runs around 40K bytes.  An xwd dump on the same screen will be around
X! 650K bytes.  While the xpr program has a "compress" option, it only
X! compresses white samples.
X  
X+ The puzzle program only supports the "picture" option for 8-plane
X+ systems, so please don't tell me that it doesn't work on your
X+ monochrome system.  I already know it doesn't.
X+ 
X  The program should build easily enough.  If you don't have imake,
X! use simple.mak (i.e., make -f simple.mak).
X  
X! The simple.mak file will install xgrabsc in /usr/bin/X11 and the 
X! man page in /usr/man/man1.  Change simple.mak before installing 
X! with it if you don't like these locations.
X  
X  
X  Please send comments, bugs and enhancements to bruce@slc.com.
X  
X  
X!  Manifest
X!  ---------------------------------
X!  README              this file
X  
X!  Imakefile           Input for "imake" program
X!  simple.mak          Simpler input for standard "make"
X  
X!  cpyright.h          Copyright notice for this software (READ IT)
X!  patchlevel.h        Current patch level
X!  xgrabsc.c           Program source
X  
X!  xgrabsc.man         Man page for xgrabsc
X  
X  
X  
X*** rls1/simple.mak	Mon Sep 10 08:24:32 1990
X--- simple.mak	Tue Sep  4 16:40:49 1990
X***************
X*** 2,17 ****
X  #
X  # Name - simple.mak
X  #
X! # Version:	1.3
X  #
X! # ccsid:	@(#)simple.mak	1.3 - 8/20/90 09:55:13
X  # from: 	ccs/s.simple.mak
X! # date: 	8/20/90 09:56:01
X  #
X  # Description: make file for xgrabsc.  Use "make -f simple.mak"
X  #
X  #=============================================================================
X  
X  
X  # change INSTALL_PATH to the directory in which you want xgrabsc installed
X  INSTALL_PATH    = /usr/bin/X11
X--- 2,18 ----
X  #
X  # Name - simple.mak
X  #
X! # Version:	1.4
X  #
X! # ccsid:	@(#)simple.mak	1.4 - 9/4/90 16:35:29
X  # from: 	ccs/s.simple.mak
X! # date: 	9/4/90 16:40:08
X  #
X  # Description: make file for xgrabsc.  Use "make -f simple.mak"
X  #
X  #=============================================================================
X  
X+ # CFLAGS = -g -DNO_RLE_CHECKS -DMEMCPY
X  
X  # change INSTALL_PATH to the directory in which you want xgrabsc installed
X  INSTALL_PATH    = /usr/bin/X11
X***************
X*** 21,29 ****
X  # change MAN_EXT to the section for xgrabsc
X  MAN_EXT         = 1
X  
X- # if you trust your optimizer, change 'g' to 'O'
X- CFLAGS  = -g
X- 
X  xgrabsc:: xgrabsc.o
X  	rm -f xgrabsc
X  	$(CC) $(CFLAGS) -o xgrabsc xgrabsc.o -lX11
X--- 22,27 ----
X***************
X*** 30,37 ****
X  
X  install::
X  	install -c -s xgrabsc $(INSTALL_PATH)
X  	install -c -m 644 xgrabsc.man \
X! 		$(MAN_PATH)/man$(MAN_EXT)/xgrabsc.$(MAN_EXT)X
X  
X  clean::
X  	rm -f core *.o xgrabsc *.log
X--- 28,37 ----
X  
X  install::
X  	install -c -s xgrabsc $(INSTALL_PATH)
X+ 
X+ install.man::
X  	install -c -m 644 xgrabsc.man \
X! 		$(MAN_PATH)/man$(MAN_EXT)/xgrabsc.$(MAN_EXT)
X  
X  clean::
X  	rm -f core *.o xgrabsc *.log
END_OF_FILE
if test 46079 -ne `wc -c <'patch1'`; then
    echo shar: \"'patch1'\" unpacked with wrong size!
fi
# end of 'patch1'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have the archive.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0


dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.