home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume18 / xgrabsc-2.1 / part02 < prev    next >
Internet Message Format  |  1992-07-23  |  51KB

  1. Path: uunet!ogicse!hp-cv!sdd.hp.com!mips!msi!dcmartin
  2. From: bruce@SLC.COM (Bruce Schuchardt)
  3. Newsgroups: comp.sources.x
  4. Subject: v18i053: xgrabsc v2.1 - grab screen dump, Part02/05
  5. Message-ID: <1992Jul23.140149.27003@msi.com>
  6. Date: 23 Jul 92 14:01:49 GMT
  7. Article-I.D.: msi.1992Jul23.140149.27003
  8. References: <csx-18i052-xgrabsc-2.1@uunet.UU.NET>
  9. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  10. Organization: Molecular Simulations, Inc.
  11. Lines: 1669
  12. Approved: dcmartin@msi.com
  13. Originator: dcmartin@fascet
  14.  
  15. Submitted-by: bruce@SLC.COM (Bruce Schuchardt)
  16. Posting-number: Volume 18, Issue 53
  17. Archive-name: xgrabsc-2.1/part02
  18.  
  19. #!/bin/sh
  20. # this is part.02 (part 2 of a multipart archive)
  21. # do not concatenate these parts, unpack them in order with /bin/sh
  22. # file xgrabsc.man continued
  23. #
  24. if test ! -r _shar_seq_.tmp; then
  25.     echo 'Please unpack part 1 first!'
  26.     exit 1
  27. fi
  28. (read Scheck
  29.  if test "$Scheck" != 2; then
  30.     echo Please unpack part "$Scheck" next!
  31.     exit 1
  32.  else
  33.     exit 0
  34.  fi
  35. ) < _shar_seq_.tmp || exit 1
  36. if test ! -f _shar_wnt_.tmp; then
  37.     echo 'x - still skipping xgrabsc.man'
  38. else
  39. echo 'x - continuing file xgrabsc.man'
  40. sed 's/^X//' << 'SHAR_EOF' >> 'xgrabsc.man' &&
  41. xgrabsc is built.  Measurements are in inches (e.g., 8.5x11.0-0.5-0.5)
  42. .sp 3
  43. .\"
  44. .\"
  45. .\"
  46. .\"
  47. .\"
  48. .\"
  49. .\"
  50. .SH PROCESSING ORDER
  51. It is helpful to know the order of processing when multiple processing
  52. options are given on the command line.
  53. .PP
  54. Processing is done in five phases:  1) set up, 2) obtain image,
  55. 3) process colors, 4) poly->monochrome conversions, and 5) output conversion.
  56. .PP
  57. The set-up phase includes processing command-line options, sleeping,
  58. connecting to X-Windows, freezing the screen, and grabbing the mouse if
  59. necessary.
  60. .PP
  61. If the mouse is grabbed for rubber-banding, an upper-left-corner cursor is
  62. displayed until the left mouse button is pressed.  A lower-left-corner
  63. cursor is then displayed while drawing rubber-rectangles until the mouse
  64. button is released.
  65. .PP
  66. If the mouse is grabbed for xwd-style window selection, an xwd-style cursor
  67. is displayed until the left mouse button is pressed.
  68. .PP
  69. The mouse is then released.
  70. .PP
  71. The bell is then run and the image is pulled from the screen.
  72. .PP
  73. Following the image-grab, the bell is run twice and the screen is released.
  74. .PP
  75. If the image is not monochrome, the color manipulation functions are
  76. then applied in this order: brighten, AND, and OR, reverse.
  77. .PP
  78. Only one polychrome to monochrome conversion is allowed.  If none of
  79. these is chosen, the color table of a polychrome image is compressed
  80. in preparation for output conversion.
  81. .PP
  82. The output stream is then opened and the image is written in the selected
  83. output format.
  84. .sp 2
  85. .SH ENVIRONMENT
  86. XXGRABSC - specifies command line arguments to be processed before those
  87. actually entered on the command line.
  88. .PP
  89. DISPLAY - specifies the name of the display that xgrabsc should grab from.
  90. .sp 2
  91. .SH EXAMPLES
  92. The simplest form of use, giving Postscript output, is
  93. .sp
  94. .ti +5
  95. xgrabsc >outfile.ps
  96. .sp
  97. .PP
  98. To write output in \fIPostscript\fP format and send to the printer,
  99. use
  100. .sp
  101. .ti +5
  102. xgrabsc | lpr
  103. .sp
  104. It is sometimes helpful to brighten an image somewhat before it is
  105. formatted for Postscript output.  E.g., to brighten by 30%
  106. .sp
  107. .ti +5
  108. xgrabsc -b 130 | lpr
  109. .sp
  110. .PP
  111. If your printer supports color, and your display is color, you can
  112. have xgrabsc generate color output instead of gray scale:
  113. .sp
  114. .ti +5
  115. xgrabsc -cps | lpr
  116. .sp
  117. .PP
  118. The default Postscript output attempts to scale the image so that
  119. it will all fit on one page, and is centered on the page.  If you
  120. are grabbing images to include in documents, such as with FrameMaker,
  121. you should ask for Encapsulated Postscript output with the \fI-eps\fP
  122. switch.  For example:
  123. .sp
  124. .ti +5
  125. X  xgrabsc -eps -o image1.eps
  126. .PP
  127. To select an entire window, write output in \fIpuzzle\fP format
  128. and read into the puzzle program, use the commands
  129. .sp
  130. .ti +5
  131. xgrabsc -click -puzzle >outfile.pzl
  132. .br
  133. .ti +5
  134. puzzle -picture outfile.pzl
  135. .sp
  136. .PP
  137. To have xgrabsc sleep for three seconds before rubber-banding, display
  138. processing information, and have the result displayed with xwud,
  139. .sp
  140. .ti +5
  141. xgrabsc -xwd -verbose -s 3 | xwud
  142. .sp
  143. .PP
  144. To grab an image from another server and then reduce the colormap
  145. to three bits by ANDing, use
  146. .sp
  147. .ti +5
  148. xgrabsc -d other:0.0 -and 5 -bm >outfile.xpm
  149. .sp
  150. You will, of course, have to go to the other machine to select the
  151. image with that machine's mouse.
  152. .sp 2
  153. .SH LIMITATIONS
  154. Colormaps larger than 256 entries are not currently supported. This
  155. means that it won't work with your fancy 24-bit display.
  156. .PP
  157. The default screen visual is used as the visual for the image.
  158. Visuals are associated with particular windows, and xgrabsc pretends
  159. ignorance about any windows but the root.
  160. .PP
  161. This software has been tested with StaticGray and 8-plane PseudoColor
  162. on DECStations (using both UWS 2.2 and X11 Release 4).  It has also
  163. been tested with 8-plane PseudoColor on Sun SparcStations and various
  164. other platforms using X11 Release 4 and Release 5.
  165. .PP
  166. XX11 Pixmap format is rather verbose.
  167. You may want to run large images through the \fIcompress\fP utility
  168. before storing them in a file.  E.g.,
  169. .sp
  170. .ti +5
  171. xgrabsc -bm | compress >outfile.xpm.Z
  172. .sp
  173. .SH AUTHOR
  174. .nf
  175. X     Bruce Schuchardt
  176. X    Servio Corporation
  177. X      bruce@slc.com
  178. .fi
  179. .sp 2
  180. .SH ACKNOWLEGEMENTS
  181. .PP
  182. Some of the source code for xgrabsc came from
  183. the xloadimage project by Jim Frost (jimf@saber.com) and others.  Jim's
  184. copyright has been included both here and in the source code.
  185. .PP
  186. The idea for using run-length encoding for Postscript output came from
  187. the xwd2ps project by Robert Tatar and Craig A. McGowan, as did the
  188. colorimage hack for monochrome display devices.
  189. .PP
  190. The ad2c.sed script that makes it possible to let you run xgrab without
  191. installing XGrab.ad everywhere is part of the ad2c package developed by
  192. George Ferguson.
  193. .sp 2
  194. .SH CONTRIBUTORS
  195. .PP
  196. Johan Garpendal did the initial color postscript work.
  197. .PP
  198. Hal R. Brand wrote the binary Postscript enhancements.
  199. .PP
  200. Yves Arrouye wrote the EPS Preview and page-configuration enhancements.
  201. .sp 2
  202. .SH COPYRIGHT
  203. Copyright (c) 1990-92 Bruce Schuchardt
  204. .PP
  205. \fIXgrabsc\fR is copywritten material with a very loose copyright
  206. allowing unlimited modification and distribution if the copyright
  207. notices are left intact.  Various portions are copywritten by various
  208. people, but all use a modification of the MIT copyright notice.
  209. Please check the source for complete copyright information.  The
  210. intent is to keep the source free, not to stifle its distribution, so
  211. please write to me if you have any questions.
  212. .PP
  213. THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  214. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
  215. NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  216. CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
  217. OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  218. OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
  219. USE OR PERFORMANCE OF THIS SOFTWARE.
  220. .s 2
  221. .SH SEE ALSO
  222. XX(1X), xhost(1), xwd(1X), xwud(1X), xwd2ps(1X), xloadimage(1X), xpm(1X),
  223. xpr(1X), puzzle(1X), compress(1), uncompress(1), xv(1X)
  224. SHAR_EOF
  225. echo 'File xgrabsc.man is complete' &&
  226. chmod 0644 xgrabsc.man ||
  227. echo 'restore of xgrabsc.man failed'
  228. Wc_c="`wc -c < 'xgrabsc.man'`"
  229. test 15159 -eq "$Wc_c" ||
  230.     echo 'xgrabsc.man: original size 15159, current size' "$Wc_c"
  231. rm -f _shar_wnt_.tmp
  232. fi
  233. # ============= Bugs ==============
  234. if test -f 'Bugs' -a X"$1" != X"-c"; then
  235.     echo 'x - skipping Bugs (File already exists)'
  236.     rm -f _shar_wnt_.tmp
  237. else
  238. > _shar_wnt_.tmp
  239. echo 'x - extracting Bugs (Text)'
  240. sed 's/^X//' << 'SHAR_EOF' > 'Bugs' &&
  241. /*========================================================================
  242. *
  243. * Name - Bugs
  244. *
  245. * Version:    1.4
  246. *
  247. * ccsid:    @(#)Bugs    1.4 - 7/9/92 12:47:40
  248. * from:     ccs/s.Bugs
  249. * date:     7/9/92 13:35:24
  250. *
  251. * Description: Known bugs and problems.  This list does not include
  252. *              bugs that have been fixed.  See the patch set README
  253. *              files for descriptions of the bugs they fix.
  254. *
  255. *========================================================================*/
  256. X
  257. *  Postscript images produced by xgrabsc don't get printed
  258. X
  259. This is almost always a memory requirement problem.  Xgrabsc v2.0 
  260. can generate checks for memory availability so you can at least 
  261. see how much memory you're lacking to be able to print your 
  262. document.  I'd like to be able to preempt the transfer of the 
  263. rest of the file when there isn't enough memory to process it, 
  264. but haven't been able to make this happen.
  265. X
  266. X
  267. *  The puzzle program won't display xgrabsc output
  268. X
  269. While xgrabsc can create puzzle picture files from monochrome 
  270. screens, the puzzle program will not display pictures with "-
  271. picture" on monochrome systems. This is not a "bug" in xgrabsc, 
  272. but is a "confusing feature".
  273. X
  274. X
  275. *  When started from a window-manager menu, xgrabsc fails to grab an image.
  276. X
  277. If you run xgrabsc from a Twm menu, be sure to end your exec 
  278. command with "&". The program may not be able to grab the pointer 
  279. or server unless you do this.  This will likely happen with any 
  280. window manager, but has been reported onlyfor Twm.
  281. X
  282. X
  283. *  Encapsulate Postscript images are not centered or scaled when printed
  284. X
  285. This isn't a problem with xgrabsc.  EPS files are not supposed to
  286. contain scaling or transformation commands.
  287. X
  288. X
  289. *  The X cursor isn't included in images
  290. X
  291. If someone can tell me how to grab an image with the X cursor, I'd
  292. be much obliged.  Most X servers explicitely hide the cursor when
  293. processing getImage requests.
  294. X
  295. X
  296. * BadMatch errors are generated when grabbing with the keyboard (-k) and
  297. X  the cursor is on a menubar
  298. X
  299. I haven't been able to reproduce this error.
  300. X
  301. X
  302. * Can't grab xeyes
  303. X
  304. I haven't been able to reproduce this problem.
  305. X
  306. X
  307. * Dithered output sent to "xpr" for a laserjet doesn't produce an image
  308. X
  309. I have no laserjet to test with.
  310. X
  311. X
  312. * The halftoning algorithm in xgrabsc should be improved
  313. X
  314. Someone have a better algorithm?  If so, please send it to me.  I'm
  315. not interested in supporting zillions of different dithering
  316. algorithms, but would be happy to improve the ones already in xgrabsc.
  317. X
  318. X
  319. * Postscript output doesn't center properly when printed
  320. X
  321. The paper size is hard-coded into xgrabsc.  If you're not using the
  322. US Letter size (8.5 x 11 inches), you'll have to change the constants
  323. in config.h to the size of paper you use.  Paper size selection will
  324. be a command-line option in a future release of xgrabsc.
  325. X
  326. X
  327. * Binary Postscript images appear dark when printed
  328. X
  329. Your print spooler is probably stripping off the top bits of the binary
  330. data, causing the samples to be darker.  Some systems have "lpr" options
  331. to tell the spooler that the file you're printing contains binary data.
  332. Consult your lpr documentation.
  333. X
  334. X
  335. SHAR_EOF
  336. chmod 0644 Bugs ||
  337. echo 'restore of Bugs failed'
  338. Wc_c="`wc -c < 'Bugs'`"
  339. test 3103 -eq "$Wc_c" ||
  340.     echo 'Bugs: original size 3103, current size' "$Wc_c"
  341. rm -f _shar_wnt_.tmp
  342. fi
  343. # ============= README ==============
  344. if test -f 'README' -a X"$1" != X"-c"; then
  345.     echo 'x - skipping README (File already exists)'
  346.     rm -f _shar_wnt_.tmp
  347. else
  348. > _shar_wnt_.tmp
  349. echo 'x - extracting README (Text)'
  350. sed 's/^X//' << 'SHAR_EOF' > 'README' &&
  351. *========================================================================
  352. *
  353. * Name - README
  354. *
  355. * Version:    1.9
  356. *
  357. * ccsid:    @(#)README    1.9 - 7/9/92 12:47:46
  358. * from:     ccs/s.README
  359. * date:     7/9/92 13:35:25
  360. *
  361. * Copyright (C) 1990-92 Bruce Schuchardt
  362. * See either the man page or the file cpyright.h for full copyright
  363. * information.
  364. *
  365. * Description:  README for xgrabsc v2.1
  366. *
  367. *========================================================================
  368. X
  369. INTRO TO xgrabsc
  370. X
  371. When I first wrote xgrabsc, there were a number of programs available
  372. for getting X-Window screen dumps (e.g., xwd and xwps), but they
  373. were all restricted to dumping a single window in a single format.
  374. I wrote xgrabsc in an effort to get around these restrictions.
  375. X
  376. The main contribution of this program is its use of root-window
  377. rubberbanding to allow capture of arbitrary portions of the screen,
  378. and its multiple output formats (x-bitmap, x-pixmap, xwd, puzzle,
  379. "simple", and several Postscript formats).
  380. X
  381. The Postscript dumps will use run-length encoding if it results in
  382. any savings in size.  A typical xterm window dump on a mono system
  383. runs around 40K bytes (20K for binary output).  An xwd dump on the
  384. same screen will be around 650K bytes.  While the xpr program has a
  385. "compress" option, it only compresses white samples.  Reducing the 
  386. size of the output increases the cost of computing the dump and the
  387. final printing of the dump, but it reduces the cost of storage and
  388. the time to transfer the dump to your printer.  The latter is
  389. especially important for large screen dumps.
  390. X
  391. The xgrabsc program is not interactive.  You specify all processing
  392. options on the command line with obscure option characters.  These
  393. are all detailed in the man page.  An interactive interface to xgrabsc,
  394. named xgrab, is also included in this release.  xgrab allows you to
  395. do most of the setup with a mouse, and then uses the xgrabsc program
  396. to actually do the processing.  To use xgrab you must have the xgrabsc
  397. program in your execution path.
  398. X
  399. X
  400. X
  401. OPTIONS FOR BUILDING xgrabsc
  402. X
  403. The file config.h contains all the configuration options for xgrabsc.
  404. Please take a moment to look through that file before building xgrabsc.
  405. X
  406. X
  407. X
  408. BUILDING xgrabsc
  409. X
  410. XXgrabsc should build easily enough.  If you don't have the imake
  411. program, use simple.mak (i.e., make -f simple.mak).  There are targets
  412. for xgrabsc, install, install.man, and clean.  E.g.,
  413. X  make
  414. X  make install
  415. X  make install.man
  416. X  make clean
  417. X
  418. The install target will put xgrabsc in /usr/bin/X11 and the
  419. man page in /usr/man/man1.  Change simple.mak before installing
  420. with it if you don't like these locations.
  421. X
  422. For Vax/VMS installations, this release includes a VMSMAKE.COM script that was
  423. contributed by a user, as well as a GETOPT.C module that implements the
  424. getopt() function.  I am informed that you will also need a copy of the
  425. XXWDfile.h include file from the MIT XWindows distribution, so I've included a
  426. copy of that file.  I do not have a Vax to test with so I can't claim you won't
  427. have problems in building xgrabsc under VMS, but this gives you a running start
  428. at it. 
  429. X
  430. X
  431. X
  432. Please send comments, bugs, and enhancements to bruce@slc.com.  Please
  433. read the Bugs file before sending bug reports.
  434. X
  435. X
  436. X Manifest
  437. X ---------------------------------
  438. X README              this file
  439. X README.xx_yy        files describing incremental changes to xgrabsc
  440. X
  441. X Acks                acknowledgements for code gleaned from other
  442. X                     systems, and people who have been very helpful
  443. X                     in adding features and removing bugs from xgrabsc
  444. X
  445. X Bugs                known bugs - read this before sending bug reports
  446. X
  447. X Imakefile           Input for "imake" program
  448. X simple.mak          Simpler input for standard "make"
  449. X
  450. X checkvm.h           Memory-check Postscript operator
  451. X config.h            Configuration options
  452. X cpyright.h          Copyright notice for this software (READ IT)
  453. X cmdopts.h         Command line options for xgrabsc
  454. X ps_color.h          Bob Tatar's colorimage operator for mono systems
  455. X patchlevel.h        Current patch level
  456. X virtual.h           Support for virtual window managers
  457. X xgrab.c             Source for window interface to xgrabsc
  458. X xgrabsc.c           Program source
  459. X
  460. X *.hc                function include files for xgrabsc.c
  461. X
  462. X VMSMAKE.COM         a DCL command script to make xgrabsc and xgrab under VMS
  463. X                     (this is untested - I no longer have a VAX at my disposal)
  464. X XWDfile.h           xwd structure definition needed for VAX/VMS builds
  465. X ad2c.sed            sed script to convert XGrab.ad to fallback resources
  466. X                     for xgrab
  467. X
  468. X xgrabsc.man         Man page for xgrabsc
  469. X xgrab.man           Man page for xgrab
  470. X
  471. X XGrab.ad            Resources for the xgrab program
  472. X
  473. X
  474. X
  475. BUGS:
  476. X
  477. Common problems and known bugs are described in the Bugs file.
  478. X
  479. X
  480. X
  481. TO DO:
  482. X
  483. Support for 24-bit displays.  If someone wants to give this a shot, please
  484. let me know.
  485. X
  486. Selectable paper size for Postscript output.
  487. X
  488. X
  489. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  490. X  Bruce Schuchardt          bruce@SLC.COM
  491. X  Servio Corp.
  492. X  Beaverton, OR
  493. SHAR_EOF
  494. chmod 0644 README ||
  495. echo 'restore of README failed'
  496. Wc_c="`wc -c < 'README'`"
  497. test 5078 -eq "$Wc_c" ||
  498.     echo 'README: original size 5078, current size' "$Wc_c"
  499. rm -f _shar_wnt_.tmp
  500. fi
  501. # ============= README.2_1 ==============
  502. if test -f 'README.2_1' -a X"$1" != X"-c"; then
  503.     echo 'x - skipping README.2_1 (File already exists)'
  504.     rm -f _shar_wnt_.tmp
  505. else
  506. > _shar_wnt_.tmp
  507. echo 'x - extracting README.2_1 (Text)'
  508. sed 's/^X//' << 'SHAR_EOF' > 'README.2_1' &&
  509. /*========================================================================
  510. *
  511. * Name - README.2_1
  512. *
  513. * Version:    1.1
  514. *
  515. * ccsid:    @(#)README.2_1    1.1 - 7/9/92 12:39:15
  516. * from:     ccs/s.README.2_1
  517. * date:     7/9/92 13:35:25
  518. *
  519. * Description: Notes on release 2.1
  520. *
  521. *========================================================================
  522. X
  523. X
  524. This release adds the following features:
  525. X
  526. * xgrabsc no longer uses getopt(), and most command line switches have been
  527. X  changed from single-characters to keywords.  Users of previous versions
  528. X  of xgrabsc should make sure any XGRABSC environment variables are updated
  529. X  to reflect this change.
  530. X  
  531. * Command line switches may be preceded with '-' (e.g., -preview) or
  532. X  '--' (e.g., --preview).  A double dash turns off an option, while a
  533. X  single or omitted dash turns on an option.  Each argument and switch must
  534. X  be seperated with white space.
  535. X
  536. * New xgrabsc options
  537. X
  538. X  preview    a preview option for encapsulated postscript output
  539. X  page        page size and border specification
  540. X  nodither    turns off any selected dithering options
  541. X  colproc    adds/removes the colorImage operator from color postscript
  542. X        output
  543. X  bm3        write color output in XPM3 format
  544. X
  545. * All xgrab text fields but the Alternate Display are now set in XGrab.ad
  546. X  instead of xgrab.c.  This means you can now put defaults for these fields
  547. X  in your .Xdefaults
  548. X
  549. * border removal now attempts to remove the window-mgr's title as well.
  550. X
  551. X
  552. Notes section:
  553. X
  554. Added attribution for ad2c.sed.  George Ferguson wrote ad2c and every person
  555. who uses xgrab without installing XGrab.ad should be grateful to George for
  556. ad2c, which is used to create the fallback resource set for the xgrab program.
  557. X
  558. Removed use of getopt() from xgrabsc, and changed all switches to be
  559. more verbose.  I was running out of letters and numbers and things were
  560. starting to get a bit silly.
  561. X
  562. Allow compression of images in EPS output.
  563. X
  564. Allow selection of colorImage proc output in config.h, and provide
  565. command-line option for adding/removing it.
  566. X
  567. Fixed border-removal switch in xgrab.  It was doing the reverse of what it
  568. advertised.
  569. X
  570. Made landscape and encapsulated postscript options mutually exclusive, and
  571. added preview option for encapsulated postscript.  The preview image is in
  572. EPSI format.  That is, it's the transportable image format, not TIFF or PICT.
  573. X
  574. Changed shapes of radio buttons in xgrab to make them distinguishable from
  575. toggle buttons and command buttons.
  576. X
  577. Removed setting of the text of all text fields in xgrab except the display.
  578. The display text is taken from your DISPLAY environment variable.  You can
  579. now set the other strings in your .Xdefaults file (see XGrab.ad for examples).
  580. X
  581. Added page-config option.  
  582. X
  583. Changed bitmap_pad in XCreateImage calls from 0 to 8.  The manual says it
  584. has to be 8, 16 or 32.  Zero isn't an option.  Odd that no-one has mentioned
  585. this before.
  586. X
  587. Added basic XPM3 output format
  588. X
  589. Made border removal search for a client window of the selected window if
  590. selection style is click or key.  This gets rid of the wm title too.
  591. SHAR_EOF
  592. chmod 0644 README.2_1 ||
  593. echo 'restore of README.2_1 failed'
  594. Wc_c="`wc -c < 'README.2_1'`"
  595. test 3026 -eq "$Wc_c" ||
  596.     echo 'README.2_1: original size 3026, current size' "$Wc_c"
  597. rm -f _shar_wnt_.tmp
  598. fi
  599. # ============= VMSMAKE.COM ==============
  600. if test -f 'VMSMAKE.COM' -a X"$1" != X"-c"; then
  601.     echo 'x - skipping VMSMAKE.COM (File already exists)'
  602.     rm -f _shar_wnt_.tmp
  603. else
  604. > _shar_wnt_.tmp
  605. echo 'x - extracting VMSMAKE.COM (Text)'
  606. sed 's/^X//' << 'SHAR_EOF' > 'VMSMAKE.COM' &&
  607. $!
  608. $! Name - VMSMAKE.COM
  609. $!
  610. $! ccs version:    1.2
  611. $!
  612. $! ccsid:    @(#)VMSMAKE.COM    1.2 - 7/9/92 13:07:31
  613. $! from:     ccs/s.VMSMAKE.COM
  614. $! date:     7/9/92 13:35:25
  615. $!
  616. $! This is an UNTESTED command file for building xgrabsc under Vax/VMS
  617. $!
  618. $!
  619. $ define x11 decw$include
  620. $ cc xgrabsc
  621. $ link xgrabsc,sys$input/opt
  622. sys$library:decw$xlibshr/share
  623. sys$library:vaxcrtl/share
  624. $!
  625. $! the link for xgrab is questionable - it probably needs an Athena
  626. $! widget library
  627. $!
  628. $ cc xgrab
  629. $ link xgrab,sys$input/opt
  630. sys$library:decw$xlibshr/share
  631. sys$library:vaxcrtl/share
  632. $ exit
  633. SHAR_EOF
  634. chmod 0644 VMSMAKE.COM ||
  635. echo 'restore of VMSMAKE.COM failed'
  636. Wc_c="`wc -c < 'VMSMAKE.COM'`"
  637. test 552 -eq "$Wc_c" ||
  638.     echo 'VMSMAKE.COM: original size 552, current size' "$Wc_c"
  639. rm -f _shar_wnt_.tmp
  640. fi
  641. # ============= XWDFile.h ==============
  642. if test -f 'XWDFile.h' -a X"$1" != X"-c"; then
  643.     echo 'x - skipping XWDFile.h (File already exists)'
  644.     rm -f _shar_wnt_.tmp
  645. else
  646. > _shar_wnt_.tmp
  647. echo 'x - extracting XWDFile.h (Text)'
  648. sed 's/^X//' << 'SHAR_EOF' > 'XWDFile.h' &&
  649. #include <X11/copyright.h>
  650. X
  651. /* Copyright 1985, 1986, Massachusetts Institute of Technology */
  652. X
  653. /* $XConsortium: XWDFile.h,v 1.12 89/10/08 16:33:57 rws Exp $ */
  654. /*
  655. X * XWDFile.h    MIT Project Athena, X Window system window raster
  656. X *        image dumper, dump file format header file.
  657. X *
  658. X *  Author:    Tony Della Fera, DEC
  659. X *        27-Jun-85
  660. X * 
  661. X * Modifier:    William F. Wyatt, SAO
  662. X *              18-Nov-86  - version 6 for saving/restoring color maps
  663. X */
  664. X
  665. X
  666. /*
  667. X * This is not portable between machines of differing word sizes.  To make
  668. X * it portable, do the following things:
  669. X *
  670. X *     o  #include <X11/Xmd.h>
  671. X *     o  remove the typedef for xwdval
  672. X *     o  replace all instances of xwdval with the appropriate CARD32 ... B32
  673. X *     o  make sure that XWDFileHeader is padded to quadword boundaries
  674. X *     o  make sure the window name is written out quadword aligned
  675. X *     o  create an XWDColor structure that contains the same fields as XColor
  676. X *        but which is defined in terms of CARD32 B32, CARD16 B16, and CARD8
  677. X *     o  convert XColor structures to XWDColor structures in xwd
  678. X *     o  remove all xwdval casts from xwd
  679. X *     o  pack image data before writing out if necessary
  680. X *     o  replace casts from xwdval objects in xwud with cvtINT macros
  681. X *     o  convert XWDColor structures to XColor structures
  682. X *     o  unpack data after reading in if necessary
  683. X */
  684. X
  685. X
  686. #include "Xmd.h"
  687. X
  688. #define XWD_FILE_VERSION 7
  689. #ifdef WORD64
  690. #define sz_XWDheader 104
  691. #else
  692. #define sz_XWDheader 100
  693. #endif
  694. #define sz_XWDColor 12
  695. X
  696. typedef CARD32 xwdval;        /* for old broken programs */
  697. X
  698. typedef struct _xwd_file_header {
  699. X    CARD32 header_size B32;  /* Size of the entire file header (bytes). */
  700. X    CARD32 file_version B32;    /* XWD_FILE_VERSION */
  701. X    CARD32 pixmap_format B32;    /* Pixmap format */
  702. X    CARD32 pixmap_depth B32;    /* Pixmap depth */
  703. X    CARD32 pixmap_width B32;    /* Pixmap width */
  704. X    CARD32 pixmap_height B32;    /* Pixmap height */
  705. X    CARD32 xoffset B32;        /* Bitmap x offset */
  706. X    CARD32 byte_order B32;        /* MSBFirst, LSBFirst */
  707. X    CARD32 bitmap_unit B32;        /* Bitmap unit */
  708. X    CARD32 bitmap_bit_order B32;    /* MSBFirst, LSBFirst */
  709. X    CARD32 bitmap_pad B32;        /* Bitmap scanline pad */
  710. X    CARD32 bits_per_pixel B32;    /* Bits per pixel */
  711. X    CARD32 bytes_per_line B32;    /* Bytes per scanline */
  712. X    CARD32 visual_class B32;    /* Class of colormap */
  713. X    CARD32 red_mask B32;        /* Z red mask */
  714. X    CARD32 green_mask B32;        /* Z green mask */
  715. X    CARD32 blue_mask B32;        /* Z blue mask */
  716. X    CARD32 bits_per_rgb B32;    /* Log2 of distinct color values */
  717. X    CARD32 colormap_entries B32;    /* Number of entries in colormap */
  718. X    CARD32 ncolors B32;        /* Number of Color structures */
  719. X    CARD32 window_width B32;    /* Window width */
  720. X    CARD32 window_height B32;    /* Window height */
  721. X    CARD32 window_x B32;        /* Window upper left X coordinate */
  722. X    CARD32 window_y B32;        /* Window upper left Y coordinate */
  723. X    CARD32 window_bdrwidth B32;    /* Window border width */
  724. #ifdef WORD64
  725. X    CARD32 header_end B32;        /* Pad to fill out word */
  726. #endif
  727. } XWDFileHeader;
  728. X
  729. struct {
  730. X        CARD32    pixel B32;
  731. X        CARD16    red B16;
  732. X    CARD16    green B16;
  733. X    CARD16    blue B16;
  734. X        CARD8    flags;
  735. X        CARD8    pad;
  736. } XWDColor;
  737. X
  738. X
  739. /*
  740. X * Name - XWDFile.h
  741. X *
  742. X * ccs version:    1.1
  743. X *
  744. X * ccsid:    @(#)XWDFile.h    1.1 - 7/2/92 16:01:52
  745. X * from:     ccs/s.XWDFile.h
  746. X * date:     7/9/92 13:35:26
  747. X *
  748. X * This is XWDFile.h from XWindows v11r4
  749. X */
  750. SHAR_EOF
  751. chmod 0644 XWDFile.h ||
  752. echo 'restore of XWDFile.h failed'
  753. Wc_c="`wc -c < 'XWDFile.h'`"
  754. test 3313 -eq "$Wc_c" ||
  755.     echo 'XWDFile.h: original size 3313, current size' "$Wc_c"
  756. rm -f _shar_wnt_.tmp
  757. fi
  758. # ============= Xmd.h ==============
  759. if test -f 'Xmd.h' -a X"$1" != X"-c"; then
  760.     echo 'x - skipping Xmd.h (File already exists)'
  761.     rm -f _shar_wnt_.tmp
  762. else
  763. > _shar_wnt_.tmp
  764. echo 'x - extracting Xmd.h (Text)'
  765. sed 's/^X//' << 'SHAR_EOF' > 'Xmd.h' &&
  766. /***********************************************************
  767. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  768. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  769. X
  770. X                        All Rights Reserved
  771. X
  772. Permission to use, copy, modify, and distribute this software and its 
  773. documentation for any purpose and without fee is hereby granted, 
  774. provided that the above copyright notice appear in all copies and that
  775. both that copyright notice and this permission notice appear in 
  776. supporting documentation, and that the names of Digital or MIT not be
  777. used in advertising or publicity pertaining to distribution of the
  778. software without specific, written prior permission.  
  779. X
  780. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  781. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  782. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  783. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  784. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  785. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  786. SOFTWARE.
  787. X
  788. ******************************************************************/
  789. #ifndef XMD_H
  790. #define XMD_H 1
  791. /* $XConsortium: Xmd.h,v 1.35 89/08/15 14:38:57 jim Exp $ */
  792. /*
  793. X *  Xmd.h: MACHINE DEPENDENT DECLARATIONS.
  794. X */
  795. X
  796. /*
  797. X * Special per-machine configuration flags.
  798. X */
  799. #ifdef CRAY
  800. #define WORD64                /* 64-bit architecture */
  801. #define UNSIGNEDBITFIELDS        /* bit fields do not honor sign */
  802. #endif
  803. X
  804. X
  805. /*
  806. X * Stuff to handle large architecture machines; the constants were generated
  807. X * on a 32-bit machine and must coorespond to the protocol.
  808. X */
  809. #ifdef WORD64
  810. #define MUSTCOPY
  811. #endif /* WORD64 */
  812. X
  813. X
  814. /*
  815. X * Definition of macro used to set constants for size of network structures;
  816. X * machines with preprocessors that can't handle all of the sz_ symbols
  817. X * can define this macro to be sizeof(x) if and only if their compiler doesn't
  818. X * pad out structures (esp. the xTextElt structure which contains only two 
  819. X * one-byte fields).  Network structures should always define sz_symbols.
  820. X *
  821. X * The sz_ prefix is used instead of something more descriptive so that the
  822. X * symbols are no more than 32 characters long (which causes problems for some
  823. X * compilers and preprocessors).
  824. X */
  825. #if defined(__STDC__) && !defined(UNIXCPP)
  826. #define SIZEOF(x) sz_##x
  827. #else
  828. #define SIZEOF(x) sz_/**/x
  829. #endif /* if ANSI C compiler else not */
  830. X
  831. X
  832. X
  833. /*
  834. X * ibm pcc doesn't understand pragmas.
  835. X */
  836. #if defined(ibm032) && defined(__HIGHC__)
  837. pragma on(pointers_compatible);
  838. pragma off(char_default_unsigned);
  839. #endif
  840. X
  841. X
  842. /*
  843. X * Bitfield suffixes for the protocol structure elements, if you
  844. X * need them.  Note that bitfields are not guarranteed to be signed
  845. X * (or even unsigned) according to ANSI C.
  846. X */
  847. #ifdef WORD64
  848. #define B32 :32
  849. #define B16 :16
  850. #else
  851. #define B32
  852. #define B16
  853. #endif
  854. X
  855. typedef long           INT32;
  856. typedef short          INT16;
  857. typedef char           INT8;
  858. X
  859. typedef unsigned long CARD32;
  860. typedef unsigned short CARD16;
  861. typedef unsigned char  CARD8;
  862. X
  863. typedef unsigned long        BITS32;
  864. typedef unsigned short        BITS16;
  865. typedef unsigned char        BYTE;
  866. X
  867. typedef unsigned char            BOOL;
  868. X
  869. X
  870. /*
  871. X * definitions for sign-extending bitfields on 64-bit architectures
  872. X */
  873. #if defined(WORD64) && defined(UNSIGNEDBITFIELDS)
  874. #define cvtINT8toInt(val)   (((val) & 0x00000080) ? ((val) | 0xffffffffffffff00) : (val))
  875. #define cvtINT16toInt(val)  (((val) & 0x00008000) ? ((val) | 0xffffffffffff0000) : (val))
  876. #define cvtINT32toInt(val)  (((val) & 0x80000000) ? ((val) | 0xffffffff00000000) : (val))
  877. #define cvtINT8toLong(val)  cvtINT8toInt(val)
  878. #define cvtINT16toLong(val) cvtINT16toInt(val)
  879. #define cvtINT32toLong(val) cvtINT32toInt(val)
  880. #else
  881. #define cvtINT8toInt(val) (val)
  882. #define cvtINT16toInt(val) (val)
  883. #define cvtINT32toInt(val) (val)
  884. #define cvtINT8toLong(val) (val)
  885. #define cvtINT16toLong(val) (val)
  886. #define cvtINT32toLong(val) (val)
  887. #endif /* WORD64 and UNSIGNEDBITFIELDS */
  888. X
  889. X
  890. X
  891. #ifdef MUSTCOPY
  892. /*
  893. X * This macro must not cast or else pointers will get aligned and be wrong
  894. X */
  895. #define NEXTPTR(p,t)  (((char *) p) + SIZEOF(t))
  896. #else /* else not MUSTCOPY, this is used for 32-bit machines */
  897. /*
  898. X * this version should leave result of type (t *), but that should only be 
  899. X * used when not in MUSTCOPY
  900. X */  
  901. #define NEXTPTR(p,t) (((t *)(p)) + 1)
  902. #endif /* MUSTCOPY - used machines whose C structs don't line up with proto */
  903. X
  904. #endif /* XMD_H */
  905. X
  906. /*
  907. X * Name - Xmd.h
  908. X *
  909. X * ccs version:    1.1
  910. X *
  911. X * ccsid:    @(#)Xmd.h    1.1 - 7/2/92 16:01:53
  912. X * from:     ccs/s.Xmd.h
  913. X * date:     7/9/92 13:35:26
  914. X *
  915. X * This is Xmd.h from XWindows v11r4
  916. X */
  917. SHAR_EOF
  918. chmod 0644 Xmd.h ||
  919. echo 'restore of Xmd.h failed'
  920. Wc_c="`wc -c < 'Xmd.h'`"
  921. test 4635 -eq "$Wc_c" ||
  922.     echo 'Xmd.h: original size 4635, current size' "$Wc_c"
  923. rm -f _shar_wnt_.tmp
  924. fi
  925. # ============= cmdopts.h ==============
  926. if test -f 'cmdopts.h' -a X"$1" != X"-c"; then
  927.     echo 'x - skipping cmdopts.h (File already exists)'
  928.     rm -f _shar_wnt_.tmp
  929. else
  930. > _shar_wnt_.tmp
  931. echo 'x - extracting cmdopts.h (Text)'
  932. sed 's/^X//' << 'SHAR_EOF' > 'cmdopts.h' &&
  933. /*========================================================================
  934. X *
  935. X * Name - cmdopts.h
  936. X *
  937. X * ccs version:    1.1
  938. X *
  939. X * ccsid:    @(#)cmdopts.h    1.1 - 7/9/92 13:18:35
  940. X * from:     ccs/s.cmdopts.h
  941. X * date:     7/9/92 13:35:26
  942. X *
  943. X * Copyright (c) 1990-92 Bruce Schuchardt.
  944. X * Read the file cpyright.h for full copyright information.
  945. X *
  946. X *
  947. X * Description:
  948. X *
  949. X * command line options for xgrabsc
  950. X *
  951. X *========================================================================
  952. X */
  953. X
  954. typedef enum {
  955. X  CMD_BELL,
  956. X  CMD_GRABSERVER,
  957. X  CMD_DISPLAY,
  958. X  CMD_OUTPUT,
  959. X  CMD_PRESLEEP,
  960. X  CMD_POSTSLEEP,
  961. X  CMD_VERBOSE,
  962. X  CMD_BORDERS,
  963. X  CMD_NOBORDERS,
  964. X
  965. X  CMD_SOURCE_KEY,
  966. X  CMD_SOURCE_ID,
  967. X  CMD_SOURCE_RECT,
  968. X  CMD_SOURCE_ROOT,
  969. X  CMD_SOURCE_WD,
  970. X
  971. X  CMD_AND,
  972. X  CMD_OR,
  973. X  CMD_NOT,
  974. X  CMD_BRIGHTEN,
  975. X
  976. X  CMD_DITHER_MAP,
  977. X  CMD_DITHER_MATRIX,
  978. X  CMD_DITHER_FS,
  979. X  CMD_DITHER_HALFTONE,
  980. X  CMD_DITHER_NONE,
  981. X
  982. X  CMD_OUTPUT_PS,
  983. X  CMD_OUTPUT_CPS,
  984. X  CMD_OUTPUT_SIMPLE,
  985. X  CMD_OUTPUT_XWD,
  986. X  CMD_OUTPUT_XPM,
  987. X  CMD_OUTPUT_XPM2,
  988. X  CMD_OUTPUT_XPM3,
  989. X  CMD_OUTPUT_PIXMAP,
  990. X  CMD_OUTPUT_PUZZLE,
  991. X
  992. X  CMD_BIN,
  993. X  CMD_COMPRESS,
  994. X  CMD_EPS,
  995. X  CMD_LANDSCAPE,
  996. X  CMD_LIMIT,
  997. X  CMD_PAGE,
  998. X  CMD_PREVIEW,
  999. X  CMD_COLORPROC
  1000. X
  1001. X  } commandEnum;
  1002. X
  1003. X
  1004. typedef struct {
  1005. X  commandEnum    command;
  1006. X  int        numargs;
  1007. X  char        *userstr;
  1008. X  } commandType;
  1009. X
  1010. commandType commands[] = {
  1011. X {  CMD_BELL,        0, "bell"    },
  1012. X {  CMD_GRABSERVER,    0, "grab"    },
  1013. X {  CMD_DISPLAY,    1, "d"        },
  1014. X {  CMD_DISPLAY,    1, "display"    },
  1015. X {  CMD_OUTPUT,        1, "o"        },
  1016. X {  CMD_OUTPUT,        1, "out"    },
  1017. X {  CMD_PRESLEEP,    1, "s"        },
  1018. X {  CMD_PRESLEEP,    1, "sleep"    },
  1019. X {  CMD_POSTSLEEP,    1, "post"    },
  1020. X {  CMD_VERBOSE,    0, "verbose"    },
  1021. X {  CMD_BORDERS,    0, "borders"    },
  1022. X {  CMD_BORDERS,    0, "bdrs"    },
  1023. X {  CMD_NOBORDERS,    0, "nobdrs"    },
  1024. X {  CMD_NOBORDERS,    0, "noborders"    },
  1025. X
  1026. X {  CMD_SOURCE_KEY,    0, "key"    },
  1027. X {  CMD_SOURCE_ID,    1, "id"        },
  1028. X {  CMD_SOURCE_RECT,    0, "stretch"    },
  1029. X {  CMD_SOURCE_ROOT,    0, "root"    },
  1030. X {  CMD_SOURCE_WD,    0, "click"    },
  1031. X
  1032. X {  CMD_AND,        1, "and"    },
  1033. X {  CMD_OR,        1, "or"        },
  1034. X {  CMD_NOT,        0, "reverse"    },
  1035. X {  CMD_BRIGHTEN,    1, "b"        },
  1036. X {  CMD_BRIGHTEN,    1, "brighten"    },
  1037. X
  1038. X {  CMD_DITHER_MAP,    0, "bw"        },
  1039. X {  CMD_DITHER_MATRIX,    0, "mdither"    },
  1040. X {  CMD_DITHER_FS,    0, "dither"    },
  1041. X {  CMD_DITHER_HALFTONE,0, "halftone"    },
  1042. X {  CMD_DITHER_NONE,    0, "nodither"   },
  1043. X
  1044. X {  CMD_OUTPUT_PS,    0, "ps"        },
  1045. X {  CMD_OUTPUT_CPS,    0, "cps"    },
  1046. X {  CMD_OUTPUT_SIMPLE,    0, "simple"    },
  1047. X {  CMD_OUTPUT_XWD,    0, "xwd"    },
  1048. X {  CMD_OUTPUT_PIXMAP,    0, "bm"        },
  1049. X {  CMD_OUTPUT_XPM2,    0, "bm2"    },
  1050. X {  CMD_OUTPUT_XPM3,    0, "bm3"    },
  1051. X {  CMD_OUTPUT_PUZZLE,    0, "puzzle"    },
  1052. X
  1053. X {  CMD_BIN,        0, "bin"    },
  1054. X {  CMD_COMPRESS,     0, "comp"    },
  1055. X {  CMD_COMPRESS,     0, "compress"    },
  1056. X {  CMD_EPS,        0, "eps"    },
  1057. X {  CMD_LANDSCAPE,    0, "l"        },
  1058. X {  CMD_LANDSCAPE,    0, "landscape"    },
  1059. X {  CMD_LIMIT,        0, "limit"    },
  1060. X {  CMD_PAGE,        1, "page"    },
  1061. X {  CMD_PREVIEW,    0, "preview"    },
  1062. X {  CMD_PREVIEW,    0, "prev"    },
  1063. X {  CMD_COLORPROC,    0, "colproc"    }
  1064. };
  1065. X
  1066. int numCmds = sizeof(commands) / sizeof(commandType);
  1067. SHAR_EOF
  1068. chmod 0644 cmdopts.h ||
  1069. echo 'restore of cmdopts.h failed'
  1070. Wc_c="`wc -c < 'cmdopts.h'`"
  1071. test 2917 -eq "$Wc_c" ||
  1072.     echo 'cmdopts.h: original size 2917, current size' "$Wc_c"
  1073. rm -f _shar_wnt_.tmp
  1074. fi
  1075. # ============= config.h ==============
  1076. if test -f 'config.h' -a X"$1" != X"-c"; then
  1077.     echo 'x - skipping config.h (File already exists)'
  1078.     rm -f _shar_wnt_.tmp
  1079. else
  1080. > _shar_wnt_.tmp
  1081. echo 'x - extracting config.h (Text)'
  1082. sed 's/^X//' << 'SHAR_EOF' > 'config.h' &&
  1083. /*========================================================================
  1084. X *
  1085. X * Name - config.h
  1086. X *
  1087. X * Version:    1.5
  1088. X *
  1089. X * ccsid:    @(#)config.h    1.5 - 7/9/92 12:48:31
  1090. X * from:     ccs/s.config.h
  1091. X * date:     7/9/92 13:35:27
  1092. X *
  1093. X * Copyright (c) 1991-92 Bruce Schuchardt.
  1094. X * Read the file cpyright.h for full copyright information.
  1095. X *
  1096. X *
  1097. X * Description:
  1098. X *   configuration options for xgrabsc
  1099. X *
  1100. X *========================================================================
  1101. X */
  1102. X
  1103. /* if you do not have memcpy routines but do have bcopy, define the following */
  1104. /* #define BCOPY */
  1105. X
  1106. /* if you have neither memcpy nor bcopy, or for some other reason would like
  1107. X * to use xgrabsc's version of memcpy, define the following */
  1108. /* #define MEMCPY */
  1109. X
  1110. /* if you want to use some other key than Control for selection, define
  1111. X * the following and replace ControlMask with the mask of your choice */
  1112. /* #define SELECTION_MASK ControlMask */
  1113. X
  1114. /* when forming postscript output and the "-c" option has not been specified,
  1115. X * xgrabsc will make a pass over the image to determine whether run-length
  1116. X * encoding will shrink the output appreciably.  If you are building xgrabsc
  1117. X * for a slower machine, you may wish to avoid this overhead.  If so,
  1118. X * define the following */
  1119. /* #define NO_RLE_CHECKS */
  1120. X
  1121. /* When forming color postscript output, xgrabsc will include a color to
  1122. X * greyscale converter in the output so that it can also be printed on
  1123. X * non-color printers.  If you prefer to have this converter omitted from
  1124. X * color postscript output by default, change the following to FALSE */
  1125. #define DEFAULT_NEED_COLORIMAGE_PROC  TRUE
  1126. X
  1127. X
  1128. /* Xgrabsc will dither Encapsulated Postscript preview images to be black
  1129. X * and white.  You can choose the default type of dithering.  Choices are
  1130. X * FS_DITHER (Floyd-Steinberg), MATRIX_HALFTONE (increases size of image),
  1131. X * MATRIX_DITHER (good for line-drawings), or MAP_BW (maps colors to black/
  1132. X * white based on grayscale brightness). */
  1133. #define PREVIEW_DITHER FS_DITHER
  1134. X
  1135. /* Xgrabsc will look for a virtual-window manager's root window for
  1136. X * window dumps.  If the virtual-window manager support code gives you
  1137. X * trouble, define the following to omit it */
  1138. /* #define NO_VIRTUAL_WINDOW */
  1139. X
  1140. /* Xgrabsc will write code to check printer memory availability before
  1141. X * attempting to display an image.  Postscript previewers may cause problems
  1142. X * with this since they usually allocate memory as needed, and so will
  1143. X * often fail memory-availability checks.
  1144. X * Editors, such as FrameMaker can also cause problems like this, so
  1145. X * the checks are turned off when Encapsulated Postscript format is
  1146. X * requested.
  1147. X * A command line switch can also turn checks off, but they can be disabled
  1148. X * totally here. */
  1149. /* #define NO_PRINTER_MEMORY_CHECKS */
  1150. X
  1151. X
  1152. /* xgrabsc has a hard-coded notion of the size of your printer's paper.
  1153. X * The default is for US Letter size (8.5x11.0 inch).
  1154. X * The inset sizes control the maximum size of the image on the page.
  1155. X * These are preset to leave at least a 0.5 inch border around the image.
  1156. X */
  1157. #define PAPER_WIDTH         8.5   /* inches are assumed */
  1158. #define PAPER_HEIGHT       11.0
  1159. X
  1160. #define VERT_MARGIN        0.5
  1161. #define HORIZ_MARGIN        0.5
  1162. X
  1163. X
  1164. SHAR_EOF
  1165. chmod 0644 config.h ||
  1166. echo 'restore of config.h failed'
  1167. Wc_c="`wc -c < 'config.h'`"
  1168. test 3177 -eq "$Wc_c" ||
  1169.     echo 'config.h: original size 3177, current size' "$Wc_c"
  1170. rm -f _shar_wnt_.tmp
  1171. fi
  1172. # ============= get.hc ==============
  1173. if test -f 'get.hc' -a X"$1" != X"-c"; then
  1174.     echo 'x - skipping get.hc (File already exists)'
  1175.     rm -f _shar_wnt_.tmp
  1176. else
  1177. > _shar_wnt_.tmp
  1178. echo 'x - extracting get.hc (Text)'
  1179. sed 's/^X//' << 'SHAR_EOF' > 'get.hc' &&
  1180. /*========================================================================
  1181. X *
  1182. X * Name - get.hc
  1183. X *
  1184. X * ccs version:    1.3
  1185. X *
  1186. X * ccsid:    @(#)get.hc    1.3 - 7/9/92 12:48:40
  1187. X * from:     ccs/s.get.hc
  1188. X * date:     7/9/92 13:35:27
  1189. X *
  1190. X * Description:  image grabbing functions for xgrabsc
  1191. X *
  1192. X *               see cpyright.h for copyright information
  1193. X *
  1194. X *
  1195. X *========================================================================
  1196. X */
  1197. X
  1198. /*
  1199. X * Get the image bounded by the given rectangle.
  1200. X * The associated colormap information is also extracted and returned.
  1201. X * TRUE is returned if an image was successfully grabbed, and FALSE
  1202. X * otherwise.
  1203. X */
  1204. getImage(xrect, image, window)
  1205. X  XRectangle *xrect;
  1206. X  imageInfo *image;
  1207. X  Window window;
  1208. {
  1209. X  XImage *ximage;
  1210. X  int depth, ncolors, cmapSize, numCmaps;
  1211. X  int h, w;
  1212. X  long i;
  1213. X  XColor colors[MAX_CELLS];
  1214. X  Colormap *cmaps, cmap;
  1215. X
  1216. X  if (xrect->width == 0  || xrect->height == 0)
  1217. X    return FALSE;
  1218. X
  1219. X  /* get the image */
  1220. X  depth  = DefaultDepth(hDisplay, hScreen);
  1221. X  ximage = XGetImage(hDisplay, window,
  1222. X            xrect->x, xrect->y, xrect->width, xrect->height, AllPlanes,
  1223. X            depth==1 ? XYPixmap : ZPixmap);
  1224. X  image->ximage = ximage;
  1225. X
  1226. X  /* get the colormap info */
  1227. X  cmaps = XListInstalledColormaps(hDisplay, window, &numCmaps);
  1228. X  if (numCmaps == 0)
  1229. X    cmap = DefaultColormap(hDisplay, hScreen);
  1230. X  else {
  1231. X    cmap = *cmaps;
  1232. X    if (numCmaps > 1)
  1233. X      fprintf(stderr,
  1234. X        "%s: more than one colormap found - using first encountered",
  1235. X        programName);
  1236. X  }
  1237. X  XFree(cmaps);
  1238. X
  1239. X  ncolors = DisplayCells(hDisplay, hScreen);
  1240. X  /* this won't cut the mustard for DirectColor */
  1241. X  for (i=0; i<ncolors; i++)
  1242. X    colors[i].pixel = i;
  1243. X
  1244. X  XQueryColors(hDisplay, cmap, colors, ncolors);
  1245. X  for (i=0; i<ncolors; i++) {
  1246. X    image->red[i]   = colors[i].red;
  1247. X    image->green[i] = colors[i].green;
  1248. X    image->blue[i]  = colors[i].blue;
  1249. X  }
  1250. X
  1251. X  /* figure out which colormap entries are actually used by the image */
  1252. X  ncolors = cmapSize = 0;
  1253. X  memset((char *)image->used, 0, MAX_CELLS);
  1254. X  for (h=0; h<ximage->height; h++)
  1255. X    for (w=0; w<ximage->width; w++) {
  1256. X      i = XGetPixel(ximage, w, h);
  1257. X      if (!image->used[i]) {
  1258. X        image->used[i] = TRUE;
  1259. X        if (i+1 > cmapSize)      /* keep track of colormap size */
  1260. X          cmapSize = i+1;
  1261. X        ncolors++;
  1262. X      }
  1263. X    }
  1264. X  image->numcells = cmapSize;
  1265. X  if (verbose)
  1266. X    fprintf(stderr, "%s: image has %d colors\n", programName, ncolors);
  1267. X
  1268. X  return TRUE;
  1269. }
  1270. X
  1271. X
  1272. X
  1273. /*
  1274. X * Let the user stretch a rectangle on the screen and return its values.
  1275. X * It may be wise to grab the server before calling this routine.  If the
  1276. X * screen is allowed to change during XOR drawing video droppings may result.
  1277. X */
  1278. getRectangle(xrect)
  1279. X  XRectangle *xrect;
  1280. {
  1281. X  XEvent event;
  1282. X  unsigned int x, y, rootx, rooty;
  1283. X  GC gc;
  1284. X  Cursor pointer1, pointer2;
  1285. X  int boxDrawn = False;
  1286. X  int rx, ry, rw, rh;
  1287. X
  1288. X  /* get some cursors for rectangle formation */
  1289. X  pointer1 = XCreateFontCursor(hDisplay, XC_ul_angle);
  1290. X  pointer2 = XCreateFontCursor(hDisplay, XC_lr_angle);
  1291. X
  1292. X  /* grab the pointer */
  1293. X  if (GrabSuccess != XGrabPointer(hDisplay, hRoot, False, ButtonPressMask,
  1294. X        GrabModeAsync, GrabModeAsync, hRoot, pointer1, CurrentTime)) {
  1295. X    fprintf(stderr,"%s - could not grab pointer!\n", programName);
  1296. X    exit(3);
  1297. X  }
  1298. X
  1299. X  /* create a graphics context to draw with */
  1300. X  gc = XCreateGC(hDisplay, hRoot, 0, NULL);
  1301. X  if (!gc) {
  1302. X    fprintf(stderr,"%s - could not get drawing resources\n", programName);
  1303. X    exit(3);
  1304. X  }
  1305. X  XSetSubwindowMode(hDisplay, gc, IncludeInferiors);
  1306. X  XSetForeground(hDisplay, gc, 255);
  1307. X  XSetFunction(hDisplay, gc, GXxor);
  1308. X
  1309. X  /* get a button-press and pull out the root location */
  1310. X  XMaskEvent(hDisplay, ButtonPressMask, &event);
  1311. X  rootx = rx = event.xbutton.x_root;
  1312. X  rooty = ry = event.xbutton.y_root;
  1313. X
  1314. X  /* get pointer motion events */
  1315. X  XChangeActivePointerGrab(hDisplay, ButtonMotionMask | ButtonReleaseMask,
  1316. X        pointer2, CurrentTime);
  1317. X
  1318. X
  1319. X  /* MAKE_RECT converts the original root coordinates and the event root
  1320. X   * coordinates into a rectangle in xrect */
  1321. #define MAKE_RECT(etype) \
  1322. X  x = event.etype.x_root;       \
  1323. X  y = event.etype.y_root;       \
  1324. X  rw  = x - rootx;              \
  1325. X  if (rw  < 0) rw  = -rw;       \
  1326. X  rh  = y - rooty;              \
  1327. X  if (rh  < 0) rh  = -rh;       \
  1328. X  rx = x < rootx ? x : rootx;   \
  1329. X  ry = y < rooty ? y : rooty
  1330. X
  1331. X  /* loop to let the user drag a rectangle */
  1332. X  while (TRUE) {
  1333. X    XNextEvent(hDisplay, &event);
  1334. X    switch(event.type) {
  1335. X      case ButtonRelease:
  1336. X        if (boxDrawn) {
  1337. X          XDrawRectangle(hDisplay, hRoot, gc, rx, ry, rw, rh);
  1338. X          boxDrawn = False;
  1339. X        }
  1340. X        XFlush(hDisplay);
  1341. X        /* record the final location */
  1342. X        MAKE_RECT(xbutton);
  1343. X        /* release resources */
  1344. X        XFreeGC(hDisplay, gc);
  1345. X        XFreeCursor(hDisplay, pointer1);
  1346. X        XFreeCursor(hDisplay, pointer2);
  1347. X        xrect->x      = rx;
  1348. X        xrect->y      = ry;
  1349. X        xrect->width  = rw;
  1350. X        xrect->height = rh;
  1351. X        XUngrabPointer(hDisplay, CurrentTime);
  1352. X    XSync(hDisplay, FALSE);
  1353. X        return True;
  1354. X      case MotionNotify:
  1355. X        if (boxDrawn) {
  1356. X          XDrawRectangle(hDisplay, hRoot, gc, rx, ry, rw, rh);
  1357. X          boxDrawn = False;
  1358. X        }
  1359. X        while (XCheckTypedEvent(hDisplay, MotionNotify, &event))
  1360. X          {}
  1361. X        MAKE_RECT(xmotion);
  1362. X        XDrawRectangle(hDisplay, hRoot, gc, rx, ry, rw, rh);
  1363. X        boxDrawn = True;
  1364. X        break;
  1365. X    }
  1366. X  }
  1367. }
  1368. X
  1369. X
  1370. X
  1371. X
  1372. X
  1373. X
  1374. /*
  1375. X * find the window under the mouse pointer when one of the bits in keyMask
  1376. X * is satisfied.
  1377. X */
  1378. Window getWindowWhenKeyIsPressed(keyMask)
  1379. X  unsigned int keyMask;
  1380. {
  1381. X  Bool status;
  1382. X  Window result;
  1383. X  Window root, child;
  1384. X  int root_x, root_y, win_x, win_y;
  1385. X  unsigned int keys_buttons;
  1386. X
  1387. X  if (verbose)
  1388. X    fprintf(stderr, "%s: waiting for keypress\n", programName);
  1389. X
  1390. X  do {
  1391. X    status = XQueryPointer(hDisplay, vRoot, &root, &child,
  1392. X              &root_x, &root_y, &win_x, &win_y, &keys_buttons);
  1393. X    if (!status)
  1394. X      return (Window)0;
  1395. X  } while ((keyMask != 0) && ((keyMask & keys_buttons) == 0));
  1396. X
  1397. X  if (child == (Window)0) {
  1398. X    if (verbose) {
  1399. X      fprintf(stderr, "%s: unable to find a non-root window under pointer.\n",
  1400. X              programName);
  1401. X      fprintf(stderr, "%s: using root window.\n", programName);
  1402. X    }
  1403. X    result = (Window)vRoot;
  1404. X  }
  1405. X  else
  1406. X    result = child;
  1407. X
  1408. X  if (verbose)
  1409. X    fprintf(stderr, "%s: returning window id %d\n", programName, result);
  1410. X
  1411. X  return result;
  1412. }
  1413. X
  1414. X
  1415. X
  1416. X
  1417. /*
  1418. X * choose a window as in xwd
  1419. X */
  1420. X
  1421. Window getWindow() {
  1422. X  int status;
  1423. X  Cursor cursor;
  1424. X  XEvent event;
  1425. X  Window result;
  1426. X
  1427. X  result = None;
  1428. X
  1429. X  cursor = XCreateFontCursor(hDisplay, XC_target);
  1430. X
  1431. X  status = XGrabPointer(hDisplay, vRoot, FALSE,
  1432. X         ButtonPressMask|ButtonReleaseMask, GrabModeSync,
  1433. X         GrabModeAsync, hRoot, cursor, CurrentTime);
  1434. X  if (status != GrabSuccess) {
  1435. X    fprintf(stderr, "%s: can't grab mouse\n", programName);
  1436. X    exit(3);
  1437. X  }
  1438. X
  1439. X  while (TRUE) {
  1440. X    XAllowEvents(hDisplay, SyncPointer, CurrentTime);
  1441. X    XWindowEvent(hDisplay, vRoot, ButtonPressMask|ButtonReleaseMask, &event);
  1442. X
  1443. X    switch (event.type) {
  1444. X      case ButtonRelease:
  1445. X        result = event.xbutton.subwindow;
  1446. X        if (result == None)
  1447. X          result = hRoot;
  1448. X        XUngrabPointer(hDisplay, CurrentTime);      /* Done with pointer */
  1449. X        if (verbose)
  1450. X          fprintf(stderr, "%s: found window with id 0x%x\n", programName, result);
  1451. X        return result;
  1452. X        break;
  1453. X    }
  1454. X  }
  1455. X
  1456. }
  1457. X
  1458. X
  1459. X
  1460. X
  1461. SHAR_EOF
  1462. chmod 0644 get.hc ||
  1463. echo 'restore of get.hc failed'
  1464. Wc_c="`wc -c < 'get.hc'`"
  1465. test 7414 -eq "$Wc_c" ||
  1466.     echo 'get.hc: original size 7414, current size' "$Wc_c"
  1467. rm -f _shar_wnt_.tmp
  1468. fi
  1469. # ============= process.hc ==============
  1470. if test -f 'process.hc' -a X"$1" != X"-c"; then
  1471.     echo 'x - skipping process.hc (File already exists)'
  1472.     rm -f _shar_wnt_.tmp
  1473. else
  1474. > _shar_wnt_.tmp
  1475. echo 'x - extracting process.hc (Text)'
  1476. sed 's/^X//' << 'SHAR_EOF' > 'process.hc' &&
  1477. /*========================================================================
  1478. X *
  1479. X * Name - process.hc
  1480. X *
  1481. X * ccs version:    1.2
  1482. X *
  1483. X * ccsid:    @(#)process.hc    1.2 - 7/6/92 10:52:51
  1484. X * from:     ccs/s.process.hc
  1485. X * date:     7/9/92 13:35:28
  1486. X *
  1487. X * Description:  color processing functions for xgrabsc
  1488. X *
  1489. X *               see cpyright.h for copyright information
  1490. X *
  1491. X *
  1492. X *========================================================================
  1493. X */
  1494. X
  1495. /*
  1496. X * Alter colors by setting or clearing bits in rgb values.
  1497. X * This effectively reduces the depth of the image, causing the
  1498. X * number of colors used to be reduced.  Equivalent colors are
  1499. X * merged in the image, and the used flags of remapped colors are
  1500. X * cleared.
  1501. X *
  1502. X * The number of eliminated colormap entries is returned.  The colormap
  1503. X * is not compressed.
  1504. X */
  1505. alterPlanes(image, modeIsAnd, bits)
  1506. X  imageInfo *image;
  1507. X  int modeIsAnd;      /* if TRUE, combine mask with AND; if FALSE, use OR */
  1508. X  unsigned int bits;
  1509. {
  1510. X  int nc, cidx, ridx, h, w;
  1511. X  long p;
  1512. X  XImage *ximage = image->ximage;
  1513. X  long map[MAX_CELLS];
  1514. X  int remapCount;
  1515. X  word mask;
  1516. X
  1517. X  if (ximage->depth <= 1)
  1518. X    return 0;
  1519. X
  1520. X  mask = 0xFFFF ^ ((1 << (bits+8)) - 1);
  1521. X  if (!modeIsAnd)
  1522. X    mask = ~mask & 0xFFFF;
  1523. X
  1524. X  if (verbose) {
  1525. X    fprintf(stderr, "%s: %s color with mask %x...", programName,
  1526. X            modeIsAnd? "ANDing" : "ORing", mask);
  1527. X    fflush(stderr);
  1528. X  }
  1529. X
  1530. X  nc = image->numcells;
  1531. X  if (modeIsAnd)
  1532. X    for (cidx=0; cidx<nc; cidx++) {
  1533. X      nr[cidx] = image->red[cidx]   & mask;
  1534. X      ng[cidx] = image->green[cidx] & mask;
  1535. X      nb[cidx] = image->blue[cidx]  & mask;
  1536. X    }
  1537. X  else
  1538. X    for (cidx=0; cidx<nc; cidx++) {
  1539. X      nr[cidx] = image->red[cidx]   | mask;
  1540. X      ng[cidx] = image->green[cidx] | mask;
  1541. X      nb[cidx] = image->blue[cidx]  | mask;
  1542. X    }
  1543. X
  1544. X  /* now eliminate redundant colors */
  1545. X  for (cidx=0; cidx<nc; cidx++)
  1546. X    map[cidx] = cidx;
  1547. X  remapCount = 0;
  1548. X  for (cidx=0; cidx<nc; cidx++)
  1549. X    if (image->used[cidx])
  1550. X      for (ridx=cidx+1; ridx<nc; ridx++)
  1551. X        if (image->used[ridx]  &&
  1552. X            nr[cidx]==nr[ridx] &&
  1553. X            ng[cidx]==ng[ridx] &&
  1554. X            nb[cidx]==nb[ridx]) {
  1555. X          /* the colors match - remap this pixel to the one we're scanning with */
  1556. X          map[ridx] = cidx;
  1557. X          image->used[ridx] = FALSE;
  1558. X          remapCount++;
  1559. X        }
  1560. X
  1561. X  memcpy((char *)image->red,   (char *)nr, nc*sizeof(word));
  1562. X  memcpy((char *)image->green, (char *)ng, nc*sizeof(word));
  1563. X  memcpy((char *)image->blue,  (char *)nb, nc*sizeof(word));
  1564. X
  1565. X  /* remap redundant pixels in the image */
  1566. X  if (remapCount)
  1567. X    for (h=0; h<ximage->height; h++)
  1568. X      for (w=0; w<ximage->width; w++) {
  1569. X        p = XGetPixel(ximage, w, h);
  1570. X        if (p != map[p])
  1571. X          XPutPixel(ximage, w, h, map[p]);
  1572. X      }
  1573. X
  1574. X  if (verbose)
  1575. X    fprintf(stderr, "  %d colors remapped\n", remapCount, nc);
  1576. X  return remapCount;
  1577. }
  1578. X
  1579. X
  1580. X
  1581. X
  1582. X
  1583. /* Brighten or darken colors in the image by the given amount ('percent').
  1584. X * The amount is an integer that, if less than 100 will darken the image
  1585. X * and if greater than 100 will brighten the image.  After modifying
  1586. X * colors equivalent colors are merged (as in alterPlanes).  The number
  1587. X * of eliminated colors is returned.
  1588. X */
  1589. brightenColors(image, percent)
  1590. X  imageInfo *image;
  1591. X  int percent;
  1592. {
  1593. X  int nc, cidx, ridx, h, w;
  1594. X  long p;
  1595. X  XImage *ximage = image->ximage;
  1596. X  float  adjustment;
  1597. X  long map[MAX_CELLS];
  1598. X  int remapCount;
  1599. X  dw new;
  1600. X
  1601. X  if (ximage->depth <= 1)
  1602. X    return 0;
  1603. X
  1604. X  if (verbose) {
  1605. X    fprintf(stderr, "%s: adjusting intensity by %d...", programName, percent);
  1606. X    fflush(stderr);
  1607. X  }
  1608. X
  1609. X  adjustment = (float)percent / 100.0;
  1610. X  nc = image->numcells;
  1611. X  for (cidx=0; cidx<nc; cidx++) {
  1612. X    new = image->red[cidx] * adjustment;
  1613. X    if (new > (dw)0xFFFF) new = (dw)0xFFFF;
  1614. X    nr[cidx] = new;
  1615. X    new = image->green[cidx] * adjustment;
  1616. X    if (new > (dw)0xFFFF) new = (dw)0xFFFF;
  1617. X    ng[cidx] = new;
  1618. X    new = image->blue[cidx] * adjustment;
  1619. X    if (new > (dw)0xFFFF) new = (dw)0xFFFF;
  1620. X    nb[cidx] = new;
  1621. X  }
  1622. X
  1623. X  /* now eliminate redundant colors */
  1624. X  for (cidx=0; cidx<nc; cidx++)
  1625. X    map[cidx] = cidx;
  1626. X  remapCount = 0;
  1627. X  for (cidx=0; cidx<nc; cidx++)
  1628. X    if (image->used[cidx])
  1629. X      for (ridx=cidx+1; ridx<nc; ridx++)
  1630. X        if (image->used[ridx]  &&
  1631. X            nr[cidx]==nr[ridx] &&
  1632. X            ng[cidx]==ng[ridx] &&
  1633. X            nb[cidx]==nb[ridx]) {
  1634. X          map[ridx] = cidx;
  1635. X          image->used[ridx] = FALSE;
  1636. X          remapCount++;
  1637. X        }
  1638. X
  1639. X  memcpy((char *)image->red,   (char *)nr, nc*sizeof(word));
  1640. X  memcpy((char *)image->green, (char *)ng, nc*sizeof(word));
  1641. X  memcpy((char *)image->blue,  (char *)nb, nc*sizeof(word));
  1642. X
  1643. X  /* remap redundant pixels in the image */
  1644. X  if (remapCount)
  1645. X    for (h=0; h<ximage->height; h++)
  1646. X      for (w=0; w<ximage->width; w++) {
  1647. X        p = XGetPixel(ximage, w, h);
  1648. X        if (p != map[p])
  1649. X          XPutPixel(ximage, w, h, map[p]);
  1650. X      }
  1651. X
  1652. X
  1653. X  if (verbose)
  1654. X    fprintf(stderr, "  %d colors remapped\n", remapCount, nc);
  1655. X
  1656. X  return remapCount;
  1657. }
  1658. X
  1659. X
  1660. X
  1661. X
  1662. X
  1663. /* Reverse the colors in the image */
  1664. reverseColors(image)
  1665. X  imageInfo *image;
  1666. {
  1667. X  int nc, cidx;
  1668. X  long size, idx;
  1669. X  unsigned char *data;
  1670. SHAR_EOF
  1671. true || echo 'restore of process.hc failed'
  1672. fi
  1673. echo 'End of  part 2'
  1674. echo 'File process.hc is continued in part 3'
  1675. echo 3 > _shar_seq_.tmp
  1676. exit 0
  1677. -- 
  1678. ---
  1679. Senior Systems Scientist        mail: dcmartin@msi.com
  1680. Molecular Simulations, Inc.        uucp: uunet!dcmartin
  1681. 796 North Pastoria Avenue        at&t: 408/522-9236
  1682.