home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume20 / xgrabsc / part03 < prev    next >
Encoding:
Text File  |  1993-08-04  |  55.5 KB  |  1,901 lines

  1. Newsgroups: comp.sources.x
  2. From: bruce@servio.slc.com (Bruce Schuchardt)
  3. Subject: v20i102:  xgrabsc - Grab and dump X displays, Part03/05
  4. Message-ID: <1993Aug4.171711.9496@sparky.sterling.com>
  5. X-Md4-Signature: 47729f2bcb97ec2ba55a8c45a4cf5d4d
  6. Sender: chris@sparky.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Wed, 4 Aug 1993 17:17:11 GMT
  9. Approved: chris@sterling.com
  10.  
  11. Submitted-by: bruce@servio.slc.com (Bruce Schuchardt)
  12. Posting-number: Volume 20, Issue 102
  13. Archive-name: xgrabsc/part03
  14. Environment: X11
  15. Supersedes: xgrabsc: Volume 18, Issue 52-56
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then unpack
  19. # it by saving it into a file and typing "sh file".  To overwrite existing
  20. # files, type "sh file -c".  You can also feed this as standard input via
  21. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  22. # will see the following message at the end:
  23. #        "End of archive 3 (of 5)."
  24. # Contents:  xgrabsc.2_3/XGrabxaw.res xgrabsc.2_3/process.hc
  25. #   xgrabsc.2_3/virtual.h xgrabsc.2_3/xgrabsc.man
  26. #   xgrabsc.2_3/xgrabxaw.c
  27. # Wrapped by bruce@trout on Mon Jun 28 09:14:50 1993
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'xgrabsc.2_3/XGrabxaw.res' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'xgrabsc.2_3/XGrabxaw.res'\"
  31. else
  32. echo shar: Extracting \"'xgrabsc.2_3/XGrabxaw.res'\" \(9956 characters\)
  33. sed "s/^X//" >'xgrabsc.2_3/XGrabxaw.res' <<'END_OF_FILE'
  34. X#include "config.h"
  35. X
  36. XXGrab*.title.label: X-Windows Screen Grabber
  37. XXGrab*.title.font:   *-times-medium-r-normal--18-*
  38. XXGrab*.title.horizDistance: 105
  39. X
  40. X!----------------------------box 1
  41. X
  42. XXGrab*.box1.horizDistance: 0
  43. XXGrab*.box1.vertDistance:  35
  44. X
  45. XXGrab*.inputLbl.horizDistance:     5
  46. XXGrab*.inputLbl.vertDistance:      0
  47. XXGrab*.inputLbl.font: *-helvetica-medium-o-normal--14-*
  48. XXGrab*.inputLbl.label: Input Options-------------------------------------
  49. X
  50. XXGrab*.click.horizDistance:   10
  51. XXGrab*.click.vertDistance:    25
  52. XXGrab*.click.label: Click on Window
  53. X
  54. XXGrab*.stretch.horizDistance:   135
  55. XXGrab*.stretch.vertDistance:     25
  56. XXGrab*.stretch.label: Stretch Rectangle
  57. XXGrab*.stretch.state: 1
  58. X
  59. XXGrab*.key.horizDistance:   265
  60. XXGrab*.key.vertDistance:     25
  61. XXGrab*.key.label: Wait for Control key
  62. X
  63. XXGrab*.root.horizDistance: 10
  64. XXGrab*.root.vertDistance:  55
  65. XXGrab*.root.label: Grab Whole Screen
  66. X
  67. XXGrab*.sleeplbl.horizDistance: 10
  68. XXGrab*.sleeplbl.vertDistance:  85
  69. XXGrab*.sleeplbl.label: Sleep before starting
  70. X
  71. XXGrab*.sleeptime.fromHoriz:      sleeplbl
  72. XXGrab*.sleeptime.horizDistance:     5
  73. XXGrab*.sleeptime.vertDistance:     85
  74. XXGrab*.sleeptime.width:            30
  75. XXGrab*.sleeptime*string: DEFAULT_PRESLEEP
  76. X
  77. XXGrab*.psleeplbl.fromHoriz:    sleeptime
  78. XXGrab*.psleeplbl.horizDistance:   10
  79. XXGrab*.psleeplbl.vertDistance:    85
  80. XXGrab*.psleeplbl.label: Sleep after selecting
  81. X
  82. XXGrab*.psleeptime.fromHoriz:    psleeplbl
  83. XXGrab*.psleeptime.horizDistance:     5
  84. XXGrab*.psleeptime.vertDistance:     85
  85. XXGrab*.psleeptime.width:            30
  86. XXGrab*.psleeptime*string: DEFAULT_POSTSLEEP
  87. X
  88. XXGrab*.host.horizDistance:   10
  89. XXGrab*.host.vertDistance:   115
  90. XXGrab*.host.label: Use Alternate Display:
  91. XXGrab*.host.shapeStyle: oval
  92. XXGrab*.host.width:        140
  93. XXGrab*.host.state: 0
  94. X
  95. XXGrab*.hostText.fromHoriz:    host
  96. XXGrab*.hostText.horizDistance:     5
  97. XXGrab*.hostText.vertDistance:    115
  98. X! xgrab sets DISPLAY value into this widget
  99. X! XGrab*.hostText*string: :0
  100. X
  101. X
  102. X!----------------------------box 2
  103. XXGrab*.box2.horizDistance:   0
  104. XXGrab*.box2.vertDistance:  180
  105. X
  106. XXGrab*.outputFormat.horizDistance:   5
  107. XXGrab*.outputFormat.vertDistance:    0
  108. XXGrab*.outputFormat.font: *-helvetica-medium-o-normal--12-*
  109. XXGrab*.outputFormat.label: Output Format------------------------------------------
  110. X
  111. XXGrab*.ps.horizDistance:    10
  112. XXGrab*.ps.vertDistance:     25
  113. XXGrab*.ps.label: PostScript
  114. XXGrab*.ps.state: 1
  115. X
  116. XXGrab*.puzzle.horizDistance:    87
  117. XXGrab*.puzzle.vertDistance:     25
  118. XXGrab*.puzzle.label: Puzzle
  119. X
  120. XXGrab*.xwd.horizDistance:   142
  121. XXGrab*.xwd.vertDistance:    25
  122. XXGrab*.xwd.label: X Window Dump
  123. X
  124. XXGrab*.xyxwd.horizDistance:    252
  125. XXGrab*.xyxwd.vertDistance:     25
  126. XXGrab*.xyxwd.label: XWD/xy
  127. X
  128. XXGrab*.xpm.horizDistance:    10
  129. XXGrab*.xpm.vertDistance:     55
  130. XXGrab*.xpm.label: Bitmap/XPM
  131. X
  132. XXGrab*.xpm2.horizDistance:    95
  133. XXGrab*.xpm2.vertDistance:     55
  134. XXGrab*.xpm2.label: Bm/XPM2
  135. X
  136. XXGrab*.xpm3.horizDistance:   165
  137. XXGrab*.xpm3.vertDistance:     55
  138. XXGrab*.xpm3.label: Bm/XPM3
  139. X
  140. X!----------------------------box 3
  141. XXGrab*.box3.horizDistance:   0
  142. XXGrab*.box3.vertDistance:  270
  143. X
  144. XXGrab*.psOptions.horizDistance:   5
  145. XXGrab*.psOptions.vertDistance:    0
  146. XXGrab*.psOptions.font: *-helvetica-medium-o-normal--12-*
  147. XXGrab*.psOptions.label: PostScript Options---------------------------------------
  148. X
  149. XXGrab*.compress.horizDistance:   10
  150. XXGrab*.compress.vertDistance:    25 
  151. XXGrab*.compress.shapeStyle: oval
  152. XXGrab*.compress.label: Compress
  153. XXGrab*.compress.state: 1
  154. X
  155. XXGrab*.color.fromHoriz: compress
  156. XXGrab*.color.horizDistance:    10
  157. XXGrab*.color.vertDistance:     25
  158. XXGrab*.color.shapeStyle: oval
  159. XXGrab*.color.label: Color Output
  160. X
  161. XXGrab*.binary.fromHoriz: color
  162. XXGrab*.binary.horizDistance: 10
  163. XXGrab*.binary.vertDistance: 25
  164. XXGrab*.binary.shapeStyle: oval
  165. XXGrab*.binary.label: Binary
  166. X
  167. XXGrab*.limit.fromHoriz: binary
  168. XXGrab*.limit.horizDistance: 10
  169. XXGrab*.limit.vertDistance: 25
  170. XXGrab*.limit.shapeStyle: oval
  171. X#if defined(NO_PRINTER_MEMORY_CHECKS)
  172. XXGrab*.limit.state: 0
  173. X#else
  174. XXGrab*.limit.state: 1
  175. X#endif
  176. XXGrab*.limit.label: Limit Check
  177. X
  178. XXGrab*.landscape.horizDistance: 10
  179. XXGrab*.landscape.vertDistance: 55
  180. XXGrab*.landscape.width: 80
  181. XXGrab*.landscape.label: Landscape
  182. X
  183. XXGrab*.epsi.fromHoriz: landscape
  184. XXGrab*.epsi.horizDistance:    10
  185. XXGrab*.epsi.vertDistance:     55
  186. XXGrab*.epsi.label: PS Figure
  187. X
  188. XXGrab*.onlyEpsi.fromHoriz: epsi
  189. XXGrab*.onlyEpsi.horizDistance:    10
  190. XXGrab*.onlyEpsi.vertDistance:     55
  191. XXGrab*.onlyEpsi.label: Preview Only
  192. X
  193. XXGrab*.pageWidth.horizDistance: 10
  194. XXGrab*.pageWidth.vertDistance:  85
  195. XXGrab*.pageWidth.label: Paper Width
  196. X
  197. XXGrab*.pageWidthText.fromHoriz: pageWidth
  198. XXGrab*.pageWidthText.horizDistance: 0
  199. XXGrab*.pageWidthText.vertDistance:  85
  200. XXGrab*.pageWidthText.width: 35
  201. XXGrab*.pageWidthText*string: PAPER_WIDTH
  202. X
  203. XXGrab*.pageHeight.fromHoriz:    pageWidthText
  204. XXGrab*.pageHeight.horizDistance: 2
  205. XXGrab*.pageHeight.vertDistance:  85
  206. XXGrab*.pageHeight.label: Height
  207. X
  208. XXGrab*.pageHeightText.fromHoriz: pageHeight
  209. XXGrab*.pageHeightText.horizDistance:  0
  210. XXGrab*.pageHeightText.vertDistance:  85
  211. XXGrab*.pageHeightText.width: 35
  212. XXGrab*.pageHeightText*string: PAPER_HEIGHT
  213. X
  214. XXGrab*.horizMargin.fromHoriz: pageHeightText
  215. XXGrab*.horizMargin.horizDistance:  2
  216. XXGrab*.horizMargin.vertDistance:  85
  217. XXGrab*.horizMargin.label: Margin Width
  218. X
  219. XXGrab*.horizMarginText.fromHoriz: horizMargin
  220. XXGrab*.horizMarginText.horizDistance:  0
  221. XXGrab*.horizMarginText.vertDistance:  85
  222. XXGrab*.horizMarginText.width: 35
  223. XXGrab*.horizMarginText*string: HORIZ_MARGIN
  224. X
  225. XXGrab*.vertMargin.fromHoriz: horizMarginText
  226. XXGrab*.vertMargin.horizDistance:  2
  227. XXGrab*.vertMargin.vertDistance:  85
  228. XXGrab*.vertMargin.label:  Height
  229. X
  230. XXGrab*.vertMarginText.fromHoriz: vertMargin
  231. XXGrab*.vertMarginText.horizDistance:  0
  232. XXGrab*.vertMarginText.vertDistance:  85
  233. XXGrab*.vertMarginText.width: 35
  234. XXGrab*.vertMarginText*string: VERT_MARGIN
  235. X
  236. X!----------------------------box 4
  237. XXGrab*.box4.horizDistance: 0
  238. XXGrab*.box4.vertDistance: 385
  239. X
  240. XXGrab*.prOptions.horizDistance:   5
  241. XXGrab*.prOptions.vertDistance:    0
  242. XXGrab*.prOptions.font: *-helvetica-medium-o-normal--12-*
  243. XXGrab*.prOptions.label: Image Processing Options-----
  244. X
  245. XXGrab*.borders.horizDistance:   10
  246. XXGrab*.borders.vertDistance:    25
  247. XXGrab*.borders.shapeStyle: oval
  248. XXGrab*.borders.label: Include Borders
  249. XXGrab*.borders.width:          105
  250. XXGrab*.borders.state:            1
  251. X
  252. XXGrab*.reverse.horizDistance:   10
  253. XXGrab*.reverse.vertDistance:    55
  254. XXGrab*.reverse.shapeStyle: oval
  255. XXGrab*.reverse.label: Reverse Colors
  256. XXGrab*.reverse.width:           105
  257. X
  258. XXGrab*.brightnessLbl.horizDistance:   10
  259. XXGrab*.brightnessLbl.vertDistance:    85
  260. XXGrab*.brightnessLbl.label: Brightness
  261. X
  262. XXGrab*.brightnessText.horizDistance:   85
  263. XXGrab*.brightnessText.vertDistance:    85
  264. XXGrab*.brightnessText.width:           30
  265. XXGrab*.brightnessText*string: 100
  266. X
  267. XXGrab*.dither.horizDistance:   10
  268. XXGrab*.dither.vertDistance:   115
  269. XXGrab*.dither.label: Dither
  270. X
  271. XXGrab*.mdither.horizDistance:   62
  272. XXGrab*.mdither.vertDistance:   115
  273. XXGrab*.mdither.label: M-Dither
  274. X
  275. XXGrab*.halftone.horizDistance:  132
  276. XXGrab*.halftone.vertDistance:   115
  277. XXGrab*.halftone.label: Halftone
  278. X
  279. XXGrab*.mapbw.horizDistance:   10
  280. XXGrab*.mapbw.vertDistance:    140
  281. XXGrab*.mapbw.label: Map to B/W
  282. X
  283. X
  284. X!----------------------------box 5
  285. XXGrab*.box5.fromHoriz: box4
  286. XXGrab*.box5.horizDistance: 5
  287. XXGrab*.box5.vertDistance:  385
  288. X
  289. XXGrab*.outputLbl.horizDistance:     5
  290. XXGrab*.outputLbl.vertDistance:      0
  291. XXGrab*.outputLbl.font: *-helvetica-medium-o-normal--12-*
  292. XXGrab*.outputLbl.label: Output Options--------------
  293. X
  294. XXGrab*.file.horizDistance:   10
  295. XXGrab*.file.vertDistance:    25
  296. XXGrab*.file.label: To File:
  297. XXGrab*.file.state: 1
  298. X
  299. XXGrab*.fileText.horizDistance:   100
  300. XXGrab*.fileText.vertDistance:    25
  301. XXGrab*.fileText.width: 100
  302. XXGrab*.fileText*string: DEFAULT_FILENAME
  303. X
  304. XXGrab*.printer.horizDistance:    10
  305. XXGrab*.printer.vertDistance:     55
  306. XXGrab*.printer.label: To Command:
  307. X
  308. XXGrab*.printerText.horizDistance:    100
  309. XXGrab*.printerText.vertDistance:     55
  310. XXGrab*.printerText.width: 100
  311. XXGrab*.printerText*string: DEFAULT_COMMAND
  312. X
  313. X
  314. X!----------------------------box 6
  315. XXGrab*.box6.horizDistance:   0
  316. XXGrab*.box6.vertDistance:  547
  317. X
  318. X
  319. XXGrab*.splat.label: -----------------------------------------------------
  320. X
  321. XXGrab*.OK.horizDistance:   110
  322. XXGrab*.OK.vertDistance:     25
  323. XXGrab*.OK.width:            80
  324. XXGrab*.OK.font: *-helvetica-bold-r-normal--14-*
  325. XXGrab*.OK.label: OK
  326. X
  327. XXGrab*.Dismiss.horizDistance:   265
  328. XXGrab*.Dismiss.vertDistance:     25
  329. XXGrab*.Dismiss.width:            80
  330. XXGrab*.Dismiss.font: *-helvetica-bold-r-normal--14-*
  331. XXGrab*.Dismiss.label: Dismiss
  332. X
  333. X
  334. X!----------------------------- pervasive resources
  335. XXGrab*font: *-helvetica-medium-r-normal--12-*
  336. XXGrab*Label.borderWidth: 0
  337. XXGrab*Toggle.borderWidth: 1
  338. XXGrab*Form.borderWidth: 0
  339. XXGrab*Toggle.shapeStyle: rectangle
  340. XXGrab*Command.shapeStyle: oval
  341. XXGrab*Text.editType: edit
  342. X
  343. XXGrab*Form.title.right: chainRight
  344. XXGrab*Form.box5.right: chainRight
  345. XXGrab*Form.box5.Text.right: chainRight
  346. XXGrab*Form.box6.right: chainRight
  347. XXGrab*Form.box6.Dismiss.left: chainRight
  348. XXGrab*Form.box6.Dismiss.right: chainRight
  349. X
  350. XXGrab*Form.Form.*.left: chainLeft
  351. XXGrab*Form.Form.*.right: chainLeft
  352. XXGrab*Form.Form.*.top: chainTop
  353. XXGrab*Form.Form.*.bottom: chainTop
  354. X
  355. XXGrab*Form.background: #a3d1f2
  356. XXGrab*Label.background: #a3d1f2
  357. X!XGrab*Text*background: #d3f1ff
  358. XXGrab*Toggle.background: ivory
  359. X!XGrab*Command.background: #d3f1ff
  360. X
  361. XXGrab*selstyle.foreground: navy
  362. XXGrab*outputFormat.foreground: navy
  363. XXGrab*psOptions.foreground: navy
  364. XXGrab*prOptions.foreground: navy
  365. XXGrab*outputLbl.foreground: navy
  366. XXGrab*foreground: navy
  367. XXGrab*background: #d3f1ff
  368. X
  369. X! ========================================================================
  370. X! *
  371. X! * Name - XGrabxaw.res
  372. X! *
  373. X! * Version:    1.2
  374. X! *
  375. X! * ccsid:    @(#)XGrabxaw.res    1.2 - 06/28/93 09:13:39
  376. X! * from:     ccs/s.XGrabxaw.res
  377. X! * date:     06/28/93 09:14:48
  378. X! *
  379. X! * Copyright (c) 1991-2 Bruce Schuchardt.
  380. X! * Read the file cpyright.h for full copyright information.
  381. X! *
  382. X! *
  383. X! * Description: Application Defaults file for xgrab
  384. X! *
  385. X! *========================================================================
  386. X
  387. END_OF_FILE
  388. if test 9956 -ne `wc -c <'xgrabsc.2_3/XGrabxaw.res'`; then
  389.     echo shar: \"'xgrabsc.2_3/XGrabxaw.res'\" unpacked with wrong size!
  390. fi
  391. # end of 'xgrabsc.2_3/XGrabxaw.res'
  392. fi
  393. if test -f 'xgrabsc.2_3/process.hc' -a "${1}" != "-c" ; then 
  394.   echo shar: Will not clobber existing file \"'xgrabsc.2_3/process.hc'\"
  395. else
  396. echo shar: Extracting \"'xgrabsc.2_3/process.hc'\" \(7583 characters\)
  397. sed "s/^X//" >'xgrabsc.2_3/process.hc' <<'END_OF_FILE'
  398. X/*========================================================================
  399. X *
  400. X * Name - process.hc
  401. X *
  402. X * ccs version:    1.2
  403. X *
  404. X * ccsid:    @(#)process.hc    1.2 - 07/06/92 10:52:51
  405. X * from:     ccs/s.process.hc
  406. X * date:     06/28/93 09:14:49
  407. X *
  408. X * Description:  color processing functions for xgrabsc
  409. X *
  410. X *               see cpyright.h for copyright information
  411. X *
  412. X *
  413. X *========================================================================
  414. X */
  415. X
  416. X/*
  417. X * Alter colors by setting or clearing bits in rgb values.
  418. X * This effectively reduces the depth of the image, causing the
  419. X * number of colors used to be reduced.  Equivalent colors are
  420. X * merged in the image, and the used flags of remapped colors are
  421. X * cleared.
  422. X *
  423. X * The number of eliminated colormap entries is returned.  The colormap
  424. X * is not compressed.
  425. X */
  426. XalterPlanes(image, modeIsAnd, bits)
  427. X  imageInfo *image;
  428. X  int modeIsAnd;      /* if TRUE, combine mask with AND; if FALSE, use OR */
  429. X  unsigned int bits;
  430. X{
  431. X  int nc, cidx, ridx, h, w;
  432. X  long p;
  433. X  XImage *ximage = image->ximage;
  434. X  long map[MAX_CELLS];
  435. X  int remapCount;
  436. X  word mask;
  437. X
  438. X  if (ximage->depth <= 1)
  439. X    return 0;
  440. X
  441. X  mask = 0xFFFF ^ ((1 << (bits+8)) - 1);
  442. X  if (!modeIsAnd)
  443. X    mask = ~mask & 0xFFFF;
  444. X
  445. X  if (verbose) {
  446. X    fprintf(stderr, "%s: %s color with mask %x...", programName,
  447. X            modeIsAnd? "ANDing" : "ORing", mask);
  448. X    fflush(stderr);
  449. X  }
  450. X
  451. X  nc = image->numcells;
  452. X  if (modeIsAnd)
  453. X    for (cidx=0; cidx<nc; cidx++) {
  454. X      nr[cidx] = image->red[cidx]   & mask;
  455. X      ng[cidx] = image->green[cidx] & mask;
  456. X      nb[cidx] = image->blue[cidx]  & mask;
  457. X    }
  458. X  else
  459. X    for (cidx=0; cidx<nc; cidx++) {
  460. X      nr[cidx] = image->red[cidx]   | mask;
  461. X      ng[cidx] = image->green[cidx] | mask;
  462. X      nb[cidx] = image->blue[cidx]  | mask;
  463. X    }
  464. X
  465. X  /* now eliminate redundant colors */
  466. X  for (cidx=0; cidx<nc; cidx++)
  467. X    map[cidx] = cidx;
  468. X  remapCount = 0;
  469. X  for (cidx=0; cidx<nc; cidx++)
  470. X    if (image->used[cidx])
  471. X      for (ridx=cidx+1; ridx<nc; ridx++)
  472. X        if (image->used[ridx]  &&
  473. X            nr[cidx]==nr[ridx] &&
  474. X            ng[cidx]==ng[ridx] &&
  475. X            nb[cidx]==nb[ridx]) {
  476. X          /* the colors match - remap this pixel to the one we're scanning with */
  477. X          map[ridx] = cidx;
  478. X          image->used[ridx] = FALSE;
  479. X          remapCount++;
  480. X        }
  481. X
  482. X  memcpy((char *)image->red,   (char *)nr, nc*sizeof(word));
  483. X  memcpy((char *)image->green, (char *)ng, nc*sizeof(word));
  484. X  memcpy((char *)image->blue,  (char *)nb, nc*sizeof(word));
  485. X
  486. X  /* remap redundant pixels in the image */
  487. X  if (remapCount)
  488. X    for (h=0; h<ximage->height; h++)
  489. X      for (w=0; w<ximage->width; w++) {
  490. X        p = XGetPixel(ximage, w, h);
  491. X        if (p != map[p])
  492. X          XPutPixel(ximage, w, h, map[p]);
  493. X      }
  494. X
  495. X  if (verbose)
  496. X    fprintf(stderr, "  %d colors remapped\n", remapCount, nc);
  497. X  return remapCount;
  498. X}
  499. X
  500. X
  501. X
  502. X
  503. X
  504. X/* Brighten or darken colors in the image by the given amount ('percent').
  505. X * The amount is an integer that, if less than 100 will darken the image
  506. X * and if greater than 100 will brighten the image.  After modifying
  507. X * colors equivalent colors are merged (as in alterPlanes).  The number
  508. X * of eliminated colors is returned.
  509. X */
  510. XbrightenColors(image, percent)
  511. X  imageInfo *image;
  512. X  int percent;
  513. X{
  514. X  int nc, cidx, ridx, h, w;
  515. X  long p;
  516. X  XImage *ximage = image->ximage;
  517. X  float  adjustment;
  518. X  long map[MAX_CELLS];
  519. X  int remapCount;
  520. X  dw new;
  521. X
  522. X  if (ximage->depth <= 1)
  523. X    return 0;
  524. X
  525. X  if (verbose) {
  526. X    fprintf(stderr, "%s: adjusting intensity by %d...", programName, percent);
  527. X    fflush(stderr);
  528. X  }
  529. X
  530. X  adjustment = (float)percent / 100.0;
  531. X  nc = image->numcells;
  532. X  for (cidx=0; cidx<nc; cidx++) {
  533. X    new = image->red[cidx] * adjustment;
  534. X    if (new > (dw)0xFFFF) new = (dw)0xFFFF;
  535. X    nr[cidx] = new;
  536. X    new = image->green[cidx] * adjustment;
  537. X    if (new > (dw)0xFFFF) new = (dw)0xFFFF;
  538. X    ng[cidx] = new;
  539. X    new = image->blue[cidx] * adjustment;
  540. X    if (new > (dw)0xFFFF) new = (dw)0xFFFF;
  541. X    nb[cidx] = new;
  542. X  }
  543. X
  544. X  /* now eliminate redundant colors */
  545. X  for (cidx=0; cidx<nc; cidx++)
  546. X    map[cidx] = cidx;
  547. X  remapCount = 0;
  548. X  for (cidx=0; cidx<nc; cidx++)
  549. X    if (image->used[cidx])
  550. X      for (ridx=cidx+1; ridx<nc; ridx++)
  551. X        if (image->used[ridx]  &&
  552. X            nr[cidx]==nr[ridx] &&
  553. X            ng[cidx]==ng[ridx] &&
  554. X            nb[cidx]==nb[ridx]) {
  555. X          map[ridx] = cidx;
  556. X          image->used[ridx] = FALSE;
  557. X          remapCount++;
  558. X        }
  559. X
  560. X  memcpy((char *)image->red,   (char *)nr, nc*sizeof(word));
  561. X  memcpy((char *)image->green, (char *)ng, nc*sizeof(word));
  562. X  memcpy((char *)image->blue,  (char *)nb, nc*sizeof(word));
  563. X
  564. X  /* remap redundant pixels in the image */
  565. X  if (remapCount)
  566. X    for (h=0; h<ximage->height; h++)
  567. X      for (w=0; w<ximage->width; w++) {
  568. X        p = XGetPixel(ximage, w, h);
  569. X        if (p != map[p])
  570. X          XPutPixel(ximage, w, h, map[p]);
  571. X      }
  572. X
  573. X
  574. X  if (verbose)
  575. X    fprintf(stderr, "  %d colors remapped\n", remapCount, nc);
  576. X
  577. X  return remapCount;
  578. X}
  579. X
  580. X
  581. X
  582. X
  583. X
  584. X/* Reverse the colors in the image */
  585. XreverseColors(image)
  586. X  imageInfo *image;
  587. X{
  588. X  int nc, cidx;
  589. X  long size, idx;
  590. X  unsigned char *data;
  591. X  XImage *ximage;
  592. X  int map[2];
  593. X
  594. X  if (verbose) {
  595. X    fprintf(stderr, "%s: reversing colors...", programName);
  596. X    fflush(stderr);
  597. X  }
  598. X
  599. X
  600. X  if (image->ximage->depth <= 1) {
  601. X    /* for black and white images, just reverse the bits */
  602. X    ximage = image->ximage;
  603. X    data = (unsigned char *)ximage->data;
  604. X    size = ximage->bytes_per_line * ximage->height;
  605. X    for (idx=0; idx<size; idx++, data++)
  606. X      *data = ~(*data);
  607. X  }
  608. X  else {
  609. X    /* for other images, reverse the color values in the color table */
  610. X    nc = image->numcells;
  611. X    for (cidx=0; cidx<nc; cidx++) {
  612. X      image->red[cidx]   = (unsigned short)~((unsigned short)(image->red[cidx]));
  613. X      image->blue[cidx]  = (unsigned short)~((unsigned short)(image->blue[cidx]));
  614. X      image->green[cidx] = (unsigned short)~((unsigned short)(image->green[cidx]));
  615. X    }
  616. X  }
  617. X}
  618. X
  619. X
  620. X
  621. X
  622. X
  623. X/*
  624. X * Compress the colors used in an XImage so that all pixel values are
  625. X * adjacent.  Alters the rgb color tables and the XImage data values.
  626. X */
  627. XcompressColormap(image)
  628. X  imageInfo *image;
  629. X{
  630. X  XImage *ximage = image->ximage;
  631. X  long map[MAX_CELLS];
  632. X  int  ncolors, w, h, m;
  633. X  long p;
  634. X
  635. X  if (ximage->depth <= 1  ||  image->numcells > MAX_CELLS)
  636. X    return;
  637. X
  638. X  if (verbose) {
  639. X    fprintf(stderr, "%s: compressing colormap...", programName);
  640. X    fflush(stderr);
  641. X  }
  642. X  ncolors = 0;
  643. X  /* map[] is indexed by old pixel values.  It delivers new, compressed,
  644. X   * pixel values. */
  645. X  for (m=0; m<MAX_CELLS; m++) map[m] = MAX_CELLS+1;
  646. X  /* bludgeon through the whole image and remap each pixel value */
  647. X  for (h=0; h<ximage->height; h++) {
  648. X    for (w=0; w<ximage->width; w++) {
  649. X      /* Get the pixel index and see if it has been used or not.
  650. X       * Then remap the pixel */
  651. X      p = XGetPixel(ximage, w, h);
  652. X      if (map[p] == MAX_CELLS+1) {
  653. X        map[p] = ncolors;
  654. X        ncolors++;
  655. X      }
  656. X      if (p != map[p])
  657. X        XPutPixel(ximage, w, h, map[p]);
  658. X    }
  659. X  }
  660. X  /* now compress the color table */
  661. X  memset((char *)image->used, 0, MAX_CELLS);
  662. X  for (m=0; m<MAX_CELLS; m++) {
  663. X    if (map[m] != MAX_CELLS+1) {
  664. X      p = map[m];
  665. X      nr[p] = image->red[m];
  666. X      ng[p] = image->green[m];
  667. X      nb[p] = image->blue[m];
  668. X      image->used[p] = TRUE;
  669. X    }
  670. X  }
  671. X  memcpy((char *)image->red,   (char *)nr, ncolors*sizeof(word));
  672. X  memcpy((char *)image->green, (char *)ng, ncolors*sizeof(word));
  673. X  memcpy((char *)image->blue,  (char *)nb, ncolors*sizeof(word));
  674. X  image->numcells = ncolors;
  675. X  if (verbose)
  676. X    fprintf(stderr, "  %d colors used\n", ncolors);
  677. X}
  678. X
  679. END_OF_FILE
  680. if test 7583 -ne `wc -c <'xgrabsc.2_3/process.hc'`; then
  681.     echo shar: \"'xgrabsc.2_3/process.hc'\" unpacked with wrong size!
  682. fi
  683. # end of 'xgrabsc.2_3/process.hc'
  684. fi
  685. if test -f 'xgrabsc.2_3/virtual.h' -a "${1}" != "-c" ; then 
  686.   echo shar: Will not clobber existing file \"'xgrabsc.2_3/virtual.h'\"
  687. else
  688. echo shar: Extracting \"'xgrabsc.2_3/virtual.h'\" \(2379 characters\)
  689. sed "s/^X//" >'xgrabsc.2_3/virtual.h' <<'END_OF_FILE'
  690. X/*
  691. X * Name - virtual.h
  692. X *
  693. X * ccs version:    1.3
  694. X *
  695. X * ccsid:    @(#)virtual.h    1.3 - 07/06/92 10:52:59
  696. X * from:     ccs/s.virtual.h
  697. X * date:     06/28/93 09:14:49
  698. X *
  699. X *--- original header:
  700. X *
  701. X * vroot.h -- Virtual Root Window handling header file
  702. X *
  703. X * This header file redefines the X11 macros RootWindow and DefaultRootWindow,
  704. X * making them look for a virtual root window as provided by certain `virtual'
  705. X * window managers like swm and tvtwm. If none is found, the ordinary root
  706. X * window is returned, thus retaining backward compatibility with standard
  707. X * window managers.
  708. X * The function implementing the virtual root lookup remembers the result of
  709. X * its last invocation to avoid overhead in the case of repeated calls
  710. X * on the same display and screen arguments.
  711. X * The lookup code itself is taken from Tom LaStrange's ssetroot program.
  712. X *
  713. X * Most simple root window changing X programs can be converted to using
  714. X * virtual roots by just including
  715. X *
  716. X * #include "vroot.h"
  717. X *
  718. X * after all the X11 header files.  It has been tested on such popular
  719. X * X clients as xphoon, xfroot, xloadimage, and xaqua.
  720. X *
  721. X * Andreas Stolcke (stolcke@ICSI.Berkeley.EDU), 9/7/90
  722. X */
  723. X
  724. Xstatic Window
  725. XVirtualRootWindow(dpy, screen)
  726. XDisplay *dpy;
  727. X{
  728. X    static Display *save_dpy = (Display *)0;
  729. X    static int save_screen = -1;
  730. X    static Window root = (Window)0;
  731. X
  732. X    Atom __SWM_VROOT = None;
  733. X    int i;
  734. X    Window rootReturn, parentReturn, *children;
  735. X    unsigned int numChildren;
  736. X
  737. X    if ( dpy != save_dpy || screen != save_screen ) {
  738. X        root = RootWindow(dpy, screen);
  739. X
  740. X        /* go look for a virtual root */
  741. X        __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
  742. X        XQueryTree(dpy, root, &rootReturn, &parentReturn,
  743. X                 &children, &numChildren);
  744. X        for (i = 0; i < numChildren; i++) {
  745. X            Atom actual_type;
  746. X            int actual_format;
  747. X            long nitems, bytesafter;
  748. X            Window *newRoot = (Window *)0;
  749. X
  750. X            if (XGetWindowProperty(dpy, children[i], __SWM_VROOT,
  751. X                0, 1, False, XA_WINDOW,
  752. X                &actual_type, &actual_format,
  753. X                &nitems, &bytesafter,
  754. X                (unsigned char **) &newRoot) == Success
  755. X                && newRoot) {
  756. X                root = *newRoot;
  757. X                break;
  758. X            }
  759. X        }
  760. X
  761. X        save_dpy = dpy;
  762. X        save_screen = screen;
  763. X    }
  764. X
  765. X    return root;
  766. X}
  767. X
  768. X/*********************
  769. X#undef DefaultRootWindow
  770. X#define DefaultRootWindow(dpy) RootWindow(dpy, DefaultScreen(dpy))
  771. X
  772. X#undef RootWindow
  773. X#define RootWindow(dpy,screen) VirtualRootWindow(dpy,screen)
  774. X**********************/
  775. END_OF_FILE
  776. if test 2379 -ne `wc -c <'xgrabsc.2_3/virtual.h'`; then
  777.     echo shar: \"'xgrabsc.2_3/virtual.h'\" unpacked with wrong size!
  778. fi
  779. # end of 'xgrabsc.2_3/virtual.h'
  780. fi
  781. if test -f 'xgrabsc.2_3/xgrabsc.man' -a "${1}" != "-c" ; then 
  782.   echo shar: Will not clobber existing file \"'xgrabsc.2_3/xgrabsc.man'\"
  783. else
  784. echo shar: Extracting \"'xgrabsc.2_3/xgrabsc.man'\" \(16313 characters\)
  785. sed "s/^X//" >'xgrabsc.2_3/xgrabsc.man' <<'END_OF_FILE'
  786. X.\"========================================================================
  787. X.\"
  788. X.\" Name - xgrabsc.man
  789. X.\"
  790. X.\" ccs version: 1.18
  791. X.\"
  792. X.\" ccsid:    @(#)xgrabsc.man    1.18 - 06/28/93 09:13:52
  793. X.\" from:     ccs/s.xgrabsc.man
  794. X.\" date:     06/28/93 09:14:49
  795. X.\"
  796. X.\" Copyright (C) 1990-92 Bruce Schuchardt
  797. X.\" See the end of this document for full copyright information.
  798. X.\"
  799. X.\" Description:  Man page for xgrabsc
  800. X.\"
  801. X.\"========================================================================
  802. X.\"
  803. X.TH XGRABSC 1X
  804. X.\"
  805. X.SH NAME
  806. Xxgrabsc \- grab rectangular screen images and store in files
  807. X.\"
  808. X.SH SYNOPSIS
  809. X.in +8n
  810. X.ti -8n
  811. X\fIxgrabsc\fR
  812. X[\fB\-d\fP\ \fIdisplay\fP]
  813. X[\fB\-id\fP\ \fIwindowId\fP]
  814. X[\fB\-o\fP\ \fIoutputFile\fP]
  815. X[\fB\-s\fP\ \fIseconds\fP]
  816. X[\fB\-post\fP\ \fIseconds\fP]
  817. X[\fB\-b\fP\ \fIpercent\fP]
  818. X[\fB\-and\fP\ \fIandBits\fP]
  819. X[\fB\-or\fP\ \fIorBits\fP]
  820. X[\fB\-page\fP\ \fIwidthxheight-hmarg-vmarg\fP]
  821. X[\fB\-bell -grab -verbose -bdrs -nobdrs -key -stretch -root -click
  822. X-coords \fIwidthxheight+x+y\fP
  823. X.br
  824. X-reverse -bw -mdither -dither -halftone
  825. X.br
  826. X-ps -cps -simple -xwd -xwdxy -bm -bm2 -bm3 -puzzle
  827. X.br
  828. X-bin -comp -eps -l -limit -preview -prev -previewonly -colproc\fP]
  829. X.in -8n
  830. X.\"
  831. X.\"
  832. X.\"
  833. X.SH DESCRIPTION
  834. X\fIxgrabsc\fR lets you grab arbitrary rectangular images from an
  835. XX server and writes them to standard output in a variety of formats.
  836. X.PP
  837. XCommand line options also allow reduction of colormaps, halftoning
  838. Xand dithering of color images, and direct mapping of color images
  839. Xto monochrome.
  840. X.PP
  841. XOptions must be seperated with spaces or tabs.  They
  842. Xmay be preceded with a dash, but this optional and provided for Un*x
  843. Xaddicts.  Many may also be prefixed with 'no', or an additional dash, to
  844. Xturn them off.
  845. X.PP
  846. XThe default output format is gray-scale non-encapsulated Postscript, with
  847. Ximage compression (if image compression significantly reduces the amount of
  848. Xoutput).
  849. X.PP
  850. XIf you desire an output format not produced by xgrabsc, try using the
  851. XPBM package by Jef Poskanzer to convert xgrabsc to that format.  PBM
  852. Xcan read xgrabsc's XWD output and convert it to a lot of different formats.
  853. X.\"
  854. X.\"
  855. X.\"
  856. X.\"
  857. X.SH GENERAL OPTIONS
  858. X.TP 8
  859. X-d \fIdisplayName\fP or -display \fIdisplayName\fP
  860. X.br
  861. XUse an alternate display.  If no display is specified on the command line,
  862. Xxgrabsc looks for the environment variable DISPLAY for the name of the
  863. Xdisplay and screen to grab from.  Note that you must have permission to
  864. Xaccess the display on another computer.
  865. X.TP
  866. X-bell
  867. XThe display's bell is normally rung while the screen is being accessed.
  868. XThis turns the bell on or off (\fI-nobell\fP will turn it \fIoff\fP).
  869. X.TP
  870. X-grab
  871. XEnable server grabs.  Normally xgrabsc will "grab" the server so
  872. Xthat the screen is frozen while a rectangle is selected and the image
  873. Xis extracted.  If the screen is not frozen, rubber-banding may cause
  874. Xvideo droppings on portions of the screen that are changing.  Use \fI-nograb\fP
  875. Xto turn off server grabs.
  876. X.TP
  877. X-o \fIoutput-file\fP or -output \fIoutput-file\fP
  878. X.br
  879. XWrite output to \fIoutput-file\fP instead of standard output.  The
  880. Xoutput-file name, minus directory and extension, is used as the internal
  881. Xname for the image in formats supporting image names.  Postscript,
  882. Xxwd, pixmap and bitmap formats all support image names.
  883. X.TP
  884. X-s \fIseconds\fP or -sleep \fIseconds\fP
  885. X.br
  886. XSleep for \fIseconds\fP seconds before commencing operation.  This
  887. Xshould be used if you need some time to get the target image ready.
  888. X.TP
  889. X-post \fIseconds\fP
  890. XSleep for \fIseconds\fP seconds after window/rectangle selection.  This is
  891. Xcommonly used to pop up menus after a window has been selected but before
  892. Xxgrabsc takes its snapshot.
  893. X.TP
  894. X-verbose
  895. XDisplay processing information on standard error output (stderr).
  896. X.sp 3
  897. X.\"
  898. X.\"
  899. X.\"
  900. X.\"
  901. X.\"
  902. X.SH SELECTION OPTIONS
  903. X.TP
  904. X-id \fIwindow ID\fP
  905. XDump the window with the given ID.
  906. X.TP
  907. X-key
  908. XSelect the window under the mouse when the Control key is pressed.  This
  909. Xoption is normally used in getting images of menus.  Pop up the menu,
  910. Xoptionally move the pointer to the window containing the menu, and strike
  911. Xthe Control key to begin the dump.
  912. X.TP
  913. X-root
  914. XDump the entire screen (root window).
  915. X.TP
  916. X-stretch
  917. XUse rubber-band rectangle to select region to grab.  This is the
  918. Xdefault.
  919. X.TP
  920. X-click
  921. XWait for a click on a window and dump the selected window.
  922. X.TP
  923. X-coords \fIwidthxheight+x+y\fP
  924. XSelects the given area of the screen, without mouse or keyboard interaction.
  925. XUse this if you need to grab the same area of the screen over and over again.
  926. X.\"
  927. X.\"
  928. X.\"
  929. X.\"
  930. X.\"
  931. X.sp 3
  932. X.SH IMAGE PROCESSING OPTIONS
  933. X.TP
  934. X-nobdrs or -noborders
  935. X.br
  936. XRemove window-manager borders from window images.  This option
  937. Xapplies only to selection by ID (\fI\-id\fP) or xwd-style selection
  938. X(\fI-click\fP).
  939. X.TP
  940. X-bdrs or -borders
  941. X.br
  942. XInclude window-manager borders in window images.  This option
  943. Xapplies only to selection by ID (\fI\-id\fP) or xwd-style selection
  944. X(\fI-click\fP).  Use \fI-nobdrs\fP or \fI-noborders\fP to turn it off.
  945. X.TP
  946. X-b \fIpercent\fR or -brighten \fIpercent\fR
  947. X.br
  948. Xbrighten or darken the image by \fIpercent\fR.  Percentages are given
  949. Xas integers. 100 is the base and a larger number will brighten the image
  950. Xwhile a smaller number will darken the image.
  951. X.TP
  952. X-and \fIandBits\fR
  953. XClear all colormap bits up to the given plane.  This has the effect of
  954. Xdarkening the image somewhat and shrinking the apparent depth of the image
  955. X(and, consequently, the size of the color table).  \fIAndBits\fR should
  956. Xbe in the range [1-8] inclusive.
  957. X.TP
  958. X-or \fIorBits\fR
  959. XSet all colormap bits up to the given plane.  This brightens the image
  960. Xsomewhat and also shrinks the apparent depth of the image.  When
  961. Xboth \-A and \-O are specified, ANDing will occur before ORing.
  962. X.TP
  963. X-reverse
  964. XReverse the colors in the image.  The bits of each color used in the
  965. Ximage are inverted.
  966. X.TP
  967. X-bw
  968. XConvert the source color image to a monochrome bitmap.  All colors
  969. Xfalling below the average color intensity are mapped to black.  Others
  970. Xare mapped to white.
  971. X.TP
  972. X-halftone
  973. XConvert the source color image to a halftoned monchrome bitmap.
  974. XResolution is maintained by increasing the size of the image by
  975. Xa factor of four on both axes.
  976. X.TP
  977. X-mdither
  978. XConvert the source color image to a dithered monochrome bitmap.
  979. XThis is like halftoning, but resolution is sacrificed to keep the
  980. Xresulting image the same size as the original.  The matrix dithering
  981. Xalgorithm used with this option is most suitable for line-drawings
  982. Xand text.  For more complex graphics the \fI-dither\fR option is recommended.
  983. X.TP
  984. X-dither
  985. XConvert the source color image to a dithered monochrome bitmap with
  986. Xthe Floyd-Steinberg algorithm.
  987. X.TP
  988. X-nodither
  989. XTurns off any dithering.  Use this if your \fBXGRABSC\fP environment variable
  990. Xspecifies dithering and you want to override it to produce an undithered
  991. Ximage.
  992. X.sp 3
  993. X.\"
  994. X.\"
  995. X.\"
  996. X.\"
  997. X.SH OUTPUT FORMAT OPTIONS
  998. X.TP
  999. X-cps
  1000. XWrite output in \fIPostscript\fP format using the colorimage operator
  1001. Xfor color printers.
  1002. XColor to grayscale conversion is bundled into the output so you can actually
  1003. Xuse either color or cheaper grayscale printers.  For monochrome displays, the
  1004. X\fI-ps\fP option will give more compact output.
  1005. X.TP
  1006. X-ps
  1007. XWrite output in \fIPostscript\fP format for greyscale printers.
  1008. XThe number of bits per Postscript sample is determined by the depth of the
  1009. Ximage.
  1010. X.TP
  1011. X-xwd
  1012. XWrite output in \fIxwd\fP format.  Use this if you want to convert to another
  1013. Xoutput format with \fBPbm+\fP.
  1014. X.TP
  1015. XWrite output in \FIxwd -xy\fP format.  This is like xwd, but allows black and
  1016. Xwhite images to be written with eight pixels per byte instead of the default
  1017. Xone pixel per byte.  While xwud and xpr will handle this format, some programs
  1018. Xwill not.
  1019. X.TP
  1020. X-bm
  1021. XWrite the output in X Bitmap format if the image is black and white, or
  1022. XX Pixmap format if the image is gray or color.
  1023. X.TP
  1024. X-bm2
  1025. XWrite the output in X Bitmap format if the image is black and white, or
  1026. XX Pixmap format 2 if the image is gray or color.
  1027. X-bm3
  1028. XWrite the output in X Bitmap format if the image is black and white, or
  1029. XX Pixmap format 3 if the image is gray or color.
  1030. X.TP
  1031. X-puzzle
  1032. XWrite output in a format suitable for loading into the \fIpuzzle\fP
  1033. Xprogram (see example below).
  1034. X.sp 2
  1035. X.\"
  1036. X.\"
  1037. X.\"
  1038. X.\"
  1039. X.\"
  1040. X.SH POSTSCRIPT OPTIONS
  1041. X.TP
  1042. X-compress
  1043. XEnable or suppress Postscript image run-length encoding.  Postscript output
  1044. Xis
  1045. Xnormally compressed to minimize the size of output.  If your printer
  1046. Xcan't handle compressed output, you should use \fI-nocompress\fP to turn
  1047. Xoff compression.
  1048. X.TP
  1049. X-eps
  1050. XCreate Encapsulated Postscript output, rather than normal stand-alone
  1051. XPostscript.  This adds EPSF header comments and removes all scaling and
  1052. Xtranslation of the image.
  1053. X.TP
  1054. X-l or -landscape
  1055. X.br
  1056. XUse landscape layout (with page width and height exchanged) for Postscript
  1057. Xoutput.  This option is ignored if Encapsulated Postscript output is requested.
  1058. XWidth and height may be specified with the -page option.
  1059. X.TP
  1060. X-bin
  1061. XWrite Postscript output in binary rather than using hexidecimal encoding.
  1062. XThis causes the image portion of the output to use half as much space,
  1063. Xdecreasing transmission time to the printer.  Note that not all print
  1064. Xspoolers can handle 8 bit binary data, so this may not work on your system!
  1065. X.TP
  1066. X-limit
  1067. XFor Postscript output, check printer memory availability before attempting
  1068. Xto print an image (the code to perform the checks is integrated into the
  1069. Xoutput of xgrabsc).  This is turned off if Encapsulated Postscript output
  1070. Xis requested, and may be disabled completely when building the xgrabsc
  1071. Xprogram.  On the command line it may be turned off with \fI-nolimit\fP.
  1072. X.TP
  1073. X-preview or -prev
  1074. X.br
  1075. XSelects Encapsulated Postscript output with an EPSI preview image in its
  1076. Xheader.  The preview image, if necessary, is dithered to black and white
  1077. Xeither with
  1078. Xa default dithering algorithm or one you specify on the command line (e.g.,
  1079. X\fI-mdither\fP).  Programs such as Frame use preview images to display
  1080. Xthe postscript image during editing sessions.  If you don't have a preview
  1081. Ximage, Frame will display a blank rectangle.  The image will print OK but
  1082. Xyou won't see it while editing.
  1083. X.TP
  1084. X-previewonly
  1085. XLike \fI-preview\fP but writes only the preview portion, not the postscript
  1086. Ximage.  This may be used to add the preview to an existing EPS file after
  1087. Xhaving displayed it using a PostScript interpreter.
  1088. X.TP
  1089. X-page \fIwidthxheight-marginWidth-marginHeight\fP
  1090. XSets the size of the paper and the borders you desire around the edge of the
  1091. Xpaper.  Xgrabsc will reduce the image if necessary to keep it within the
  1092. Xborders you specify.  The default page size and margins are set when
  1093. Xxgrabsc is built.  Measurements are in inches (e.g., 8.5x11.0-0.5-0.5)
  1094. X.sp 3
  1095. X.\"
  1096. X.\"
  1097. X.\"
  1098. X.\"
  1099. X.\"
  1100. X.\"
  1101. X.\"
  1102. X.SH PROCESSING ORDER
  1103. XIt is helpful to know the order of processing when multiple processing
  1104. Xoptions are given on the command line.
  1105. X.PP
  1106. XProcessing is done in five phases:  1) set up, 2) obtain image,
  1107. X3) process colors, 4) poly->monochrome conversions, and 5) output conversion.
  1108. X.PP
  1109. XThe set-up phase includes processing command-line options, sleeping,
  1110. Xconnecting to X-Windows, freezing the screen, and grabbing the mouse if
  1111. Xnecessary.
  1112. X.PP
  1113. XIf the mouse is grabbed for rubber-banding, an upper-left-corner cursor is
  1114. Xdisplayed until the left mouse button is pressed.  A lower-left-corner
  1115. Xcursor is then displayed while drawing rubber-rectangles until the mouse
  1116. Xbutton is released.
  1117. X.PP
  1118. XIf the mouse is grabbed for xwd-style window selection, an xwd-style cursor
  1119. Xis displayed until the left mouse button is pressed.
  1120. X.PP
  1121. XThe mouse is then released.
  1122. X.PP
  1123. XThe bell is then run and the image is pulled from the screen.
  1124. X.PP
  1125. XFollowing the image-grab, the bell is run twice and the screen is released.
  1126. X.PP
  1127. XIf the image is not monochrome, the color manipulation functions are
  1128. Xthen applied in this order: brighten, AND, and OR, reverse.
  1129. X.PP
  1130. XOnly one polychrome to monochrome conversion is allowed.  If none of
  1131. Xthese is chosen, the color table of a polychrome image is compressed
  1132. Xin preparation for output conversion.
  1133. X.PP
  1134. XThe output stream is then opened and the image is written in the selected
  1135. Xoutput format.
  1136. X.sp 2
  1137. X.SH ENVIRONMENT
  1138. XXGRABSC - specifies command line arguments to be processed before those
  1139. Xactually entered on the command line.
  1140. X.PP
  1141. XDISPLAY - specifies the name of the display that xgrabsc should grab from.
  1142. X.sp 2
  1143. X.SH EXAMPLES
  1144. XThe simplest form of use, giving Postscript output, is
  1145. X.sp
  1146. X.ti +5
  1147. Xxgrabsc >outfile.ps
  1148. X.sp
  1149. X.PP
  1150. XTo write output in \fIPostscript\fP format and send to the printer,
  1151. Xuse
  1152. X.sp
  1153. X.ti +5
  1154. Xxgrabsc | lpr
  1155. X.sp
  1156. XIt is sometimes helpful to brighten an image somewhat before it is
  1157. Xformatted for Postscript output.  E.g., to brighten by 30%
  1158. X.sp
  1159. X.ti +5
  1160. Xxgrabsc -b 130 | lpr
  1161. X.sp
  1162. X.PP
  1163. XIf your printer supports color, and your display is color, you can
  1164. Xhave xgrabsc generate color output instead of gray scale:
  1165. X.sp
  1166. X.ti +5
  1167. Xxgrabsc -cps | lpr
  1168. X.sp
  1169. X.PP
  1170. XThe default Postscript output attempts to scale the image so that
  1171. Xit will all fit on one page, and is centered on the page.  If you
  1172. Xare grabbing images to include in documents, such as with FrameMaker,
  1173. Xyou should ask for Encapsulated Postscript output with the \fI-eps\fP
  1174. Xswitch.  For example:
  1175. X.sp
  1176. X.ti +5
  1177. X  xgrabsc -eps -o image1.eps
  1178. X.PP
  1179. XTo select an entire window, write output in \fIpuzzle\fP format
  1180. Xand read into the puzzle program, use the commands
  1181. X.sp
  1182. X.ti +5
  1183. Xxgrabsc -click -puzzle >outfile.pzl
  1184. X.br
  1185. X.ti +5
  1186. Xpuzzle -picture outfile.pzl
  1187. X.sp
  1188. X.PP
  1189. XTo have xgrabsc sleep for three seconds before rubber-banding, display
  1190. Xprocessing information, and have the result displayed with xwud,
  1191. X.sp
  1192. X.ti +5
  1193. Xxgrabsc -xwd -verbose -s 3 | xwud
  1194. X.sp
  1195. X.PP
  1196. XTo grab an image from another server and then reduce the colormap
  1197. Xto three bits by ANDing, use
  1198. X.sp
  1199. X.ti +5
  1200. Xxgrabsc -d other:0.0 -and 5 -bm >outfile.xpm
  1201. X.sp
  1202. XYou will, of course, have to go to the other machine to select the
  1203. Ximage with that machine's mouse.
  1204. X.sp 2
  1205. X.SH LIMITATIONS
  1206. XColormaps larger than 256 entries are not currently supported. This
  1207. Xmeans that it won't work with your fancy 24-bit display.
  1208. X.PP
  1209. XThe default screen visual is used as the visual for the image.
  1210. XVisuals are associated with particular windows, and xgrabsc pretends
  1211. Xignorance about any windows but the root.
  1212. X.PP
  1213. XThis software has been tested with StaticGray and 8-plane PseudoColor
  1214. Xon DECStations (using both UWS 2.2 and X11 Release 4).  It has also
  1215. Xbeen tested with 8-plane PseudoColor on Sun SparcStations and various
  1216. Xother platforms using X11 Release 4 and Release 5.
  1217. X.PP
  1218. XX11 Pixmap format is rather verbose.
  1219. XYou may want to run large images through the \fIcompress\fP utility
  1220. Xbefore storing them in a file.  E.g.,
  1221. X.sp
  1222. X.ti +5
  1223. Xxgrabsc -bm | compress >outfile.xpm.Z
  1224. X.sp
  1225. X.SH AUTHOR
  1226. X.nf
  1227. X     Bruce Schuchardt
  1228. X    Servio Corporation
  1229. X      bruce@slc.com
  1230. X.fi
  1231. X.sp 2
  1232. X.SH ACKNOWLEGEMENTS
  1233. X.PP
  1234. XSome of the source code for xgrabsc came from
  1235. Xthe xloadimage project by Jim Frost (jimf@saber.com) and others.  Jim's
  1236. Xcopyright has been included both here and in the source code.
  1237. X.PP
  1238. XThe idea for using run-length encoding for Postscript output came from
  1239. Xthe xwd2ps project by Robert Tatar and Craig A. McGowan.
  1240. X.PP
  1241. XThe ad2c.sed script that makes it possible to let you run xgrab without
  1242. Xinstalling XGrab.ad everywhere is part of the ad2c package developed by
  1243. XGeorge Ferguson.
  1244. X.sp 2
  1245. X.SH CONTRIBUTORS
  1246. X.PP
  1247. XYves Arrouye wrote the EPS Preview and page-configuration enhancements.
  1248. X.sp 2
  1249. X.SH COPYRIGHT
  1250. XCopyright (c) 1990-93 Bruce Schuchardt
  1251. X.PP
  1252. X\fIXgrabsc\fR is copywritten material with a very loose copyright
  1253. Xallowing unlimited modification and distribution if the copyright
  1254. Xnotices are left intact.  Various portions are copywritten by various
  1255. Xpeople, but all use a modification of the MIT copyright notice.
  1256. XPlease check the cpyright.h for complete copyright information.  The
  1257. Xintent is to keep the source free, not to stifle its distribution, so
  1258. Xplease write to me if you have any questions.
  1259. X.PP
  1260. XTHE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  1261. XINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
  1262. XNO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  1263. XCONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
  1264. XOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  1265. XOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
  1266. XUSE OR PERFORMANCE OF THIS SOFTWARE.
  1267. X.s 2
  1268. X.SH SEE ALSO
  1269. XX(1X), xhost(1), xwd(1X), xwud(1X), xwd2ps(1X), xloadimage(1X), xpm(1X),
  1270. Xxpr(1X), puzzle(1X), compress(1), uncompress(1), xv(1X)
  1271. END_OF_FILE
  1272. if test 16313 -ne `wc -c <'xgrabsc.2_3/xgrabsc.man'`; then
  1273.     echo shar: \"'xgrabsc.2_3/xgrabsc.man'\" unpacked with wrong size!
  1274. fi
  1275. # end of 'xgrabsc.2_3/xgrabsc.man'
  1276. fi
  1277. if test -f 'xgrabsc.2_3/xgrabxaw.c' -a "${1}" != "-c" ; then 
  1278.   echo shar: Will not clobber existing file \"'xgrabsc.2_3/xgrabxaw.c'\"
  1279. else
  1280. echo shar: Extracting \"'xgrabsc.2_3/xgrabxaw.c'\" \(14663 characters\)
  1281. sed "s/^X//" >'xgrabsc.2_3/xgrabxaw.c' <<'END_OF_FILE'
  1282. X/*========================================================================
  1283. X *
  1284. X * Name - xgrabxaw.c
  1285. X *
  1286. X * Version:    1.16
  1287. X *
  1288. X * ccsid:    @(#)xgrabxaw.c    1.16 - 06/28/93 09:13:54
  1289. X * from:     ccs/s.xgrabxaw.c
  1290. X * date:     06/28/93 09:14:49
  1291. X *
  1292. X * Copyright (c) 1990-93 Bruce Schuchardt.
  1293. X * Read the file cpyright.h for full copyright information.
  1294. X *
  1295. X *
  1296. X * Description:
  1297. X *
  1298. X * xgrab.c - interactive front for xgrabsc
  1299. X *
  1300. X *========================================================================
  1301. X */
  1302. X#include "cpyright.h"
  1303. X#include "patchlevel.h"
  1304. X#include "config.h"
  1305. X
  1306. X#include <stdio.h>
  1307. X#include <X11/Intrinsic.h>
  1308. X#include <X11/StringDefs.h>
  1309. X#include <X11/Shell.h>
  1310. X#include <X11/Xaw/Form.h>
  1311. X#include <X11/Xaw/Label.h>
  1312. X#include <X11/Xaw/Command.h>
  1313. X#include <X11/Xaw/AsciiText.h>
  1314. X#include <X11/Xaw/Toggle.h>
  1315. X
  1316. Xstatic char *fallback_resources[] = {
  1317. X#include "xgrabxaw_ad.h"
  1318. X  NULL
  1319. X  };
  1320. X
  1321. X
  1322. Xstatic Display *hDisplay;
  1323. X
  1324. Xtypedef enum {
  1325. X  HITWIN = 1,
  1326. X  STRETCH,
  1327. X  KEY,
  1328. X  ROOT,
  1329. X
  1330. X  XWD,
  1331. X  XWDXY,
  1332. X  PS,
  1333. X  BITMAP,
  1334. X  BITMAP2,
  1335. X  BITMAP3,
  1336. X  PUZZLE,
  1337. X  SIMPLE,
  1338. X
  1339. X  DITHER,
  1340. X  MDITHER,
  1341. X  HALFTONE,
  1342. X  MAPBW,
  1343. X
  1344. X  REVERSE,
  1345. X
  1346. X  TOFILE,
  1347. X  TOPRN,
  1348. X
  1349. X  PS_NORMAL,
  1350. X  PS_EPS,
  1351. X  PS_EPSI,
  1352. X  PS_EPSIONLY,
  1353. X  PS_LANDSCAPE
  1354. X  
  1355. X  } radioType;
  1356. X
  1357. X
  1358. XWidget selBtns, formatBtns, psColr, encBtns, psComp, sltext, psltext,
  1359. X       psLim,
  1360. X       psBin, borderBtn, horizMargin, vertMargin, pgHeight, pgWidth,
  1361. X       cnvBtns, revBtn, brtext, outBtns, filenm, prncmd, dispBtn, hostnm;
  1362. XWidget hShell;
  1363. X
  1364. XXtAppContext appContext;
  1365. X
  1366. X
  1367. Xstatic char* stradi(ptr, i)    /* Add an integer to a string */
  1368. X    char* ptr;
  1369. X    int i; {
  1370. X
  1371. X    sprintf(ptr + strlen(ptr), "%d", i);
  1372. X    return ptr;
  1373. X}
  1374. X
  1375. Xstatic char* stradw(ptr, s)   /* Add a string to another, with no ws */
  1376. X    char* ptr;
  1377. X    char* s; {
  1378. X
  1379. X    char* ou = ptr + strlen(ptr);
  1380. X
  1381. X    while (isspace(*s)) {
  1382. X    ++s;
  1383. X    }
  1384. X    while (*s && !isspace(*s)) {
  1385. X    *ou++ = *s++;
  1386. X    }
  1387. X    *ou = '\0';
  1388. X
  1389. X    return ptr;
  1390. X}
  1391. X
  1392. X
  1393. Xstatic void doGrab() {
  1394. X  char tmp[257];
  1395. X  char cmdargs[200];
  1396. X  char piper[200];
  1397. X  char cmd[500];
  1398. X  char *txt;
  1399. X  int  s, d, len, num;
  1400. X  int  sltime, psltime;
  1401. X  int  bright;
  1402. X  Boolean state;
  1403. X
  1404. X  cmdargs[0] = '\0';
  1405. X  piper[0] = '\0';
  1406. X
  1407. X  XtVaGetValues(sltext, XtNstring, &txt, NULL);
  1408. X  sltime = atoi(txt);
  1409. X  if (sltime < 0) sltime = 0;
  1410. X  sprintf(tmp, "-sleep %d ", sltime);
  1411. X  strcat(cmdargs, tmp);
  1412. X
  1413. X  XtVaGetValues(psltext, XtNstring, &txt, NULL);
  1414. X  psltime = atoi(txt);
  1415. X  if (psltime < 0) psltime = 0;
  1416. X  sprintf(tmp, "-post %d ", psltime);
  1417. X  strcat(cmdargs, tmp);
  1418. X
  1419. X  XtVaGetValues(brtext, XtNstring, &txt, NULL);
  1420. X  bright = atoi(txt);
  1421. X  sprintf(tmp, "-brighten %d ", bright);
  1422. X  strcat(cmdargs, tmp);
  1423. X
  1424. X  XtVaGetValues(borderBtn, XtNstate, &state, NULL);
  1425. X  if (!state)
  1426. X    strcat(cmdargs, "-");
  1427. X  strcat(cmdargs, "-bdrs ");
  1428. X
  1429. X  XtVaGetValues(revBtn, XtNstate, &state, NULL);
  1430. X  if (!state)
  1431. X    strcat(cmdargs, "-");
  1432. X  strcat(cmdargs, "-reverse ");
  1433. X
  1434. X  switch ((int)XawToggleGetCurrent(selBtns)) {
  1435. X    case HITWIN:
  1436. X      strcat(cmdargs, "-click ");
  1437. X      break;
  1438. X    case KEY:
  1439. X      strcat(cmdargs, "-key ");
  1440. X      break;
  1441. X    case ROOT:
  1442. X      strcat(cmdargs, "-root ");
  1443. X      break;
  1444. X    case STRETCH:
  1445. X    default:
  1446. X      strcat(cmdargs, "-stretch ");
  1447. X      break;
  1448. X  }
  1449. X  switch ((int)XawToggleGetCurrent(formatBtns)) {
  1450. X    case XWD:
  1451. X      strcat(cmdargs, "-xwd ");
  1452. X      break;
  1453. X    case XWDXY:
  1454. X      strcat(cmdargs, "-xwdxy ");
  1455. X      break;
  1456. X    case BITMAP:
  1457. X      strcat(cmdargs, "-bm ");
  1458. X      break;
  1459. X    case BITMAP2:
  1460. X      strcat(cmdargs, "-bm2 ");
  1461. X      break;
  1462. X    case BITMAP3:
  1463. X      strcat(cmdargs, "-bm3 ");
  1464. X      break;
  1465. X    case PUZZLE:
  1466. X      strcat(cmdargs, "-puzzle ");
  1467. X      break;
  1468. X    case SIMPLE:
  1469. X      strcat(cmdargs, "-simple ");
  1470. X      break;
  1471. X    case PS:
  1472. X    default:
  1473. X      XtVaGetValues(psColr, XtNstate, &state, NULL);
  1474. X      if (!state)
  1475. X        strcat(cmdargs, "-ps ");
  1476. X      else
  1477. X        strcat(cmdargs, "-cps ");
  1478. X
  1479. X      switch ((int)XawToggleGetCurrent(encBtns)) {
  1480. X        case PS_EPS:
  1481. X          strcat(cmdargs, "-eps ");
  1482. X      break;
  1483. X    case PS_EPSI:
  1484. X      strcat(cmdargs, "-preview ");
  1485. X      break;
  1486. X    case PS_EPSIONLY:
  1487. X      strcat(cmdargs, "-previewonly ");
  1488. X      break;
  1489. X    case PS_LANDSCAPE:
  1490. X      strcat(cmdargs, "-landscape ");
  1491. X      break;
  1492. X    default:
  1493. X      break;
  1494. X      }
  1495. X
  1496. X      XtVaGetValues(psComp, XtNstate, &state, NULL);
  1497. X      if (!state)
  1498. X        strcat(cmdargs, "-");
  1499. X      strcat(cmdargs, "-compress ");
  1500. X      XtVaGetValues(psBin, XtNstate, &state, NULL);
  1501. X      if (!state)
  1502. X        strcat(cmdargs, "-");
  1503. X      strcat(cmdargs, "-bin ");
  1504. X
  1505. X      XtVaGetValues(psLim, XtNstate, &state, NULL);
  1506. X      if (!state)
  1507. X        strcat(cmdargs, "-");
  1508. X      strcat(cmdargs, "-limit ");
  1509. X
  1510. X      strcat(cmdargs, "-page ");
  1511. X      XtVaGetValues(pgWidth, XtNstring, &txt, NULL);
  1512. X      if (strlen(txt))    stradw(cmdargs, txt);
  1513. X      else                stradi(cmdargs, PAPER_WIDTH);
  1514. X      strcat(cmdargs, "x");
  1515. X      XtVaGetValues(pgHeight, XtNstring, &txt, NULL);
  1516. X      if (strlen(txt))    stradw(cmdargs, txt);
  1517. X      else                stradi(cmdargs, PAPER_HEIGHT);
  1518. X      strcat(cmdargs, "-");
  1519. X      XtVaGetValues(horizMargin, XtNstring, &txt, NULL);
  1520. X      if (strlen(txt))    stradw(cmdargs, txt);
  1521. X      else                stradi(cmdargs, HORIZ_MARGIN);
  1522. X      strcat(cmdargs, "-");
  1523. X      XtVaGetValues(horizMargin, XtNstring, &txt, NULL);
  1524. X      if (strlen(txt))    stradw(cmdargs, txt);
  1525. X      else                stradi(cmdargs, VERT_MARGIN);
  1526. X      strcat(cmdargs, " ");
  1527. X
  1528. X      break;
  1529. X  }
  1530. X  switch ((int)XawToggleGetCurrent(cnvBtns)) {
  1531. X    case DITHER:
  1532. X      strcat(cmdargs, "-dither ");
  1533. X      break;
  1534. X    case MDITHER:
  1535. X      strcat(cmdargs, "-mdither ");
  1536. X      break;
  1537. X    case HALFTONE:
  1538. X      strcat(cmdargs, "-halftone ");
  1539. X      break;
  1540. X    case MAPBW:
  1541. X      strcat(cmdargs, "-bw ");
  1542. X      break;
  1543. X    default:
  1544. X      break;
  1545. X  }
  1546. X  switch ((int)XawToggleGetCurrent(outBtns)) {
  1547. X    case TOPRN:
  1548. X      XtVaGetValues(prncmd, XtNstring, &txt, NULL);
  1549. X      if (strlen(txt)) {
  1550. X        strcat(piper, " | ");
  1551. X        strcat(piper, txt);
  1552. X      }
  1553. X      break;
  1554. X    case TOFILE:
  1555. X    default:
  1556. X      strcat(cmdargs, "-o ");
  1557. X      XtVaGetValues(filenm, XtNstring, &txt, NULL);
  1558. X      if (strlen(txt)) {
  1559. X        strcat(cmdargs, txt);
  1560. X#ifdef BUMP_FILENAMES
  1561. X    len = strlen(txt);
  1562. X    for (s=0; s<len && (txt[s] != '.'); s++)
  1563. X    {}
  1564. X    strcpy(tmp, txt);
  1565. X    tmp[s] = '\0';
  1566. X    d = s;
  1567. X    while (d > 0  &&  ('0' <= txt[d-1]  &&  txt[d-1] <= '9'))
  1568. X      d--;
  1569. X    if ('0' <= txt[d]  && txt[d] <= '9')
  1570. X      num = atoi(&tmp[d]);
  1571. X    else
  1572. X      num = 0;
  1573. X    num++;
  1574. X    sprintf(&tmp[d], "%d", num);
  1575. X    strcat(tmp, &txt[s]);
  1576. X    XtVaSetValues(filenm, XtNstring, tmp, NULL);
  1577. X#endif
  1578. X      }
  1579. X      else {
  1580. X        strcat(cmdargs, "screen.dmp");
  1581. X    XtVaSetValues(filenm, XtNstring, "screen.dmp", NULL);
  1582. X      }
  1583. X      strcat(cmdargs, " ");
  1584. X      break;
  1585. X  }
  1586. X
  1587. X  XtVaGetValues(dispBtn, XtNstate, &state, NULL);
  1588. X  if (state) {
  1589. X    XtVaGetValues(hostnm, XtNstring, &txt, NULL);
  1590. X    strcat(cmdargs, "-d ");
  1591. X    if (strlen(txt)) {
  1592. X      strcat(cmdargs, txt);
  1593. X      strcat(cmdargs, " ");
  1594. X    }
  1595. X    else
  1596. X      strcat(cmdargs, ":0 ");
  1597. X  }
  1598. X
  1599. X  sprintf(cmd, "xgrabsc %s%s\n", cmdargs, piper);
  1600. X  /* fputs(cmd, stderr); */
  1601. X  /* try to make the window iconic */
  1602. X  XtUnmapWidget(hShell);
  1603. X  XSync(hDisplay, False);
  1604. X  system(cmd);
  1605. X  XtMapWidget(hShell);
  1606. X}
  1607. X
  1608. X
  1609. X
  1610. X
  1611. Xstatic void doDismiss() {
  1612. X  if (hShell) {
  1613. X    XtDestroyWidget(hShell);
  1614. X    hShell = NULL;
  1615. X    exit(0);
  1616. X  }
  1617. X}
  1618. X
  1619. X
  1620. X
  1621. X
  1622. Xstatic void createWindow() {
  1623. X  Widget dialog, button, box1, box2, box3, box4, box5, box6;
  1624. X
  1625. X  dialog = XtVaCreateManagedWidget("dialog", formWidgetClass, hShell,
  1626. X           NULL);
  1627. X           XtVaCreateManagedWidget("title",  labelWidgetClass, dialog,
  1628. X           NULL);
  1629. X
  1630. X
  1631. X  /* selection options */
  1632. X  /* input options */
  1633. X  box1 = XtVaCreateManagedWidget("box1", formWidgetClass, dialog, NULL);
  1634. X
  1635. X           XtVaCreateManagedWidget("inputLbl", labelWidgetClass, box1,
  1636. X       NULL);
  1637. X
  1638. X  dispBtn= XtVaCreateManagedWidget("host", toggleWidgetClass, box1,
  1639. X       NULL);
  1640. X
  1641. X  hostnm = XtVaCreateManagedWidget("hostText", asciiTextWidgetClass, box1,
  1642. X           XtNeditType, XawtextEdit, NULL);
  1643. X
  1644. X  if (getenv("DISPLAY"))
  1645. X    XtVaSetValues(hostnm, XtNstring, getenv("DISPLAY"), NULL);
  1646. X
  1647. X  selBtns =
  1648. X           XtVaCreateManagedWidget("click", toggleWidgetClass, box1,
  1649. X           XtNradioData, HITWIN,
  1650. X       NULL);
  1651. X
  1652. X           XtVaCreateManagedWidget("stretch", toggleWidgetClass, box1,
  1653. X           XtNradioData, STRETCH,
  1654. X       XtNradioGroup, selBtns,
  1655. X       NULL);
  1656. X
  1657. X           XtVaCreateManagedWidget("key", toggleWidgetClass, box1,
  1658. X           XtNradioData, KEY,
  1659. X       XtNradioGroup, selBtns,
  1660. X       NULL);
  1661. X
  1662. X           XtVaCreateManagedWidget("root", toggleWidgetClass, box1,
  1663. X           XtNradioData, ROOT,
  1664. X       XtNradioGroup, selBtns,
  1665. X       NULL);
  1666. X
  1667. X           XtVaCreateManagedWidget("sleeplbl", labelWidgetClass, box1,
  1668. X           NULL);
  1669. X
  1670. X  sltext = XtVaCreateManagedWidget("sleeptime", asciiTextWidgetClass, box1,
  1671. X           XtNeditType, XawtextEdit, NULL);
  1672. X
  1673. X           XtVaCreateManagedWidget("psleeplbl", labelWidgetClass, box1,
  1674. X           NULL);
  1675. X
  1676. X  psltext = XtVaCreateManagedWidget("psleeptime", asciiTextWidgetClass, box1,
  1677. X           XtNeditType, XawtextEdit, NULL);
  1678. X
  1679. X  box2 = XtVaCreateManagedWidget("box2", formWidgetClass, dialog, NULL);
  1680. X
  1681. X  /* output options */
  1682. X           XtVaCreateManagedWidget("outputFormat", labelWidgetClass, box2,
  1683. X           NULL);
  1684. X
  1685. X  formatBtns =
  1686. X           XtVaCreateManagedWidget("xwd", toggleWidgetClass, box2,
  1687. X           XtNradioData, XWD,
  1688. X       NULL);
  1689. X
  1690. X           XtVaCreateManagedWidget("ps", toggleWidgetClass, box2,
  1691. X           XtNradioData, PS,
  1692. X       XtNradioGroup, formatBtns,
  1693. X       NULL);
  1694. X
  1695. X           XtVaCreateManagedWidget("puzzle", toggleWidgetClass, box2,
  1696. X           XtNradioData, PUZZLE,
  1697. X       XtNradioGroup, formatBtns,
  1698. X       NULL);
  1699. X
  1700. X
  1701. X           XtVaCreateManagedWidget("xyxwd", toggleWidgetClass, box2,
  1702. X           XtNradioData, XWDXY,
  1703. X       XtNradioGroup, formatBtns,
  1704. X       NULL);
  1705. X
  1706. X           XtVaCreateManagedWidget("xpm", toggleWidgetClass, box2,
  1707. X           XtNradioData, BITMAP,
  1708. X       XtNradioGroup, formatBtns,
  1709. X       NULL);
  1710. X
  1711. X           XtVaCreateManagedWidget("xpm2", toggleWidgetClass, box2,
  1712. X           XtNradioData, BITMAP2,
  1713. X       XtNradioGroup, formatBtns,
  1714. X       NULL);
  1715. X
  1716. X           XtVaCreateManagedWidget("xpm3", toggleWidgetClass, box2,
  1717. X           XtNradioData, BITMAP3,
  1718. X       XtNradioGroup, formatBtns,
  1719. X       NULL);
  1720. X
  1721. X
  1722. X  /* postscript options */
  1723. X  box3 = XtVaCreateManagedWidget("box3", formWidgetClass, dialog, NULL);
  1724. X
  1725. X           XtVaCreateManagedWidget("psOptions", labelWidgetClass, box3,
  1726. X           NULL);
  1727. X
  1728. X  psComp = XtVaCreateManagedWidget("compress", toggleWidgetClass, box3,
  1729. X       NULL);
  1730. X
  1731. X  psColr = XtVaCreateManagedWidget("color", toggleWidgetClass, box3,
  1732. X       NULL);
  1733. X
  1734. X  psBin = XtVaCreateManagedWidget("binary", toggleWidgetClass, box3,
  1735. X       NULL);
  1736. X
  1737. X  psLim = XtVaCreateManagedWidget("limit", toggleWidgetClass, box3,
  1738. X       NULL);
  1739. X
  1740. X  encBtns= XtVaCreateManagedWidget("landscape", toggleWidgetClass, box3,
  1741. X           XtNradioData, PS_LANDSCAPE,
  1742. X       NULL);
  1743. X
  1744. X           XtVaCreateManagedWidget("epsi", toggleWidgetClass, box3,
  1745. X           XtNradioData, PS_EPSI,
  1746. X       XtNradioGroup, encBtns,
  1747. X       NULL);
  1748. X
  1749. X           XtVaCreateManagedWidget("onlyEpsi", toggleWidgetClass, box3,
  1750. X           XtNradioData, PS_EPSIONLY,
  1751. X       XtNradioGroup, encBtns,
  1752. X       NULL);
  1753. X
  1754. X/*------------
  1755. X           XtVaCreateManagedWidget("encap", toggleWidgetClass, box3,
  1756. X           XtNradioData, PS_EPS,
  1757. X       XtNradioGroup, encBtns,
  1758. X       NULL);
  1759. X--------------*/
  1760. X
  1761. X
  1762. X           XtVaCreateManagedWidget("pageWidth", labelWidgetClass, box3,
  1763. X           NULL);
  1764. X
  1765. X  pgWidth = XtVaCreateManagedWidget("pageWidthText",asciiTextWidgetClass, box3,
  1766. X           XtNeditType, XawtextEdit, NULL);
  1767. X
  1768. X           XtVaCreateManagedWidget("pageHeight", labelWidgetClass, box3,
  1769. X           NULL);
  1770. X
  1771. X  pgHeight = XtVaCreateManagedWidget("pageHeightText",asciiTextWidgetClass, box3,
  1772. X           XtNeditType, XawtextEdit, NULL);
  1773. X
  1774. X           XtVaCreateManagedWidget("horizMargin", labelWidgetClass, box3,
  1775. X           NULL);
  1776. X
  1777. X  horizMargin = XtVaCreateManagedWidget("horizMarginText",asciiTextWidgetClass, box3,
  1778. X           XtNeditType, XawtextEdit, NULL);
  1779. X
  1780. X           XtVaCreateManagedWidget("vertMargin", labelWidgetClass, box3,
  1781. X           NULL);
  1782. X
  1783. X  vertMargin = XtVaCreateManagedWidget("vertMarginText",asciiTextWidgetClass, box3,
  1784. X           XtNeditType, XawtextEdit, NULL);
  1785. X
  1786. X
  1787. X  /* image processing options */
  1788. X  box4 = XtVaCreateManagedWidget("box4", formWidgetClass, dialog, NULL);
  1789. X
  1790. X           XtVaCreateManagedWidget("prOptions", labelWidgetClass, box4,
  1791. X           NULL);
  1792. X  cnvBtns= XtVaCreateManagedWidget("dither", toggleWidgetClass, box4,
  1793. X           XtNradioData, DITHER,
  1794. X       NULL);
  1795. X           XtVaCreateManagedWidget("mdither", toggleWidgetClass, box4,
  1796. X           XtNradioData, MDITHER,
  1797. X       XtNradioGroup, cnvBtns,
  1798. X       NULL);
  1799. X           XtVaCreateManagedWidget("halftone", toggleWidgetClass, box4,
  1800. X           XtNradioData, HALFTONE,
  1801. X       XtNradioGroup, cnvBtns,
  1802. X       NULL);
  1803. X           XtVaCreateManagedWidget("mapbw", toggleWidgetClass, box4,
  1804. X           XtNradioData, MAPBW,
  1805. X       XtNradioGroup, cnvBtns,
  1806. X       NULL);
  1807. X
  1808. X           XtVaCreateManagedWidget("brightnessLbl", labelWidgetClass, box4,
  1809. X       NULL);
  1810. X  brtext = XtVaCreateManagedWidget("brightnessText", asciiTextWidgetClass, box4,
  1811. X           XtNeditType, XawtextEdit, NULL);
  1812. X
  1813. X  revBtn = XtVaCreateManagedWidget("reverse", toggleWidgetClass, box4, NULL);
  1814. X
  1815. X  borderBtn = XtVaCreateManagedWidget("borders", toggleWidgetClass, box4, NULL);
  1816. X
  1817. X  box5 = XtVaCreateManagedWidget("box5", formWidgetClass, dialog, NULL);
  1818. X
  1819. X           XtVaCreateManagedWidget("outputLbl", labelWidgetClass, box5,
  1820. X       NULL);
  1821. X
  1822. X  outBtns= XtVaCreateManagedWidget("file", toggleWidgetClass, box5,
  1823. X           XtNradioData, TOFILE,
  1824. X       NULL);
  1825. X
  1826. X  filenm = XtVaCreateManagedWidget("fileText", asciiTextWidgetClass, box5,
  1827. X           XtNeditType, XawtextEdit, NULL);
  1828. X
  1829. X           XtVaCreateManagedWidget("printer", toggleWidgetClass, box5,
  1830. X           XtNradioData, TOPRN,
  1831. X       XtNradioGroup, outBtns,
  1832. X       NULL);
  1833. X
  1834. X  prncmd = XtVaCreateManagedWidget("printerText", asciiTextWidgetClass, box5,
  1835. X           XtNeditType, XawtextEdit, NULL);
  1836. X
  1837. X
  1838. X  box6 = XtVaCreateManagedWidget("box6", formWidgetClass, dialog, NULL);
  1839. X
  1840. X  XtVaCreateManagedWidget("splat", labelWidgetClass, box6, NULL);
  1841. X  
  1842. X  button = XtVaCreateManagedWidget("OK", commandWidgetClass, box6, NULL);
  1843. X  XtAddCallback(button, XtNcallback, doGrab, NULL);
  1844. X
  1845. X  button = XtVaCreateManagedWidget("Dismiss", commandWidgetClass, box6, NULL);
  1846. X  XtAddCallback(button, XtNcallback, doDismiss, NULL);
  1847. X
  1848. X}
  1849. X
  1850. X
  1851. X
  1852. Xint main(argc, argv, envp)
  1853. X  int argc;
  1854. X  char *argv[];
  1855. X  char *envp;
  1856. X{
  1857. X  puts("X-Windows Screen Grabber");
  1858. X  puts(Copyright);
  1859. X  puts("");
  1860. X
  1861. X
  1862. X  hShell = XtAppInitialize(&appContext, "XGrab", NULL, 0, &argc, argv,
  1863. X     fallback_resources, NULL, 0);
  1864. X
  1865. X  hDisplay = XtDisplay(hShell);
  1866. X  createWindow();
  1867. X
  1868. X  XtRealizeWidget(hShell);
  1869. X  XtAppMainLoop(appContext);
  1870. X}
  1871. END_OF_FILE
  1872. if test 14663 -ne `wc -c <'xgrabsc.2_3/xgrabxaw.c'`; then
  1873.     echo shar: \"'xgrabsc.2_3/xgrabxaw.c'\" unpacked with wrong size!
  1874. fi
  1875. # end of 'xgrabsc.2_3/xgrabxaw.c'
  1876. fi
  1877. echo shar: End of archive 3 \(of 5\).
  1878. cp /dev/null ark3isdone
  1879. MISSING=""
  1880. for I in 1 2 3 4 5 ; do
  1881.     if test ! -f ark${I}isdone ; then
  1882.     MISSING="${MISSING} ${I}"
  1883.     fi
  1884. done
  1885. if test "${MISSING}" = "" ; then
  1886.     echo You have unpacked all 5 archives.
  1887.     rm -f ark[1-9]isdone
  1888. else
  1889.     echo You still need to unpack the following archives:
  1890.     echo "        " ${MISSING}
  1891. fi
  1892. ##  End of shell archive.
  1893. exit 0
  1894.  
  1895. exit 0 # Just in case...
  1896. -- 
  1897.   // chris@Sterling.COM           | Send comp.sources.x submissions to:
  1898. \X/  Amiga - The only way to fly! |    sources-x@sterling.com
  1899.  "It's intuitively obvious to the |
  1900.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  1901.