home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume18 / xgrabsc-2.1 / part01 next >
Encoding:
Internet Message Format  |  1992-07-23  |  52.3 KB

  1. Path: uunet!ogicse!uwm.edu!caen!sdd.hp.com!mips!msi!dcmartin
  2. From: bruce@SLC.COM (Bruce Schuchardt)
  3. Newsgroups: comp.sources.x
  4. Subject: v18i052: xgrabsc v2.1 - grab screen dump, Part01/05
  5. Message-ID: <csx-18i052-xgrabsc-2.1@uunet.UU.NET>
  6. Date: 23 Jul 92 14:01:26 GMT
  7. Article-I.D.: uunet.csx-18i052-xgrabsc-2.1
  8. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  9. Organization: Molecular Simulations, Inc.
  10. Lines: 1760
  11. Approved: dcmartin@msi.com
  12. Originator: dcmartin@fascet
  13.  
  14. Submitted-by: bruce@SLC.COM (Bruce Schuchardt)
  15. Posting-number: Volume 18, Issue 52
  16. Archive-name: xgrabsc-2.1/part01
  17.  
  18. INTRO TO xgrabsc
  19.  
  20. When I first wrote xgrabsc, there were a number of programs available
  21. for getting X-Window screen dumps (e.g., xwd and xwps), but they
  22. were all restricted to dumping a single window in a single format.
  23. I wrote xgrabsc in an effort to get around these restrictions.
  24.  
  25. The main contribution of this program is its use of root-window
  26. rubberbanding to allow capture of arbitrary portions of the screen,
  27. and its multiple output formats (x-bitmap, x-pixmap, xwd, puzzle,
  28. "simple", and several Postscript formats).
  29.  
  30. The Postscript dumps will use run-length encoding if it results in
  31. any savings in size.  A typical xterm window dump on a mono system
  32. runs around 40K bytes (20K for binary output).  An xwd dump on the
  33. same screen will be around 650K bytes.  While the xpr program has a
  34. "compress" option, it only compresses white samples.  Reducing the 
  35. size of the output increases the cost of computing the dump and the
  36. final printing of the dump, but it reduces the cost of storage and
  37. the time to transfer the dump to your printer.  The latter is
  38. especially important for large screen dumps.
  39.  
  40. This release (2.1) adds the following features:
  41.  
  42. * xgrabsc no longer uses getopt(), and most command line switches have been
  43.   changed from single-characters to keywords.  Users of previous versions
  44.   of xgrabsc should make sure any XGRABSC environment variables are updated
  45.   to reflect this change.
  46.   
  47. * Command line switches may be preceded with '-' (e.g., -preview) or
  48.   '--' (e.g., --preview).  A double dash turns off an option, while a
  49.   single or omitted dash turns on an option.  Each argument and switch must
  50.   be seperated with white space.
  51.  
  52. * New xgrabsc options
  53.  
  54.   preview    a preview option for encapsulated postscript output
  55.   page        page size and border specification
  56.   nodither    turns off any selected dithering options
  57.   colproc    adds/removes the colorImage operator from color postscript
  58.         output
  59.   bm3        write color output in XPM3 format
  60.  
  61. * All xgrab text fields but the Alternate Display are now set in XGrab.ad
  62.   instead of xgrab.c.  This means you can now put defaults for these fields
  63.   in your .Xdefaults
  64.  
  65. * border removal now attempts to remove the window-mgr's title as well.
  66.  
  67. #!/bin/sh
  68. # This is a shell archive (produced by shar 3.50)
  69. # To extract the files from this archive, save it to a file, remove
  70. # everything above the "!/bin/sh" line above, and type "sh file_name".
  71. #
  72. # made 07/23/1992 13:57 UTC by dcmartin@fascet
  73. # Source directory /home/fascet/dcmartin/csx/src/tmp/xgrabsc.2_1
  74. #
  75. # existing files will NOT be overwritten unless -c is specified
  76. #
  77. # This is part 1 of a multipart archive                                    
  78. # do not concatenate these parts, unpack them in order with /bin/sh        
  79. #
  80. # This shar contains:
  81. # length  mode       name
  82. # ------ ---------- ------------------------------------------
  83. #    988 -rw-r--r-- ad2c.sed
  84. #  36231 -rw-r--r-- write.hc
  85. #  15159 -rw-r--r-- xgrabsc.man
  86. #   3103 -rw-r--r-- Bugs
  87. #   5078 -rw-r--r-- README
  88. #   3026 -rw-r--r-- README.2_1
  89. #    552 -rw-r--r-- VMSMAKE.COM
  90. #   3313 -rw-r--r-- XWDFile.h
  91. #   4635 -rw-r--r-- Xmd.h
  92. #   2917 -rw-r--r-- cmdopts.h
  93. #   3177 -rw-r--r-- config.h
  94. #   7414 -rw-r--r-- get.hc
  95. #   7579 -rw-r--r-- process.hc
  96. #   5078 -rw-r--r-- ps_color.h
  97. #   4071 -rw-r--r-- xgrab.man
  98. #   1104 -rw-r--r-- Acks
  99. #    976 -rw-r--r-- Imakefile
  100. #    960 -rw-r--r-- checkvm.h
  101. #   1443 -rw-r--r-- cpyright.h
  102. #   1651 -rw-r--r-- mem.hc
  103. #    856 -rw-r--r-- patchlevel.h
  104. #   1493 -rw-r--r-- showvm.ps
  105. #   2375 -rw-r--r-- virtual.h
  106. #   8449 -rw-r--r-- XGrab.ad
  107. #   9241 -rw-r--r-- convert.hc
  108. #   1725 -rw-r--r-- simple.mak
  109. #  12758 -rw-r--r-- xgrab.c
  110. #  18405 -rw-r--r-- xgrabsc.c
  111. #  10735 -rw-r--r-- Makefile
  112. #   8142 -rw-r--r-- xgrab_ad.h
  113. #
  114. if test -r _shar_seq_.tmp; then
  115.     echo 'Must unpack archives in sequence!'
  116.     echo Please unpack part `cat _shar_seq_.tmp` next
  117.     exit 1
  118. fi
  119. # ============= ad2c.sed ==============
  120. if test -f 'ad2c.sed' -a X"$1" != X"-c"; then
  121.     echo 'x - skipping ad2c.sed (File already exists)'
  122.     rm -f _shar_wnt_.tmp
  123. else
  124. > _shar_wnt_.tmp
  125. echo 'x - extracting ad2c.sed (Text)'
  126. sed 's/^X//' << 'SHAR_EOF' > 'ad2c.sed' &&
  127. #========================================================================
  128. #
  129. # Name - ad2c.sed
  130. #
  131. # Version:    1.2
  132. #
  133. # ccsid:    @(#)ad2c.sed    1.2 - 7/9/92 12:48:17
  134. # from:     ccs/s.ad2c.sed
  135. # date:     7/9/92 13:35:26
  136. #
  137. #  Name - ad2c.sed, part of the ad2c package by George Ferguson
  138. #
  139. #  Description:
  140. #
  141. #    Convert app-defaults file to C strings decls.
  142. #
  143. #    Invoke by: sed -n -f ad2c.sed
  144. #
  145. #
  146. #  This is part of an older version of the ad2c package.
  147. #  If you need to create fallback resources from .ad files, get the full
  148. #  package.
  149. #
  150. # ========================================================================
  151. X
  152. : read
  153. # remove comments
  154. /^!/d
  155. /^#/d
  156. # remove blanks
  157. /^$/d
  158. # escape quotes
  159. s/"/\\"/g
  160. # escape backslash
  161. s/\\/\\\\/g
  162. # except the line continuation ones
  163. s/\\$//g
  164. # add leading quote
  165. s/^/"/
  166. #
  167. : test
  168. /\\$/b slash
  169. s/$/",/
  170. p
  171. n
  172. b read
  173. #
  174. : slash
  175. p
  176. n
  177. # just like "read" only doesn't add leading quote
  178. /^!/d
  179. /^$/d
  180. s/"/\\"/g
  181. s/\\\\/\\/g
  182. s/\\n/\\\\n/g
  183. s/\\t/\\\\t/g
  184. s/\\f/\\\\f/g
  185. s/\\b/\\\\b/g
  186. b test
  187. SHAR_EOF
  188. chmod 0644 ad2c.sed ||
  189. echo 'restore of ad2c.sed failed'
  190. Wc_c="`wc -c < 'ad2c.sed'`"
  191. test 988 -eq "$Wc_c" ||
  192.     echo 'ad2c.sed: original size 988, current size' "$Wc_c"
  193. rm -f _shar_wnt_.tmp
  194. fi
  195. # ============= write.hc ==============
  196. if test -f 'write.hc' -a X"$1" != X"-c"; then
  197.     echo 'x - skipping write.hc (File already exists)'
  198.     rm -f _shar_wnt_.tmp
  199. else
  200. > _shar_wnt_.tmp
  201. echo 'x - extracting write.hc (Text)'
  202. sed 's/^X//' << 'SHAR_EOF' > 'write.hc' &&
  203. /*========================================================================
  204. X *
  205. X * Name - write.hc
  206. X *
  207. X * ccs version:    1.3
  208. X *
  209. X * ccsid:    @(#)write.hc    1.3 - 7/9/92 12:49:14
  210. X * from:     ccs/s.write.hc
  211. X * date:     7/9/92 13:35:29
  212. X *
  213. X * Description:  output conversions for xgrabsc
  214. X *
  215. X *               see cpyright.h for copyright information
  216. X *
  217. X *
  218. X *========================================================================
  219. X */
  220. X
  221. X
  222. /* swap the bits in a byte */
  223. swapbits(b)
  224. X  byte b;
  225. {
  226. X  byte b2;
  227. X
  228. X  b2 = 0;
  229. X  b2 |= (b & 0x01) << 7;
  230. X  b2 |= (b & 0x02) << 5;
  231. X  b2 |= (b & 0x04) << 3;
  232. X  b2 |= (b & 0x08) << 1;
  233. X  b2 |= (b & 0x10) >> 1;
  234. X  b2 |= (b & 0x20) >> 3;
  235. X  b2 |= (b & 0x40) >> 5;
  236. X  b2 |= (b & 0x80) >> 7;
  237. X  return b2;
  238. }
  239. X
  240. X
  241. X
  242. X
  243. /* swap the bytes in a long int */
  244. swapbytes(pDblw)
  245. X  dw *pDblw;
  246. X  {
  247. X  union {
  248. X    dw  dbl;
  249. X    byte bytes[4];
  250. X    } cnv;
  251. X  byte aByte;
  252. X
  253. X  cnv.dbl = *pDblw;
  254. X  aByte = cnv.bytes[0];
  255. X  cnv.bytes[0] = cnv.bytes[3];
  256. X  cnv.bytes[3] = aByte;
  257. X  aByte = cnv.bytes[1];
  258. X  cnv.bytes[1] = cnv.bytes[2];
  259. X  cnv.bytes[2] = aByte;
  260. X  *pDblw = cnv.dbl;
  261. X  }
  262. X
  263. X
  264. X
  265. /* swap some long ints.  (n is number of BYTES, not number of longs) */
  266. swapdws (bp, n)
  267. X  register char *bp;
  268. X  register unsigned n;
  269. {
  270. X  register char c;
  271. X  register char *ep = bp + n;
  272. X  register char *sp;
  273. X
  274. X  while (bp < ep) {
  275. X    sp = bp + 3;
  276. X    c = *sp;
  277. X    *sp = *bp;
  278. X    *bp++ = c;
  279. X    sp = bp + 1;
  280. X    c = *sp;
  281. X    *sp = *bp;
  282. X    *bp++ = c;
  283. X    bp += 2;
  284. X  }
  285. }
  286. X
  287. X
  288. X
  289. /* swap some short ints */
  290. swapwords (bp, n)
  291. X  register char *bp;
  292. X  register unsigned n;
  293. {
  294. X  register char c;
  295. X  register char *ep = bp + n;
  296. X
  297. X  while (bp < ep) {
  298. X    c = *bp;
  299. X    *bp = *(bp + 1);
  300. X    bp++;
  301. X    *bp++ = c;
  302. X  }
  303. }
  304. X
  305. X
  306. X
  307. X
  308. X
  309. writeSimple(image, outfile)
  310. X  imageInfo *image;
  311. X  FILE *outfile;
  312. {
  313. X  dw width, height, hasColormap, colormapSize;
  314. X  dw swaptest = 1;
  315. X  int i, w, h;
  316. X
  317. X  if (verbose)
  318. X    fprintf("%s: writing in simple output format\n", programName);
  319. X  if (image->ximage->depth != 8) {
  320. X    fprintf("%s: can't write simple image format if depth is not 8\n",
  321. X            programName);
  322. X    return;
  323. X  }
  324. X  width        = image->ximage->width;
  325. X  height       = image->ximage->height;
  326. X  hasColormap  = 1;
  327. X  colormapSize = image->numcells;
  328. X  if (*(char *)&swaptest==0) {
  329. X    swapdws(&width,        1);
  330. X    swapdws(&height,       1);
  331. X    swapdws(&hasColormap,  1);
  332. X    swapdws(&colormapSize, 1);
  333. X  }
  334. X  fwrite(&width, 4, 1, outfile);
  335. X  fwrite(&height, 4, 1, outfile);
  336. X  fwrite(&hasColormap, 4, 1, outfile);
  337. X  fwrite(&colormapSize, 4, 1, outfile);
  338. X  for (i=0; i<image->numcells; i++)
  339. X    fputc((byte)(image->red[i]>>8), outfile);
  340. X  for (i=0; i<image->numcells; i++)
  341. X    fputc((byte)(image->green[i]>>8), outfile);
  342. X  for (i=0; i<image->numcells; i++)
  343. X    fputc((byte)(image->blue[i]>>8), outfile);
  344. X  for (i=0; i<image->numcells; i++)
  345. X    fputc((byte)(image->used[i]), outfile);
  346. X  for (h=0; h<image->ximage->height; h++)
  347. X    for (w=0; w<image->ximage->width; w++)
  348. X      fputc(XGetPixel(image->ximage, w, h), outfile);
  349. }
  350. X
  351. X
  352. X
  353. X
  354. X
  355. X
  356. X
  357. /*
  358. X * makePSImage returns an XImage structure that contains the samples
  359. X * to be written.  If the input image is monochrome, its XImage structure
  360. X * will be returned.  Otherwise a new structure is allocated and returned.
  361. X */
  362. X
  363. XXImage* makePSImage(image, desiredDepth, depth, bpl, spb)
  364. X    imageInfo* image;
  365. X    int desiredDepth;  /* 0 = don't care */
  366. X    int* depth;
  367. X    int* bpl;
  368. X    int* spb;
  369. {
  370. X    register byte* ptr;
  371. X    int lshift, lmask;
  372. X    long p;
  373. X    int x, y, i;
  374. X    XImage* ximage = image->ximage;
  375. X    XImage* psimage;
  376. X
  377. X  /* use depth as the number of bits in output samples */
  378. X  *depth = ximage->depth;
  379. X  /* postscript only supports 1, 2, 4, or 8 */
  380. X  if (*depth > 8) *depth = 8;     /* max postscript bits/sample */
  381. X  if (*depth < 8 && *depth > 4) *depth = 8;
  382. X  if (*depth == 3) *depth = 4;
  383. X    
  384. X    if (desiredDepth == 0) {
  385. X    desiredDepth = *depth;
  386. X    }
  387. X
  388. X
  389. X  *bpl = ((ximage->width * desiredDepth) + 7) / 8;
  390. X
  391. X  if (*depth == 1)
  392. X    /* Same image */
  393. X    psimage = ximage;
  394. X  else {
  395. X    /* colors have to be changed to luminescence */
  396. X    ptr = (byte *)malloc(ximage->height * *bpl);
  397. X    psimage = XCreateImage(hDisplay, DefaultVisual(hDisplay, hScreen),
  398. X                  desiredDepth, ZPixmap,
  399. X                  0, ptr,
  400. X                  ximage->width, ximage->height,
  401. X                  8, *bpl);
  402. X    if (!psimage) {
  403. X      fprintf(stderr, "%s: could not create image for Postscript conversion\n",
  404. X        programName);
  405. X      exit(3);
  406. X    }
  407. X    /* force the bits_per_pixel to be what is needed */
  408. X    psimage->bits_per_pixel = desiredDepth;
  409. X  }
  410. X
  411. X  *spb = 8 / psimage->bits_per_pixel;    /* samples per byte */
  412. X
  413. X  if (*depth > 1) {
  414. X    /* translate colors into grays */
  415. X    lshift = 16 - psimage->bits_per_pixel;
  416. X    lmask  = (1 << psimage->bits_per_pixel) - 1;
  417. X    for (y = 0; y < ximage->height; y++) {
  418. X      for (x = 0; x < ximage->width; x++) {
  419. X        p = XGetPixel(ximage, x, y);
  420. X        i = (0.30*(double)image->red[p]) +
  421. X            (0.59*(double)image->green[p])+
  422. X            (0.11*(double)image->blue[p]);
  423. X        i = (i >> lshift) & lmask;
  424. X        XPutPixel(psimage, x, y, i);
  425. X      }
  426. X    }
  427. X  }
  428. X  *depth = desiredDepth;  /* The final resolution */
  429. X  return psimage;
  430. }
  431. X
  432. X
  433. X
  434. X
  435. X
  436. X
  437. X
  438. writePreview(image, outfile, defaultImage, ditherKind)
  439. X  imageInfo *image;
  440. X  XImage *defaultImage;
  441. X  FILE *outfile;
  442. X  ditherType ditherKind;
  443. {
  444. X  register byte b, *ptr;
  445. X  int depth, bpl, spb;
  446. X  int reverse, x, y;
  447. X  int widthcount, lines;
  448. X  XImage* ximage;
  449. X  XImage* psimage = (XImage *)NULL;
  450. X    
  451. X  if (image->ximage->depth > 1) {
  452. X    /* required to use black and white for the preview image */
  453. X    if (ditherKind == MAP_BW) {
  454. X      if (verbose) fprintf(stderr, "%s: previewing with a bitmap\n", programName);
  455. X      pixmap2bitmap(image);
  456. X    }
  457. X    else {
  458. X      if (ditherKind == NO_DITHER)
  459. X        ditherKind = FS_DITHER;
  460. X      if (verbose) fprintf(stderr, "%s: previewing with a dither\n", programName);
  461. X      pixmap2halftone(image, ditherKind);
  462. X    }
  463. X    psimage = makePSImage(image, 1, &depth, &bpl, &spb);
  464. X  }
  465. X  else
  466. X    /* the image is already monochrome, so use the psimage that's already
  467. X     * been processed */
  468. X    psimage = defaultImage;
  469. X    
  470. X
  471. X  /* compute the number of lines in the preview output so
  472. X   * apps reading the file can easily skip it */
  473. X  lines = (bpl * psimage->height) / 30;
  474. X  if (lines % 30 > 0) lines++;
  475. X
  476. X  fprintf(outfile, "%%%%BeginPreview: %d %d %d %d\n%%",
  477. X        psimage->width, psimage->height, psimage->depth, lines);
  478. X
  479. X    
  480. X  /* if the bits haven't been swizzled yet, we have to check for color
  481. X   * reversal */
  482. X  if (psimage == image->ximage)
  483. X    reverse = BlackPixel(hDisplay,hScreen)==1;
  484. X  else
  485. X    reverse = FALSE;
  486. X
  487. X  widthcount = 0;
  488. X  for (y=0; y<psimage->height; y++) {
  489. X    /* note that depth 1 images are already padded to even byte boundaries
  490. X     * under X, so there is no need to shift bits around to do padding of
  491. X     * the preview image */
  492. X    for (x=0, ptr=(byte *)(psimage->data+(y * psimage->bytes_per_line));
  493. X         x<psimage->width;
  494. X         x+=spb, ptr++) {
  495. X      b = *ptr;
  496. X      if (reverse) b = ~b;
  497. X      if (depth == 1  &&  psimage->bitmap_bit_order == LSBFirst)
  498. X        b = swapbits(b);
  499. X      fprintf(outfile, "%02.2x", b);
  500. X      widthcount += 2;
  501. X      if (widthcount >= 60) {
  502. X    fputs("\n%", outfile);
  503. X        widthcount = 0;
  504. X      }
  505. X    }
  506. X  }
  507. X  fprintf(outfile, "\n%%%%EndPreview\n");
  508. X    
  509. X  if (psimage && psimage != defaultImage) {
  510. X    free(psimage->data);
  511. X    free(psimage);
  512. X  }
  513. }
  514. X
  515. X
  516. X
  517. /*
  518. X * Write an image in Postscript format
  519. X */
  520. writePostscript(image, outfile, encode, encapsulate, preview,
  521. X  previewDither, landscape, binary, checkLimits)
  522. X  imageInfo *image;
  523. X  FILE *outfile;
  524. X  int encode;       /* TRUE if we're to encode the Postscript output */
  525. X  int encapsulate;  /* TRUE if encapsulated Postscript output is wanted */
  526. X  int preview;      /* TRUE if EPSI preview image is to be written with EPS output */
  527. X  ditherType previewDither;  /* type of dither to use for preview image */
  528. X  int landscape;    /* TRUE if landscape format is wanted */
  529. X  int binary;       /* TRUE if binary output is wanted */
  530. X  int checkLimits;  /* TRUE if PS interpreter memory checks should be made */
  531. {
  532. X  register byte b, *ptr;
  533. X  register int x, y;
  534. X  register int i;
  535. X  XImage *ximage = image->ximage;
  536. X  XImage *psimage;
  537. X  double xdpi, ydpi, xscale, yscale, f;
  538. X  int lshift, lmask;
  539. X  int depth, bpl, spb;
  540. X  int reverse;
  541. X  long p;
  542. X  /* rle variables */
  543. X  int rlecount;
  544. X  byte rlesample;
  545. X  dw  rletotal;
  546. X  int widthcount;
  547. X  int firstSample;
  548. X
  549. X  if (verbose)
  550. X    fprintf(stderr, "%s: formatting Postscript output\n", programName);
  551. X
  552. X  if (preview)
  553. X    encapsulate = TRUE;
  554. X
  555. X  if (encapsulate)
  556. X    landscape = FALSE;  /* landscape uses a transformation matrix */
  557. X
  558. X  psimage = makePSImage(image, 0, &depth, &bpl, &spb);
  559. X
  560. #ifndef NO_RLE_CHECKS
  561. X  if (encode) {
  562. X    rletotal = 0;
  563. X    rlecount = 0;
  564. X    firstSample = TRUE;
  565. X    for (y=0; y<psimage->height; y++)
  566. X      for (x=0, ptr=(byte *)(psimage->data + (y * psimage->bytes_per_line));
  567. X           x<psimage->width; x+=spb, ptr++) {
  568. X        b = *ptr;
  569. X    if (firstSample || b != rlesample || rlecount==254) {
  570. X      if (!firstSample)
  571. X        rletotal += 2;
  572. X      else
  573. X        firstSample = FALSE;
  574. X      rlecount = 0;
  575. X      rlesample = b;
  576. X    }
  577. X    else
  578. X      rlecount++;
  579. X      }
  580. X    if (!firstSample)
  581. X      rletotal += 2;
  582. X    f = (float)(rletotal) / (float)(psimage->height*bpl);
  583. X    if (verbose)
  584. X      fprintf(stderr, "%s: encoding would change to %5.1f%% of orig size\n",
  585. X            programName, f * 100.0);
  586. X    encode = f <= 0.95;
  587. X  }
  588. #endif
  589. X
  590. X
  591. X
  592. X  if (verbose)
  593. X    fprintf(stderr, "%s: image will %sbe encoded\n", programName,
  594. X            encode? "" : "not ");
  595. X
  596. X  if (encapsulate) {
  597. X    fprintf(outfile, "%%!PS-Adobe-2.0 EPSF-2.0\n");
  598. X    fprintf(outfile, "%%%%BoundingBox: %d %d %d %d\n",
  599. X                0, 0, psimage->width, psimage->height);
  600. X  }
  601. X  else
  602. X    fprintf(outfile, "%%!\n");
  603. X
  604. X  fprintf(outfile, "%%%%Creator: xgrabsc\n");
  605. X  fprintf(outfile, "%%%%Title: %s\n", imageName);
  606. X  time(&p);
  607. X  fprintf(outfile, "%%%%CreationDate: %s", ctime(&p));
  608. X  fprintf(outfile, "%%%%EndComments\n");
  609. X  fprintf(outfile, "%%\n");
  610. X  fprintf(outfile, "%%\n");
  611. X
  612. X  /* if the user wants a preview image, EPS 2.0 says it must go here */
  613. X  if (preview)
  614. X    writePreview(image, outfile, psimage, previewDither);
  615. X
  616. X
  617. X  if (encapsulate) {
  618. X    fprintf(outfile, "%%%%EndProlog\n");
  619. X    fprintf(outfile, "%%%%Page: 1 1\n");
  620. X  }
  621. X
  622. X  /* standard inch procedure */
  623. X  fputs("/inch {72 mul} def\n", outfile);
  624. X
  625. X
  626. X  /* define a string to hold image bytes */
  627. X  if (encode) {
  628. X    fputs("/rlebuffer 2 string def\n", outfile);
  629. X    fprintf(outfile, "/samples %d string def\n", 256);  /* max bytes per burst */
  630. X  }
  631. X  else
  632. X    fprintf(outfile, "/picstr %d string def\n", bpl);
  633. X
  634. X  if (binary) {
  635. X    fputs("/endstr 1 string def\n", outfile);
  636. X    if (encode) fputs("/ccount 0 def\n", outfile);
  637. X  }
  638. X
  639. X  /* define the image plotting procedure */
  640. X  fputs("/plotimage\n", outfile);
  641. X
  642. X  fprintf(outfile, "{%d %d %d ",
  643. X        psimage->width, psimage->height, psimage->bits_per_pixel);
  644. X
  645. X
  646. X
  647. X  /* transformation matrix */
  648. X  if (landscape)
  649. X    fprintf(outfile, "[0 %d %d 0 0 0]\n", psimage->width, psimage->height);
  650. X  else
  651. X    fprintf(outfile, "[%d 0 0 -%d 0 %d]\n",
  652. X        psimage->width, psimage->height, psimage->height);
  653. X
  654. X  /* line reading function  */
  655. X
  656. X  if (encode) {
  657. X  fputs("% run-length decoding block\n",                                       outfile);
  658. X    if (binary) {
  659. X      fputs("  { currentfile rlebuffer readstring pop pop\n", outfile);
  660. X      fputs("    /ccount ccount 2 add def                 %% count binary chars\n",outfile);
  661. X      fputs("    ccount 60 ge                             %% test for >60 chars\n",outfile);
  662. X      fputs("    { /ccount 0 def                          %% reset character counter\n",outfile);
  663. X      fputs("      currentfile endstr readline pop pop    %% skip newline\n",outfile);
  664. X      fputs("    } if                                     %% skip newlines after 60 chars\n",outfile);
  665. X    }
  666. X    else
  667. X      fputs("  { currentfile rlebuffer readhexstring pop pop\n",                 outfile);
  668. X    fputs("    rlebuffer 0 get 1 add       %% number of copies of the sample\n", outfile);
  669. X    fputs("    /nsamples exch store        %% save it away\n",                   outfile);
  670. X    fputs("    /lum rlebuffer 1 get store  %% the sample itself\n",              outfile);
  671. X    fputs("    0 1 nsamples 1 sub { samples exch lum put } for\n",               outfile);
  672. X    fputs("    samples 0 nsamples getinterval %% leave the pixels on the stack\n",outfile);
  673. X    fputs("  }\n", outfile);
  674. X  }
  675. X  else {
  676. X    if (binary) {
  677. X      /* Do a "readline" after each "readstring" so we can seperate each
  678. X         scanline of binary data with a "newline" */
  679. X      fputs("   {currentfile picstr readstring pop\n", outfile);
  680. X      fputs("    currentfile endstr readline pop pop}\n", outfile);
  681. X    }
  682. X    else
  683. X      fputs("  {currentfile picstr readhexstring pop}\n", outfile);
  684. X  }
  685. X
  686. X  fputs("  image\n} def\n", outfile);
  687. X
  688. X
  689. X  /* emit some code to check for resource availability */
  690. X  if (!encapsulate  &&  checkLimits) {
  691. X    for (x=0; CheckVM[x] != NULL; x++) {
  692. X      fputs(CheckVM[x], outfile);
  693. X      fputc('\n', outfile);
  694. X    }
  695. X    fprintf(outfile, "\n\n");
  696. X    fprintf(outfile, "%d checkvm\n", psimage->height * bpl);
  697. X  }
  698. X
  699. X  /* save context and move to a nice origin */
  700. X  fputs("gsave\n", outfile);
  701. X
  702. X  if (encapsulate) {
  703. X    /* for encapsulated postscript, we need a scale factor that is equal
  704. X     * to the image width/height in samples */
  705. X    fprintf(outfile, "%d %d scale\n", psimage->width, psimage->height);
  706. X  }
  707. X  else {
  708. X    /* For physical output we need a scale factor that will create
  709. X      * the same size image, and we need to center it on the page.
  710. X      *   -Figure out the physical dimensions on the screen
  711. X      *    and make it come out the same on the printer. */
  712. X    xdpi = (((double)DisplayWidth(hDisplay,hScreen)) * 25.4) /
  713. X            ((double)DisplayWidthMM(hDisplay,hScreen));
  714. X    ydpi = (((double)DisplayHeight(hDisplay,hScreen)) * 25.4) /
  715. X            ((double)DisplayHeightMM(hDisplay,hScreen));
  716. X    xscale = ((double)psimage->width) / xdpi;
  717. X    yscale = ((double)psimage->height) / ydpi;
  718. X    if (landscape) {
  719. X      f = xscale; xscale = yscale; yscale = f;
  720. X    }
  721. X    if (xscale > horizInset) {
  722. X      yscale *= horizInset / xscale;
  723. X      xscale = horizInset;
  724. X    }
  725. X    else if (yscale > vertInset) {
  726. X      xscale *= vertInset / yscale;
  727. X      yscale = vertInset;
  728. X    }
  729. X    fprintf(outfile, "%1.2g inch %1.2g inch translate\n",
  730. X                  (pageWidth - xscale) / 2.0, (pageHeight - yscale) / 2.0);
  731. X    if (landscape)
  732. X      fprintf(outfile, "%1.2g inch %1.2g inch scale\n", yscale, xscale);
  733. X    else
  734. X      fprintf(outfile, "%1.2g inch %1.2g inch scale\n", xscale, yscale);
  735. X  }
  736. X
  737. X
  738. X
  739. X  if (binary)
  740. X    fprintf(outfile,"%%%%BeginBinary: %d\n",
  741. X        encode ? rletotal+11+rletotal/60
  742. X        : ximage->height*(ximage->width+1)+10);
  743. X
  744. X  fputs("plotimage\n", outfile);
  745. X
  746. X
  747. X  reverse = depth == 1? BlackPixel(hDisplay,hScreen)==1 : FALSE;
  748. X  if (encode) {
  749. X    rletotal = 0;
  750. X    rlecount = 0;
  751. X    firstSample = TRUE;
  752. X  }
  753. X  widthcount = 0;
  754. X  for (y=0; y<psimage->height; y++) {
  755. X    for (x=0, ptr=(byte *)(psimage->data+(y * psimage->bytes_per_line));
  756. X         x<psimage->width;
  757. X         x+=spb, ptr++) {
  758. X      b = *ptr;
  759. X      if (reverse) b = ~b;
  760. X      if (depth == 1  &&  psimage->bitmap_bit_order == LSBFirst)
  761. X        b = swapbits(b);
  762. X      if (encode) {
  763. X        if (firstSample || b != rlesample || rlecount==254) {
  764. X      if (!firstSample) {
  765. X        if (binary) {
  766. X          putc((byte)rlecount,outfile);
  767. X          putc((byte)rlesample,outfile);
  768. X          widthcount += 2;
  769. X        }
  770. X        else {
  771. X          fprintf(outfile, "%02.2x%02.2x", rlecount, rlesample);
  772. X          widthcount += 4;
  773. X        }
  774. X        rletotal += 2;
  775. X        if (widthcount >= 60) {
  776. X          fputc('\n', outfile);
  777. X          widthcount = 0;
  778. X        }
  779. X      }
  780. X      else
  781. X        firstSample = FALSE;
  782. X      rlecount = 0;
  783. X      rlesample = b;
  784. X    }
  785. X    else
  786. X      rlecount++;
  787. X      }
  788. X      else {
  789. X    if (binary)
  790. X      putc((byte)b,outfile);
  791. X    else {
  792. X          fprintf(outfile, "%02.2x", b);
  793. X      widthcount += 2;
  794. X      if (widthcount >= 60) {
  795. X        fputc('\n', outfile);
  796. X            widthcount = 0;
  797. X          }
  798. X        }
  799. X      }
  800. X    }
  801. X    if (binary && !encode) putc('\n',outfile);
  802. X  }
  803. X
  804. X  if (encode) {
  805. X    if (!firstSample) {
  806. X      if (binary) {
  807. X    putc((byte)rlecount,outfile);
  808. X    putc((byte)rlesample,outfile);
  809. X      }
  810. X      else
  811. X        fprintf(outfile, "%02.2x%02.2x\n", rlecount, rlesample);
  812. X      rletotal += 2;
  813. X    }
  814. X    putc('\n',outfile);
  815. X    if (binary) fputs("%%EndBinary\n",outfile);
  816. X    fputs("%\n", outfile);
  817. X    fprintf(outfile, "%% Run-length encoding savings = %5.1f%%\n",
  818. X          100.0 - ((float)(rletotal) * 100.0 / (float)(psimage->height * bpl)));
  819. X    fputs("%\n", outfile);
  820. X  }
  821. X  else if (binary) fputs("%%EndBinary\n",outfile);
  822. X
  823. X  fputs("\n\n\ngrestore\nshowpage\n", outfile);
  824. X
  825. X
  826. X  if (psimage != ximage) {
  827. X    free(psimage->data);
  828. X    free(psimage);
  829. X  }
  830. }
  831. X
  832. X
  833. X
  834. X
  835. X
  836. /*
  837. X * Write an image in Color Postscript format
  838. X */
  839. writeColorPS(image, outfile, encode, encapsulate, preview,
  840. X  previewDither, landscape, binary, checkLimits)
  841. X  imageInfo *image;
  842. X  FILE *outfile;
  843. X  int encode;       /* TRUE if we're to encode the Postscript output    */
  844. X  int encapsulate;  /* TRUE if encapsulated Postscript output is wanted */
  845. X  int preview;      /* TRUE if EPSI preview image is to be written with EPS output */
  846. X  ditherType previewDither; /* type of dither to use for preview image */
  847. X  int landscape;    /* TRUE if landscape output is wanted               */
  848. X  int binary;       /* TRUE if binary Postscript output is wanted */
  849. X  int checkLimits;  /* TRUE if PS interpreter memory checks should be made */
  850. {
  851. X  register byte *ptr, b;
  852. X  register int x, y;
  853. X  XImage *ximage = image->ximage;
  854. X  double xdpi, ydpi, xscale, yscale, f;
  855. X  double left, top;
  856. X  int depth, bpl, spb;
  857. X  long p;
  858. X  /* rle variables */
  859. X  int rlecount;
  860. X  dw  rletotal;
  861. X  byte rlesample;
  862. X  int firstSample;
  863. X  int widthcount;
  864. X
  865. X
  866. X  if (verbose)
  867. X    fprintf(stderr, "%s: formatting Color Postscript output\n", programName);
  868. X
  869. X  if (encapsulate)
  870. X    landscape = FALSE;  /* landscape uses a transformation matrix */
  871. X
  872. X  depth = 8;                                  /* bits per sample  */
  873. X  spb   = 1;                                  /* samples per byte */
  874. X  bpl = ((ximage->width * depth) + 7) / 8;    /* bytes per line   */
  875. X
  876. X
  877. #ifndef NO_RLE_CHECKS
  878. X  if (encode) {
  879. X    rletotal = 0;
  880. X    rlecount = 0;
  881. X    firstSample = TRUE;
  882. X    for (y=0; y<ximage->height; y++)
  883. X      for (x=0, ptr=(byte *)(ximage->data + (y * ximage->bytes_per_line));
  884. X           x<ximage->width; x+=spb, ptr++) {
  885. X        b = *ptr;
  886. X    if (firstSample || b != rlesample || rlecount==254) {
  887. X      if (!firstSample)
  888. X        rletotal += 2;
  889. X      else
  890. X        firstSample = FALSE;
  891. X      rlecount = 0;
  892. X      rlesample = b;
  893. X    }
  894. X    else
  895. X      rlecount++;
  896. X      }
  897. X    rletotal += 2;
  898. X    f = (float)(rletotal) / (float)(ximage->height*bpl);
  899. X    if (verbose)
  900. X      fprintf(stderr, "%s: encoding would change to %5.1f%% of orig size\n",
  901. X            programName, f * 100.0);
  902. X    encode = f <= 0.95;
  903. X  }
  904. #endif
  905. X
  906. X  if (encapsulate) {
  907. X    fprintf(outfile, "%%!PS-Adobe-2.0 EPSF-2.0\n");
  908. X  }
  909. X  else
  910. X    fprintf(outfile, "%%!\n");
  911. X
  912. X  fprintf(outfile, "%%%%Creator: xgrabsc\n");
  913. X  fprintf(outfile, "%%%%Title: %s\n", imageName);
  914. X  if (encapsulate) {
  915. X    fprintf(outfile, "%%%%Pages: 1\n");
  916. X    fprintf(outfile, "%%%%BoundingBox: %d %d %d %d\n",
  917. X                0, 0, ximage->width, ximage->height);
  918. X  }
  919. X  time(&p);
  920. X  fprintf(outfile, "%%%%CreationDate: %s", ctime(&p));
  921. X  fprintf(outfile, "%%%%EndComments\n");
  922. X
  923. X  /* if the user wants a preview image, EPS 2.0 says it must go here */
  924. X  if (preview)
  925. X    writePreview(image, outfile, image->ximage, previewDither);
  926. X
  927. X  if (encapsulate) {
  928. X    fprintf(outfile, "%%%%EndProlog\n");
  929. X    fprintf(outfile, "%%%%Page: 1 1\n");
  930. X  }
  931. X  fprintf(outfile, "\n\ngsave\n\n");
  932. X
  933. X
  934. X  if (needColorImageProc) {
  935. X    /* put a colorImage procedure into the output file so a monochrome
  936. X    * printer can handle the file as well
  937. X    */
  938. X    for (x=0; ColorImage[x] != NULL; x++) {
  939. X      fputs(ColorImage[x], outfile);
  940. X      fputc('\n', outfile);
  941. X    }
  942. X    fprintf(outfile, "\n\n\n");
  943. X  }
  944. X
  945. X  fputs("/inch {72 mul} def\n", outfile);
  946. X
  947. X  /* emit some code to check for resource availability */
  948. X  if (!encapsulate  &&  checkLimits) {
  949. X    for (x=0; CheckVM[x] != NULL; x++) {
  950. X      fputs(CheckVM[x], outfile);
  951. X      fputc('\n', outfile);
  952. X    }
  953. X    fprintf(outfile, "\n\n");
  954. X    fprintf(outfile, "%d checkvm\n\n", ximage->height * bpl);
  955. X  }
  956. X
  957. X  if (encapsulate) {
  958. X    /* don't translate the image for encapsulated postscript.  The
  959. X     * scale should match the data dimensions of the image in samples.  */
  960. X    fprintf(outfile, "%d %d scale\n", ximage->width, ximage->height);
  961. X  }
  962. X  else {
  963. X    /* For physical output we need a scale factor that will create
  964. X     * the same size image, and we need to center it on the page.
  965. X     *   -Figure out the physical dimensions on the screen
  966. X     *    and make it come out the same on the printer.
  967. X     */
  968. X    xdpi = (((double)DisplayWidth(hDisplay,hScreen)) * 25.4) /
  969. X            ((double)DisplayWidthMM(hDisplay,hScreen));
  970. X    ydpi = (((double)DisplayHeight(hDisplay,hScreen)) * 25.4) /
  971. X            ((double)DisplayHeightMM(hDisplay,hScreen));
  972. X    xscale = ((double)ximage->width) / xdpi;
  973. X    yscale = ((double)ximage->height) / ydpi;
  974. X    if (landscape) {
  975. X      f = xscale; xscale = yscale; yscale = f;
  976. X    }
  977. X    if (xscale > horizInset) {
  978. X      yscale *= horizInset / xscale;
  979. X      xscale = horizInset;
  980. X    }
  981. X    else if (yscale > vertInset) {
  982. X      xscale *= vertInset / yscale;
  983. X      yscale = vertInset;
  984. X    }
  985. X     
  986. X
  987. X    left = ((pageWidth - xscale) / 2.0);
  988. X    top  = ((pageHeight - yscale) / 2.0);
  989. X    fprintf(outfile, "%1.2g inch %1.2g inch translate\n", left, top);
  990. X    if (landscape)
  991. X      fprintf(outfile, "%1.2g inch %1.2g inch scale\n", yscale, xscale);
  992. X    else
  993. X      fprintf(outfile, "%1.2g inch %1.2g inch scale\n", xscale, yscale);
  994. X    fprintf(outfile, "\n\n\n");
  995. X  }
  996. X
  997. X  if (binary) {
  998. X    fputs("/endstr 1 string def\n", outfile);
  999. X    fputs("/ccount 0 def\n", outfile);
  1000. X  }
  1001. X
  1002. X  if (encode) {
  1003. X    /* define a drawcolormappedimage procedure geared to this image
  1004. X    */
  1005. X    fprintf(outfile, "/rgbstr %d string def\n", 256 * 3); /* max pixels per burst */
  1006. X    fprintf(outfile, "/buffer %d string def\n", 2);
  1007. X    fputs("/rgb (000) def\n", outfile);
  1008. X    fprintf(outfile, "/rgbmap %d string def\n", image->numcells * 3);
  1009. X    fputs("\n\n", outfile);
  1010. X
  1011. X    fputs("/drawcolormappedimage {\n", outfile);
  1012. X    fprintf(outfile, "  %d %d %d\n", ximage->width, ximage->height,depth);
  1013. X    if (landscape)
  1014. X      fprintf(outfile, "  [0 %d %d 0 0 0]\n", ximage->width, ximage->height);
  1015. X    else
  1016. X      fprintf(outfile, "  [%d 0 0 -%d 0 %d]\n", ximage->width, ximage->height,
  1017. X                                                ximage->height);
  1018. X    fputs("  %% define a block of code to read and decode the rle input stream\n", outfile);
  1019. X
  1020. X    if (binary) {
  1021. X      fputs("  { currentfile buffer readstring pop pop    %% run length and index\n", outfile);
  1022. X      fputs("    /ccount ccount 2 add def                 %% count binary chars\n",outfile);
  1023. X      fputs("    ccount 60 ge                             %% test for >60 chars\n",outfile);
  1024. X      fputs("    { /ccount 0 def                          %% reset character counter\n",outfile);
  1025. X      fputs("      currentfile endstr readline pop pop    %% skip newline\n",outfile);
  1026. X      fputs("    } if                                     %% skip newlines after 60 chars\n",outfile);
  1027. X    }
  1028. X    else
  1029. X      fputs("  { currentfile buffer readhexstring pop pop %% run length and index\n", outfile);
  1030. X
  1031. X    fputs("    /npixels buffer 0 get 1 add 3 mul store  %% number of bytes\n", outfile);
  1032. X    fputs("    /color buffer 1 get 3 mul store          %% fix index into rgb map\n", outfile);
  1033. X    fputs("    /rgb rgbmap color 3 getinterval store    %% and get the colors\n", outfile);
  1034. X    fputs("    0 3 npixels 1 sub {                      %% loop to store the rgb bytes\n", outfile);
  1035. X    fputs("      rgbstr exch rgb putinterval\n", outfile);
  1036. X    fputs("    } for\n", outfile);
  1037. X    fputs("    rgbstr 0 npixels getinterval\n", outfile);
  1038. X    fputs("  }\n", outfile);
  1039. X    fputs("  false 3 colorimage\n", outfile);
  1040. X    fputs("} bind def\n", outfile);
  1041. X    fprintf(outfile, "\n\n\n");
  1042. X
  1043. X
  1044. X  }
  1045. X
  1046. X
  1047. X  else {
  1048. X    /* define a drawcolorimage procedure geared to this image
  1049. X    */
  1050. X    fprintf(outfile, "/buffer %d string def\n", 1);
  1051. X    fprintf(outfile, "/rgbmap %d string def\n", image->numcells * 3);
  1052. X    fputs("\n\n", outfile);
  1053. X
  1054. X    fputs("/onepixel 3 string store\n", outfile);
  1055. X    fputs("/drawcolormappedimage {\n", outfile);
  1056. X    fprintf(outfile, "  %d %d %d\n", ximage->width, ximage->height,depth);
  1057. X    if (landscape)
  1058. X      fprintf(outfile, "  [0 %d %d 0 0 0]\n", ximage->width, ximage->height);
  1059. X    else
  1060. X      fprintf(outfile, "  [%d 0 0 -%d 0 %d]\n", ximage->width, ximage->height,
  1061. X                                                ximage->height);
  1062. X    fputs("  %% define a block of code to read and decode the rle input stream\n", outfile);
  1063. X    if (binary) {
  1064. X      fputs("  { currentfile buffer readstring pop pop    %% run length and index\n", outfile);
  1065. X      fprintf(outfile,"    /ccount ccount %d add def                 %% count binary chars\n",encode ? 2 : 1);
  1066. X      fputs("    ccount 60 ge                             %% test for >60 chars\n",outfile);
  1067. X      fputs("    { /ccount 0 def                          %% reset character counter\n",outfile);
  1068. X      fputs("      currentfile endstr readline pop pop    %% skip newline\n",outfile);
  1069. X      fputs("    } if                                     %% skip newlines after 60 chars\n",outfile);
  1070. X    }
  1071. X    else
  1072. X      fputs("  { currentfile buffer readhexstring pop pop  %% index\n", outfile);
  1073. X    fputs("    rgbmap buffer 0 get 3 mul 3 getinterval   %% color bytes\n", outfile);
  1074. X    fputs("  }\n", outfile);
  1075. X    fputs("  false 3 colorimage\n", outfile);
  1076. X    fputs("} bind def\n", outfile);
  1077. X    fprintf(outfile, "\n\n\n");
  1078. X
  1079. X  }
  1080. X
  1081. X
  1082. X  /* write the rgb map */
  1083. X  fputs("%% get the rgb map\n", outfile);
  1084. X  fputs("currentfile rgbmap readhexstring pop pop\n", outfile);
  1085. X  for (x=0; x<image->numcells; x++)
  1086. X    fprintf(outfile, "%02.2x%02.2x%02.2x\n",
  1087. X                      (byte)((image->red[x]   >> 8) & 0xff),
  1088. X              (byte)((image->green[x] >> 8) & 0xff),
  1089. X              (byte)((image->blue[x]  >> 8) & 0xff) );
  1090. X  fputs("\n\n", outfile);
  1091. X
  1092. X
  1093. X  if (binary)
  1094. X    fprintf(outfile,"%%%%BeginBinary: %d\n",
  1095. X        encode ? rletotal+22+rletotal/60
  1096. X        : ximage->height*ximage->width+22+
  1097. X          (ximage->height*ximage->width)/60);
  1098. X
  1099. X  fputs("drawcolormappedimage\n", outfile);
  1100. X
  1101. X  /* write the map indexes */
  1102. X  rletotal = 0;
  1103. X  rlecount = 0;
  1104. X  firstSample = TRUE;
  1105. X  widthcount = 0;
  1106. X  for (y=0; y<ximage->height; y++) {
  1107. X    for (x=0, ptr=(byte *)(ximage->data+(y * ximage->bytes_per_line));
  1108. X        x<ximage->width;
  1109. X        x+=spb, ptr++) {
  1110. X      b = *ptr;
  1111. X      if (encode) {
  1112. X        if (firstSample || b != rlesample || rlecount==254) {
  1113. X      if (!firstSample) {
  1114. X        if (binary) {
  1115. X          putc((byte)rlecount,outfile);
  1116. X          putc((byte)rlesample,outfile);
  1117. X          widthcount += 2;
  1118. X        }
  1119. X        else {
  1120. X          fprintf(outfile, "%02.2x%02.2x", rlecount, rlesample);
  1121. X          widthcount += 4;
  1122. X        }
  1123. X        rletotal += 2;
  1124. X        if (widthcount >= 60) {
  1125. X          fputc('\n', outfile);
  1126. X          widthcount = 0;
  1127. X        }
  1128. X      }
  1129. X      else
  1130. X        firstSample = FALSE;
  1131. X      rlecount = 0;
  1132. X      rlesample = b;
  1133. X        }
  1134. X        else
  1135. X      rlecount++;
  1136. X      }
  1137. X      else {
  1138. X    if (binary) {
  1139. X      putc((byte)b,outfile);
  1140. X      ++widthcount;
  1141. X    }
  1142. X    else {
  1143. X      fprintf(outfile, "%02.2x", b & 0xFF);
  1144. X      widthcount += 2;
  1145. X    }
  1146. X    if (widthcount >= 60) {
  1147. X      fputc('\n', outfile);
  1148. X      widthcount = 0;
  1149. X    }
  1150. X      }
  1151. X    }
  1152. X  }
  1153. X
  1154. X  if (encode) {
  1155. X    if (!firstSample) {
  1156. X      if (binary) {
  1157. X    putc((byte)rlecount,outfile);
  1158. X    putc((byte)rlesample,outfile);
  1159. X      }
  1160. X      else
  1161. X        fprintf(outfile, "%02.2x%02.2x\n", rlecount, rlesample);
  1162. X      rletotal += 2;
  1163. X    }
  1164. X  }
  1165. X  if (binary)
  1166. X    fprintf(outfile,"\n%%%%EndBinary\n");
  1167. X
  1168. X  /* print some statistics */
  1169. X  if (encode) {
  1170. X    fputs("%\n", outfile);
  1171. X    fprintf(outfile, "%% Run-length encoding savings = %5.1f%%\n",
  1172. X          100.0 - ((float)(rletotal) * 100.0 / (float)(ximage->height * bpl)));
  1173. X  }
  1174. X
  1175. X  fputs("%\n", outfile);
  1176. X  fputs("\ngrestore\nshowpage\n%%Trailer\n", outfile);
  1177. }
  1178. X
  1179. X
  1180. X
  1181. X
  1182. X
  1183. X
  1184. X
  1185. X
  1186. X
  1187. X
  1188. X
  1189. /*
  1190. X * Write an image in 'puzzle' format, suitable for loading with
  1191. X * "puzzle -picture".
  1192. X */
  1193. writePuzzle(image, outfile)
  1194. X  imageInfo *image;
  1195. X  FILE *outfile;
  1196. {
  1197. X  XImage *ximage = image->ximage;
  1198. X  int nc, width, height, w, h, cidx;
  1199. X  dw swaptest = 1;
  1200. X
  1201. X  if (verbose)
  1202. X    fprintf(stderr, "%s: formatting Puzzle output\n", programName);
  1203. X
  1204. X  if (ximage->depth > 8) {
  1205. X    fprintf(stderr, "%s: Puzzle converter can't handle depth > 8 yet\n",
  1206. X            programName);
  1207. X    return;
  1208. X  }
  1209. X
  1210. X  nc     = image->numcells;
  1211. X  width  = ximage->width;
  1212. X  height = ximage->height;
  1213. X  if (*(char *)&swaptest) {
  1214. X    swapbytes(&width);
  1215. X    swapbytes(&height);
  1216. X  }
  1217. X  fwrite(&width, 4, 1, outfile);
  1218. X  fwrite(&height, 4, 1, outfile);
  1219. X  fputc(nc, outfile);
  1220. X  for (cidx=0; cidx<nc; cidx++) {
  1221. X    fputc(image->red[cidx]>>8,   outfile);
  1222. X    fputc(image->green[cidx]>>8, outfile);
  1223. X    fputc(image->blue[cidx]>>8,  outfile);
  1224. X  }
  1225. X  for (h=0; h<ximage->height; h++)
  1226. X    if (ximage->bits_per_pixel == 8)
  1227. X      fwrite(ximage->data+(h*ximage->bytes_per_line),ximage->width,1,outfile);
  1228. X    else
  1229. X      /* this won't work if depth > 8 */
  1230. X      for (w=0; w<ximage->width; w++)
  1231. X        fputc(XGetPixel(ximage, w, h), outfile);
  1232. }
  1233. X
  1234. X
  1235. X
  1236. X
  1237. X
  1238. X
  1239. X
  1240. writeXWD(image, outfile)
  1241. X  imageInfo *image;
  1242. X  FILE *outfile;
  1243. {
  1244. X  XImage   *ximage = image->ximage;
  1245. X  XWDFileHeader header;
  1246. X  Visual   *visual = DefaultVisual(hDisplay, hScreen);
  1247. X  XColor    color;
  1248. X  dw        visMask = (visual->red_mask
  1249. X                      | visual->green_mask
  1250. X                      | visual->blue_mask);
  1251. X  dw        swaptest = 1;
  1252. X  int       i;
  1253. X
  1254. X  if (verbose)
  1255. X    fprintf(stderr, "%s: formatting xwd output\n", programName);
  1256. X
  1257. X  header.header_size    = (CARD32)(sizeof(header)+strlen(imageName)+1);
  1258. X  header.file_version   = (CARD32) XWD_FILE_VERSION;
  1259. X  header.pixmap_format  = (CARD32)(ximage->depth>1? ZPixmap : XYPixmap);
  1260. X  header.pixmap_depth   = (CARD32) ximage->depth;
  1261. X  header.pixmap_width   = (CARD32) ximage->width;
  1262. X  header.pixmap_height  = (CARD32) ximage->height;
  1263. X  header.xoffset        = (CARD32) ximage->xoffset;
  1264. X  header.byte_order     = (CARD32) ximage->byte_order;
  1265. X  header.bitmap_unit    = (CARD32) ximage->bitmap_unit;
  1266. X  header.bitmap_bit_order = (CARD32) ximage->bitmap_bit_order;
  1267. X  header.bitmap_pad     = (CARD32) ximage->bitmap_pad;
  1268. X  header.bits_per_pixel = (CARD32) ximage->bits_per_pixel;
  1269. X  header.bytes_per_line = (CARD32) ximage->bytes_per_line;
  1270. X  header.visual_class   = (CARD32)visual->class;
  1271. X  header.red_mask       = (CARD32)visual->red_mask;
  1272. X  header.green_mask     = (CARD32)visual->green_mask;
  1273. X  header.blue_mask      = (CARD32)visual->blue_mask;
  1274. X  header.bits_per_rgb   = (CARD32)visual->bits_per_rgb;
  1275. X  header.colormap_entries = (CARD32)visual->map_entries;
  1276. X  header.ncolors        = image->numcells;
  1277. X  header.window_width   = (CARD32)ximage->width;
  1278. X  header.window_height  = (CARD32)ximage->height;
  1279. X  header.window_x       = 0;
  1280. X  header.window_y       = 0;
  1281. X  header.window_bdrwidth = 0;
  1282. X
  1283. X  if (*(char *) &swaptest)
  1284. X    swapdws(&header, sizeof(header));
  1285. X
  1286. X  fwrite(&header, sizeof(header), 1, outfile);
  1287. X  fwrite(imageName, 1, strlen(imageName)+1, outfile);
  1288. X
  1289. X  for (i=0; i<image->numcells; i++) {
  1290. X    color.pixel = i;
  1291. X    color.red   = image->red[i];
  1292. X    color.green = image->green[i];
  1293. X    color.blue  = image->blue[i];
  1294. X    color.flags = visMask;
  1295. X    color.pad   = 0;
  1296. X    if (*(char *) &swaptest) {
  1297. X      swapdws(&color.pixel, sizeof(color.pixel));
  1298. X      swapwords(&color.red, 3 * sizeof(color.red)); /* assume g and b follow r */
  1299. X    }
  1300. X    fwrite(&color, sizeof(XColor), 1, outfile);
  1301. X  }
  1302. X
  1303. X  fwrite(ximage->data, ximage->height * ximage->bytes_per_line, 1, outfile);
  1304. }
  1305. X
  1306. X
  1307. X
  1308. X
  1309. X
  1310. /*
  1311. X * Write a monochrome image out in Bitmap format.  XWriteBitmapToFile
  1312. X * requires a Pixmap as input & we'd have to invent one before we could
  1313. X * use it.
  1314. X */
  1315. X
  1316. writeXYPixmap(image, outfile)
  1317. X  imageInfo *image;
  1318. X  FILE *outfile;
  1319. {
  1320. X  XImage *ximage = image->ximage;
  1321. X  int w, h;
  1322. X  byte b, *line;
  1323. X  int lcount;
  1324. X  int reverse = BlackPixel(hDisplay, hScreen) == 0;
  1325. X  int swap    = ximage->bitmap_bit_order != LSBFirst;
  1326. X
  1327. X  if (verbose)
  1328. X    fprintf(stderr, "%s: formatting Bitmap output\n", programName);
  1329. X
  1330. X  if (ximage->depth != 1) {
  1331. X    fprintf(stderr, "%s: can't write polychrome images in XY bitmap format\n",
  1332. X      programName);
  1333. X    return;
  1334. X  }
  1335. X
  1336. X  fprintf(outfile, "#define %s_width %d\n",  imageName, ximage->width);
  1337. X  fprintf(outfile, "#define %s_height %d\n", imageName, ximage->height);
  1338. X  fprintf(outfile, "#define %s_x_hot 0\n",   imageName);
  1339. X  fprintf(outfile, "#define %s_y_hot 0\n",   imageName);
  1340. X  fprintf(outfile, "static char %s_bits[] = {\n", imageName);
  1341. X  lcount = 0;
  1342. X  fputs("  ", outfile);
  1343. X  for (h=0; h<ximage->height; h++) {
  1344. X    line = (byte *)(ximage->data + (h * ximage->bytes_per_line));
  1345. X    for (w=0; w<ximage->width; w+=8) {
  1346. X      b = line[w/8];
  1347. X      if (reverse) b = ~b;
  1348. X      if (swap)    b = swapbits(b);
  1349. X      fprintf(outfile, " 0x%02x", b);
  1350. X      if (h<ximage->height || w+8<ximage->width)
  1351. X        fputc(',', outfile);
  1352. X      lcount++;
  1353. X      if (lcount >= 12) {
  1354. X        fputs("\n  ", outfile);
  1355. X        lcount = 0;
  1356. X      }
  1357. X    }
  1358. X  }
  1359. X  fputs("  };\n", outfile);
  1360. }
  1361. X
  1362. X
  1363. X
  1364. X
  1365. X
  1366. X
  1367. X
  1368. X
  1369. /*
  1370. X * Write a color image out in Pixmap format.
  1371. X * Supported output formats are xpm1 (original xpm), xpm2  and xpm3
  1372. X */
  1373. writeZPixmap(xpmFormat, image, outfile)
  1374. X  imageInfo *image;
  1375. X  FILE *outfile;
  1376. {
  1377. X  XImage *ximage = image->ximage;
  1378. X  int nc, width, height, w, h, cidx, cpp;
  1379. X  char mne[MAX_CELLS][3];
  1380. X
  1381. X  if (verbose) {
  1382. X    switch (xpmFormat) {
  1383. X    case 3:
  1384. X      fprintf(stderr, "%s: formatting XPM3 Pixmap output\n", programName);
  1385. X      break;
  1386. X    case 2:
  1387. X      fprintf(stderr, "%s: formatting XPM2 Pixmap output\n", programName);
  1388. X      break;
  1389. X    default:
  1390. X    case 1:
  1391. X      fprintf(stderr, "%s: formatting XPM output\n", programName);
  1392. X      break;
  1393. X    }
  1394. X  }
  1395. X
  1396. X  nc  = image->numcells;
  1397. X  cpp = image->numcells <= 26? 1 : 2;
  1398. X  switch (xpmFormat) {
  1399. X  case 3:
  1400. X    fprintf(outfile, "/* XPM */\nstatic char * image_name [] = {\n\"%d %d %d %d\",.\n",
  1401. X      ximage->width, ximage->height, image->numcells, cpp);
  1402. X    fputs("/* pixels*/\n", outfile);
  1403. X    break;
  1404. X  case 2:
  1405. X    fprintf(outfile, "! XPM2  \n%d %d %d %d\n", ximage->width,
  1406. X      ximage->height, image->numcells, cpp);
  1407. X    fputs("! pixels\n", outfile);
  1408. X    break;
  1409. X  case 1:
  1410. X  default:
  1411. X    fprintf(outfile, "#define %s_format 1\n",   imageName);
  1412. X    fprintf(outfile, "#define %s_width %d\n",   imageName, ximage->width);
  1413. X    fprintf(outfile, "#define %s_height %d\n",  imageName, ximage->height);
  1414. X    fprintf(outfile, "#define %s_ncolors %d\n", imageName, image->numcells);
  1415. X    fprintf(outfile, "#define %s_chars_per_pixel %d\n",     imageName, cpp);
  1416. X    fprintf(outfile, "static char * %s_colors[] = {\n", imageName);
  1417. X    break;
  1418. X  }
  1419. X
  1420. X  for (cidx=0; cidx<image->numcells; cidx++) {
  1421. X    if (cpp > 1) {
  1422. X      mne[cidx][0] = (char)(cidx / 10) + 'a';
  1423. X      mne[cidx][1] = (char)(cidx % 10) + '0';
  1424. X      mne[cidx][2] = '\0';
  1425. X    }
  1426. X    else {
  1427. X      mne[cidx][0] = (char)cidx + (cidx? 'A' : ' ');
  1428. X      mne[cidx][1] = '\0';
  1429. X    }
  1430. X    switch (xpmFormat) {
  1431. X    case 3:
  1432. X      fprintf(outfile, "\"%s\tc #%4.4x%4.4x%4.4x\",\n",mne[cidx],
  1433. X                image->red[cidx], image->green[cidx], image->blue[cidx]);
  1434. X      break;
  1435. X    case 2:
  1436. X      fprintf(outfile, "%s c #%4.4x%4.4x%4.4x\n", mne[cidx],
  1437. X                image->red[cidx], image->green[cidx], image->blue[cidx]);
  1438. X      break;
  1439. X    default:
  1440. X    case 1:
  1441. X      fprintf(outfile, "\"%s\", \"#%4.4x%4.4x%4.4x\"\n", mne[cidx],
  1442. X                image->red[cidx], image->green[cidx], image->blue[cidx]);
  1443. X      break;
  1444. X    }
  1445. X  }
  1446. X  if (xpmFormat == 1) {
  1447. X    fputs("} ;\n", outfile);
  1448. X    fprintf(outfile, "static char * %s_pixels[] = {\n", imageName);
  1449. X  }
  1450. X  for (h=0; h<ximage->height; h++) {
  1451. X    if (xpmFormat != 2)
  1452. X      fputs("\"", outfile);
  1453. X    for (w=0; w<ximage->width; w++)
  1454. X      fputs(mne[XGetPixel(ximage, w, h)], outfile);
  1455. X    if (xpmFormat == 2)
  1456. X      fputs("\n", outfile);
  1457. X    else
  1458. X      fputs("\",\n", outfile);
  1459. X  }
  1460. X  if (xpmFormat == 3)
  1461. X    fputs("};\n", outfile);
  1462. X  else if (xpmFormat != 2)
  1463. X    fputs("} ;\n", outfile);
  1464. }
  1465. X
  1466. X
  1467. X
  1468. X
  1469. SHAR_EOF
  1470. chmod 0644 write.hc ||
  1471. echo 'restore of write.hc failed'
  1472. Wc_c="`wc -c < 'write.hc'`"
  1473. test 36231 -eq "$Wc_c" ||
  1474.     echo 'write.hc: original size 36231, current size' "$Wc_c"
  1475. rm -f _shar_wnt_.tmp
  1476. fi
  1477. # ============= xgrabsc.man ==============
  1478. if test -f 'xgrabsc.man' -a X"$1" != X"-c"; then
  1479.     echo 'x - skipping xgrabsc.man (File already exists)'
  1480.     rm -f _shar_wnt_.tmp
  1481. else
  1482. > _shar_wnt_.tmp
  1483. echo 'x - extracting xgrabsc.man (Text)'
  1484. sed 's/^X//' << 'SHAR_EOF' > 'xgrabsc.man' &&
  1485. .\"========================================================================
  1486. .\"
  1487. .\" Name - xgrabsc.man
  1488. .\"
  1489. .\" ccs version: 1.11
  1490. .\"
  1491. .\" ccsid:    @(#)xgrabsc.man    1.11 - 7/9/92 12:49:29
  1492. .\" from:     ccs/s.xgrabsc.man
  1493. .\" date:     7/9/92 13:35:31
  1494. .\"
  1495. .\" Copyright (C) 1990-92 Bruce Schuchardt
  1496. .\" See the end of this document for full copyright information.
  1497. .\"
  1498. .\" Description:  Man page for xgrabsc
  1499. .\"
  1500. .\"========================================================================
  1501. .\"
  1502. .TH XGRABSC 1X
  1503. .\"
  1504. .SH NAME
  1505. xgrabsc \- grab rectangular screen images and store in files
  1506. .\"
  1507. .SH SYNOPSIS
  1508. .in +8n
  1509. .ti -8n
  1510. \fIxgrabsc\fR
  1511. [\fB\-d\fP\ \fIdisplay\fP]
  1512. [\fB\-id\fP\ \fIwindowId\fP]
  1513. [\fB\-o\fP\ \fIoutputFile\fP]
  1514. [\fB\-s\fP\ \fIseconds\fP]
  1515. [\fB\-post\fP\ \fIseconds\fP]
  1516. [\fB\-b\fP\ \fIpercent\fP]
  1517. [\fB\-and\fP\ \fIandBits\fP]
  1518. [\fB\-or\fP\ \fIorBits\fP]
  1519. [\fB\-page\fP\ \fIwidthxheight-hmarg-vmarg\fP]
  1520. [\fB\-bell -grab -verbose -bdrs -nobdrs -key -stretch -root -click
  1521. .br
  1522. -reverse -bw -mdither -dither -halftone -nodither
  1523. .br
  1524. -ps -cps -simple -xwd -bm -bm2 -bm3 -puzzle
  1525. .br
  1526. -bin -comp -eps -l -limit -preview -prev -colproc\fP]
  1527. .in -8n
  1528. .\"
  1529. .\"
  1530. .\"
  1531. .SH DESCRIPTION
  1532. \fIxgrabsc\fR lets you grab arbitrary rectangular images from an
  1533. XX server and writes them to standard output in a variety of formats.
  1534. .PP
  1535. Command line options also allow reduction of colormaps, halftoning
  1536. and dithering of color images, and direct mapping of color images
  1537. to monochrome.  Options must be seperated with spaces or tabs, and many
  1538. can be preceded by two dashes instead of one to them turn off.
  1539. .PP
  1540. The default output format is gray-scale non-encapsulated Postscript, with
  1541. image compression (if image compression significantly reduces the amount of
  1542. output).
  1543. .\"
  1544. .\"
  1545. .\"
  1546. .\"
  1547. .SH GENERAL OPTIONS
  1548. .TP 8
  1549. -d \fIdisplayName\fP or -display \fIdisplayName\fP
  1550. .br
  1551. Use an alternate display.  If no display is specified on the command line,
  1552. xgrabsc looks for the environment variable DISPLAY for the name of the
  1553. display and screen to grab from.  Note that you must have permission to
  1554. access the display on another computer.
  1555. .TP
  1556. -bell
  1557. The display's bell is normally rung while the screen is being accessed.
  1558. This turns the bell on or off (\fI--bell\fP will turn it \fIoff\fP).
  1559. .TP
  1560. -grab
  1561. Enable server grabs.  Normally xgrabsc will "grab" the server so
  1562. that the screen is frozen while a rectangle is selected and the image
  1563. is extracted.  If the screen is not frozen, rubber-banding may cause
  1564. video droppings on portions of the screen that are changing.  Use \fI--grab\fP
  1565. to turn off server grabs.
  1566. .TP
  1567. -o \fIoutput-file\fP or -output \fIoutput-file\fP
  1568. .br
  1569. Write output to \fIoutput-file\fP instead of standard output.  The
  1570. output-file name, minus directory and extension, is used as the internal
  1571. name for the image in formats supporting image names.  Postscript,
  1572. xwd, pixmap and bitmap formats all support image names.
  1573. .TP
  1574. -s \fIseconds\fP or -sleep \fIseconds\fP
  1575. .br
  1576. Sleep for \fIseconds\fP seconds before commencing operation.  This
  1577. should be used if you need some time to get the target image ready.
  1578. .TP
  1579. -post \fIseconds\fP
  1580. Sleep for \fIseconds\fP seconds after window/rectangle selection.  This is
  1581. commonly used to pop up menus after a window has been selected but before
  1582. xgrabsc takes its snapshot.
  1583. .TP
  1584. -verbose
  1585. Display processing information on standard error output (stderr).
  1586. .sp 3
  1587. .\"
  1588. .\"
  1589. .\"
  1590. .\"
  1591. .\"
  1592. .SH SELECTION OPTIONS
  1593. .TP
  1594. -id \fIwindow ID\fP
  1595. Dump the window with the given ID.
  1596. .TP
  1597. -key
  1598. Select the window under the mouse when the Control key is pressed.  This
  1599. option is normally used in getting images of menus.  Pop up the menu,
  1600. optionally move the pointer to the window containing the menu, and strike
  1601. the Control key to begin the dump.
  1602. .TP
  1603. -root
  1604. Dump the entire screen (root window).
  1605. .TP
  1606. -stretch
  1607. Use rubber-band rectangle to select region to grab.  This is the
  1608. default.
  1609. .TP
  1610. -click
  1611. Wait for a click on a window and dump the selected window.
  1612. .\"
  1613. .\"
  1614. .\"
  1615. .\"
  1616. .\"
  1617. .sp 3
  1618. .SH IMAGE PROCESSING OPTIONS
  1619. .TP
  1620. -nobdrs or -noborders
  1621. .br
  1622. Remove window-manager borders from window images.  This option
  1623. applies only to selection by ID (\fI\-id\fP) or xwd-style selection
  1624. (\fI-click\fP).
  1625. .TP
  1626. -bdrs or -borders
  1627. .br
  1628. Include window-manager borders in window images.  This option
  1629. applies only to selection by ID (\fI\-id\fP) or xwd-style selection
  1630. (\fI-click\fP).  It is provided as a convenience since \fI--noborders\fP
  1631. doesn't exactly flow from most peoples minds.
  1632. .TP
  1633. -b \fIpercent\fR or -brighten \fIpercent\fR
  1634. .br
  1635. brighten or darken the image by \fIpercent\fR.  Percentages are given
  1636. as integers. 100 is the base and a larger number will brighten the image
  1637. while a smaller number will darken the image.
  1638. .TP
  1639. -and \fIandBits\fR
  1640. Clear all colormap bits up to the given plane.  This has the effect of
  1641. darkening the image somewhat and shrinking the apparent depth of the image
  1642. (and, consequently, the size of the color table).  \fIAndBits\fR should
  1643. be in the range [1-8] inclusive.
  1644. .TP
  1645. -or \fIorBits\fR
  1646. Set all colormap bits up to the given plane.  This brightens the image
  1647. somewhat and also shrinks the apparent depth of the image.  When
  1648. both \-A and \-O are specified, ANDing will occur before ORing.
  1649. .TP
  1650. -reverse
  1651. Reverse the colors in the image.  The bits of each color used in the
  1652. image are inverted.
  1653. .TP
  1654. -bw
  1655. Convert the source color image to a monochrome bitmap.  All colors
  1656. falling below the average color intensity are mapped to black.  Others
  1657. are mapped to white.
  1658. .TP
  1659. -halftone
  1660. Convert the source color image to a halftoned monchrome bitmap.
  1661. Resolution is maintained by increasing the size of the image by
  1662. a factor of four on both axes.
  1663. .TP
  1664. -mdither
  1665. Convert the source color image to a dithered monochrome bitmap.
  1666. This is like halftoning, but resolution is sacrificed to keep the
  1667. resulting image the same size as the original.  The matrix dithering
  1668. algorithm used with this option is most suitable for line-drawings
  1669. and text.  For more complex graphics the \fI-dither\fR option is recommended.
  1670. .TP
  1671. -dither
  1672. Convert the source color image to a dithered monochrome bitmap with
  1673. the Floyd-Steinberg algorithm.
  1674. .sp 3
  1675. .\"
  1676. .\"
  1677. .\"
  1678. .\"
  1679. .SH OUTPUT FORMAT OPTIONS
  1680. .TP
  1681. -cps
  1682. Write output in \fIPostscript\fP format using the colorimage operator
  1683. for color printers.
  1684. Color to grayscale conversion is bundled into the output so you can actually
  1685. use either color or cheaper grayscale printers.  For monochrome displays, the
  1686. \fI-ps\fP option will give more compact output.
  1687. .TP
  1688. -ps
  1689. Write output in \fIPostscript\fP format for greyscale printers.
  1690. The number of bits per Postscript sample is determined by the depth of the
  1691. image.
  1692. .TP
  1693. -xwd
  1694. Write output in \fIxwd\fP format.  Use this if you want to convert to another
  1695. output format with \fBPbm+\fP.
  1696. .TP
  1697. -bm
  1698. Write the output in X Bitmap format if the image is black and white, or
  1699. XX Pixmap format if the image is gray or color.
  1700. .TP
  1701. -bm2
  1702. Write the output in X Bitmap format if the image is black and white, or
  1703. XX Pixmap format 2 if the image is gray or color.
  1704. -bm3
  1705. Write the output in X Bitmap format if the image is black and white, or
  1706. XX Pixmap format 3 if the image is gray or color.
  1707. .TP
  1708. -puzzle
  1709. Write output in a format suitable for loading into the \fIpuzzle\fP
  1710. program (see example below).
  1711. .sp 2
  1712. .\"
  1713. .\"
  1714. .\"
  1715. .\"
  1716. .\"
  1717. .SH POSTSCRIPT OPTIONS
  1718. .TP
  1719. -compress
  1720. Enable or suppress Postscript image run-length encoding.  Postscript output
  1721. is
  1722. normally compressed to minimize the size of output.  If your printer
  1723. can't handle compressed output, you should use \fI--compress\fP to turn
  1724. off compression.
  1725. .TP
  1726. -eps
  1727. Create Encapsulated Postscript output, rather than normal stand-alone
  1728. Postscript.  This adds EPSF header comments and removes all scaling and
  1729. translation of the image.
  1730. .TP
  1731. -l or -landscape
  1732. .br
  1733. Use landscape layout (11 x 8.5) for Postscript output.  This option is
  1734. ignored if Encapsulated Postscript output is requested.
  1735. .TP
  1736. -bin
  1737. Write Postscript output in binary rather than using hexidecimal encoding.
  1738. This causes the image portion of the output to use half as much space,
  1739. decreasing transmission time to the printer.  Note that not all print
  1740. spoolers can handle 8 bit binary data, so this may not work on your system!
  1741. .TP
  1742. -limit
  1743. For Postscript output, check printer memory availability before attempting
  1744. to print an image (the code to perform the checks is integrated into the
  1745. output of xgrabsc).  This is turned off if Encapsulated Postscript output
  1746. is requested, and may be disabled completely when building the xgrabsc
  1747. program.  On the command line it may be turned off with \fI--limit\fP.
  1748. .TP
  1749. -preview or -prev
  1750. .br
  1751. Selects Encapsulated Postscript output with an EPSI preview image in its
  1752. header.  The preview image is dithered to black and white.  Programs such
  1753. as xfig can display these preview images.  Ghostscript and other Postscript
  1754. interpreters can be used to preview EPS files without generating preview
  1755. images, so if you have one of these packages there is not much point in using
  1756. this option.
  1757. .TP
  1758. -page \fIwidthxheight-marginWidth-marginHeight\fP
  1759. Sets the size of the paper and the borders you desire around the edge of the
  1760. paper.  Xgrabsc will reduce the image if necessary to keep it within the
  1761. borders you specify.  The default page size and margins are set when
  1762. SHAR_EOF
  1763. true || echo 'restore of xgrabsc.man failed'
  1764. fi
  1765. echo 'End of  part 1'
  1766. echo 'File xgrabsc.man is continued in part 2'
  1767. echo 2 > _shar_seq_.tmp
  1768. exit 0
  1769. -- 
  1770. ---
  1771. Senior Systems Scientist        mail: dcmartin@msi.com
  1772. Molecular Simulations, Inc.        uucp: uunet!dcmartin
  1773. 796 North Pastoria Avenue        at&t: 408/522-9236
  1774.