home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sources / misc / 4182 < prev    next >
Encoding:
Text File  |  1992-12-14  |  57.3 KB  |  1,830 lines

  1. Newsgroups: comp.sources.misc
  2. Path: sparky!kent
  3. From: cristy@eplrx7.es.duPont.com (John Cristy)
  4. Subject:  v34i042:  imagemagick - X11 image processing and display v2.2, Part14/26
  5. Message-ID: <1992Dec15.035244.21694@sparky.imd.sterling.com>
  6. Followup-To: comp.sources.d
  7. X-Md4-Signature: 094348b8daf5a085eb62a9d6d9e02206
  8. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  9. Organization: Sterling Software
  10. References: <csm-v34i028=imagemagick.141926@sparky.IMD.Sterling.COM>
  11. Date: Tue, 15 Dec 1992 03:52:44 GMT
  12. Approved: kent@sparky.imd.sterling.com
  13. Lines: 1815
  14.  
  15. Submitted-by: cristy@eplrx7.es.duPont.com (John Cristy)
  16. Posting-number: Volume 34, Issue 42
  17. Archive-name: imagemagick/part14
  18. Environment: UNIX, VMS, X11, SGI, DEC, Cray, Sun, Vax
  19.  
  20. #!/bin/sh
  21. # this is Part.14 (part 14 of a multipart archive)
  22. # do not concatenate these parts, unpack them in order with /bin/sh
  23. # file ImageMagick/display.c continued
  24. #
  25. if test ! -r _shar_seq_.tmp; then
  26.     echo 'Please unpack part 1 first!'
  27.     exit 1
  28. fi
  29. (read Scheck
  30.  if test "$Scheck" != 14; then
  31.     echo Please unpack part "$Scheck" next!
  32.     exit 1
  33.  else
  34.     exit 0
  35.  fi
  36. ) < _shar_seq_.tmp || exit 1
  37. if test ! -f _shar_wnt_.tmp; then
  38.     echo 'x - still skipping ImageMagick/display.c'
  39. else
  40. echo 'x - continuing file ImageMagick/display.c'
  41. sed 's/^X//' << 'SHAR_EOF' >> 'ImageMagick/display.c' &&
  42. X              break;
  43. X            }
  44. X         if (strncmp("foreground",option+1,3) == 0)
  45. X           {
  46. X             resource_info.foreground_color=(char *) NULL;
  47. X             if (*option == '-')
  48. X               {
  49. X                 i++;
  50. X                 if (i == argc)
  51. X                   Error("missing foreground on -foreground",(char *) NULL);
  52. X                 resource_info.foreground_color=argv[i];
  53. X               }
  54. X              break;
  55. X           }
  56. X          Error("unrecognized option",option);
  57. X          break;
  58. X        }
  59. X        case 'g':
  60. X        {
  61. X          if (strncmp("gamma",option+1,2) == 0)
  62. X            {
  63. X              gamma=0.0;
  64. X              if (*option == '-')
  65. X                {
  66. X                  i++;
  67. X                  if ((i == argc) || !sscanf(argv[i],"%d",&x))
  68. X                    Error("missing gamma on -gamma",(char *) NULL);
  69. X                  gamma=atof(argv[i]);
  70. X                }
  71. X              break;
  72. X            }
  73. X          if (strncmp("geometry",option+1,2) == 0)
  74. X            {
  75. X              resource_info.image_geometry=(char *) NULL;
  76. X              if (*option == '-')
  77. X                {
  78. X                  i++;
  79. X                  if (i == argc)
  80. X                    Error("missing geometry on -geometry",(char *) NULL);
  81. X                  resource_info.image_geometry=argv[i];
  82. X                }
  83. X              alien_info.geometry=resource_info.image_geometry;
  84. X              break;
  85. X            }
  86. X          Error("unrecognized option",option);
  87. X          break;
  88. X        }
  89. X        case 'h':
  90. X        {
  91. X          Usage(True);
  92. X          break;
  93. X        }
  94. X        case 'i':
  95. X        {
  96. X          if (strncmp("iconGeometry",option+1,5) == 0)
  97. X            {
  98. X              resource_info.icon_geometry=(char *) NULL;
  99. X              if (*option == '-')
  100. X                {
  101. X                  i++;
  102. X                  if (i == argc)
  103. X                    Error("missing geometry on -iconGeometry",(char *) NULL);
  104. X                  resource_info.icon_geometry=argv[i];
  105. X                }
  106. X              break;
  107. X            }
  108. X          if (strncmp("iconic",option+1,5) == 0)
  109. X            {
  110. X              resource_info.iconic=(*option == '-');
  111. X              break;
  112. X            }
  113. X          if (strncmp("inverse",option+1,2) == 0)
  114. X            {
  115. X              inverse=(*option == '-');
  116. X              break;
  117. X            }
  118. X          Error("unrecognized option",option);
  119. X          break;
  120. X        }
  121. X        case 'm':
  122. X        {
  123. X          if (strncmp("magnify",option+1,3) == 0)
  124. X            {
  125. X              resource_info.magnify=2;
  126. X              if (*option == '-')
  127. X                {
  128. X                  i++;
  129. X                  if ((i == argc) || !sscanf(argv[i],"%d",&x))
  130. X                    Error("missing level on -magnify",(char *) NULL);
  131. X                  resource_info.magnify=atoi(argv[i]);
  132. X                }
  133. X              break;
  134. X            }
  135. X          if (strncmp("map",option+1,3) == 0)
  136. X            {
  137. X              resource_info.map_type=(char *) NULL;
  138. X              if (*option == '-')
  139. X                {
  140. X                  i++;
  141. X                  if (i == argc)
  142. X                    Error("missing map type on -map",(char *) NULL);
  143. X                  resource_info.map_type=argv[i];
  144. X                }
  145. X              break;
  146. X            }
  147. X          if (strncmp("monochrome",option+1,2) == 0)
  148. X            {
  149. X              resource_info.monochrome=(*option == '-');
  150. X              break;
  151. X            }
  152. X          Error("unrecognized option",option);
  153. X          break;
  154. X        }
  155. X        case 'n':
  156. X        {
  157. X          if (strncmp("name",option+1,2) == 0)
  158. X            {
  159. X              resource_info.name=(char *) NULL;
  160. X              if (*option == '-')
  161. X                {
  162. X                  i++;
  163. X                  if (i == argc)
  164. X                    Error("missing name on -name",(char *) NULL);
  165. X                  resource_info.name=argv[i];
  166. X                }
  167. X              break;
  168. X            }
  169. X          if (strncmp("noise",option+1,3) == 0)
  170. X            {
  171. X              noise=(*option == '-');
  172. X              break;
  173. X            }
  174. X          if (strncmp("normalize",option+1,3) == 0)
  175. X            {
  176. X              normalize=(*option == '-');
  177. X              break;
  178. X            }
  179. X          Error("unrecognized option",option);
  180. X          break;
  181. X        }
  182. X        case 'p':
  183. X        {
  184. X          if (strncmp("print",option+1,2) == 0)
  185. X            {
  186. X              resource_info.print_filename=(char *) NULL;
  187. X              if (*option == '-')
  188. X                {
  189. X                  i++;
  190. X                  if (i == argc)
  191. X                    Error("missing file name on -print",(char *) NULL);
  192. X                  resource_info.print_filename=argv[i];
  193. X                  if (access(resource_info.print_filename,0) == 0)
  194. X                    {
  195. X                      char
  196. X                        answer[2];
  197. X
  198. X                      (void) fprintf(stderr,"Overwrite %s? ",
  199. X                        resource_info.print_filename);
  200. X                      (void) gets(answer);
  201. X                      if (!((*answer == 'y') || (*answer == 'Y')))
  202. X                    exit(1);
  203. X                    }
  204. X                }
  205. X              break;
  206. X            }
  207. X          Error("unrecognized option",option);
  208. X          break;
  209. X        }
  210. X        case 'r':
  211. X        {
  212. X          if (strncmp("reflect",option+1,2) == 0)
  213. X            {
  214. X              reflect=(*option == '-');
  215. X              break;
  216. X            }
  217. X          if (strncmp("rotate",option+1,3) == 0)
  218. X            {
  219. X              degrees=0;
  220. X              if (*option == '-')
  221. X                {
  222. X                  i++;
  223. X                  if ((i == argc) || !sscanf(argv[i],"%d",&x))
  224. X                    Error("missing degrees on -rotate",(char *) NULL);
  225. X                  degrees=atoi(argv[i]);
  226. X                }
  227. X              break;
  228. X            }
  229. X          Error("unrecognized option",option);
  230. X          break;
  231. X        }
  232. X        case 's':
  233. X        {
  234. X          if (strncmp("scale",option+1,3) == 0)
  235. X            {
  236. X              scale_geometry=(char *) NULL;
  237. X              if (*option == '-')
  238. X                {
  239. X                  i++;
  240. X                  if ((i == argc) || !sscanf(argv[i],"%f",(float *) &x))
  241. X                    Error("missing scale geometry on -scale",(char *) NULL);
  242. X                  scale_geometry=argv[i];
  243. X                }
  244. X              break;
  245. X            }
  246. X          if (strncmp("scene",option+1,3) == 0)
  247. X            {
  248. X              scene=0;
  249. X              if (*option == '-')
  250. X                {
  251. X                  i++;
  252. X                  if ((i == argc) || !sscanf(argv[i],"%d",&x))
  253. X                    Error("missing scene number on -scene",(char *) NULL);
  254. X                  scene=atoi(argv[i]);
  255. X                }
  256. X              break;
  257. X            }
  258. X          Error("unrecognized option",option);
  259. X          break;
  260. X        }
  261. X        case 't':
  262. X        {
  263. X          if (strncmp("title",option+1,2) == 0)
  264. X            {
  265. X              resource_info.title=(char *) NULL;
  266. X              if (*option == '-')
  267. X                {
  268. X                  i++;
  269. X                  if (i == argc)
  270. X                    Error("missing title on -title",(char *) NULL);
  271. X                  resource_info.title=argv[i];
  272. X                }
  273. X              break;
  274. X            }
  275. X          if (strncmp("treedepth",option+1,2) == 0)
  276. X            {
  277. X              resource_info.tree_depth=0;
  278. X              if (*option == '-')
  279. X                {
  280. X                  i++;
  281. X                  if ((i == argc) || !sscanf(argv[i],"%d",&x))
  282. X                    Error("missing depth on -treedepth",(char *) NULL);
  283. X                  resource_info.tree_depth=atoi(argv[i]);
  284. X                }
  285. X              break;
  286. X            }
  287. X          Error("unrecognized option",option);
  288. X          break;
  289. X        }
  290. X        case 'v':
  291. X        {
  292. X          if (strncmp("verbose",option+1,2) == 0)
  293. X            {
  294. X              verbose=(*option == '-');
  295. X              alien_info.verbose=verbose;
  296. X              break;
  297. X            }
  298. X          if (strncmp("visual",option+1,2) == 0)
  299. X            {
  300. X              resource_info.visual_type=(char *) NULL;
  301. X              if (*option == '-')
  302. X                {
  303. X                  i++;
  304. X                  if (i == argc)
  305. X                    Error("missing visual class on -visual",(char *) NULL);
  306. X                  resource_info.visual_type=argv[i];
  307. X                }
  308. X              break;
  309. X            }
  310. X          Error("unrecognized option",option);
  311. X          break;
  312. X        }
  313. X        case 'w':
  314. X        {
  315. X          if (strncmp("window",option+1,2) == 0)
  316. X            {
  317. X              window_id=(char *) NULL;
  318. X              if (*option == '-')
  319. X                {
  320. X                  i++;
  321. X                  if (i == argc)
  322. X                    Error("missing id, name, or 'root' on -window",
  323. X                      (char *) NULL);
  324. X                  window_id=argv[i];
  325. X                }
  326. X              break;
  327. X            }
  328. X          if (strncmp("write",option+1,2) == 0)
  329. X            {
  330. X              resource_info.write_filename=(char *) NULL;
  331. X              if (*option == '-')
  332. X                {
  333. X                  i++;
  334. X                  if (i == argc)
  335. X                    Error("missing file name on -write",(char *) NULL);
  336. X                  resource_info.write_filename=argv[i];
  337. X                  if (access(resource_info.write_filename,0) == 0)
  338. X                    {
  339. X                      char
  340. X                        answer[2];
  341. X
  342. X                      (void) fprintf(stderr,"Overwrite %s? ",
  343. X                        resource_info.write_filename);
  344. X                      (void) gets(answer);
  345. X                      if (!((*answer == 'y') || (*answer == 'Y')))
  346. X                        exit(1);
  347. X                    }
  348. X                }
  349. X              break;
  350. X            }
  351. X          Error("unrecognized option",option);
  352. X          break;
  353. X        }
  354. X        default:
  355. X        {
  356. X          Error("unrecognized option",option);
  357. X          break;
  358. X        }
  359. X      }
  360. X    else
  361. X      {
  362. X        Image
  363. X          *image,
  364. X          info_image,
  365. X          *next_image;
  366. X
  367. X        time_t
  368. X          start_time;
  369. X
  370. X        unsigned long
  371. X          total_colors;
  372. X
  373. X        /*
  374. X          Option is a file name: begin by reading image from specified file.
  375. X        */
  376. X        start_time=time((time_t *) 0);
  377. X        (void) strcpy(alien_info.filename,option);
  378. X        image=ReadAlienImage(&alien_info);
  379. X        if (image == (Image *) NULL)
  380. X          if (*option == '-')
  381. X            break;
  382. X          else
  383. X            continue;
  384. X        do
  385. X        {
  386. X          info_image=(*image);
  387. X          if (scene > 0)
  388. X            image->scene=scene;
  389. X          /*
  390. X            Transform image as defined by the clip, image and scale geometries.
  391. X          */
  392. X          TransformImage(&image,clip_geometry,resource_info.image_geometry,
  393. X            scale_geometry);
  394. X          if (reflect)
  395. X            {
  396. X              Image
  397. X                *reflected_image;
  398. X
  399. X              /*
  400. X                Reverse image scanlines.
  401. X              */
  402. X              reflected_image=ReflectImage(image);
  403. X              if (reflected_image != (Image *) NULL)
  404. X                {
  405. X                  DestroyImage(image);
  406. X                  image=reflected_image;
  407. X                }
  408. X            }
  409. X          if ((degrees % 360) != 0)
  410. X            {
  411. X              Image
  412. X                *rotated_image;
  413. X
  414. X              /*
  415. X                Rotate image.
  416. X              */
  417. X              rotated_image=RotateImage(image,(double) degrees,False);
  418. X              if (rotated_image != (Image *) NULL)
  419. X                {
  420. X                  DestroyImage(image);
  421. X                  image=rotated_image;
  422. X                }
  423. X            }
  424. X          if (enhance)
  425. X            {
  426. X              Image
  427. X                *enhanced_image;
  428. X
  429. X              /*
  430. X                Enhance image.
  431. X              */
  432. X              enhanced_image=EnhanceImage(image);
  433. X              if (enhanced_image != (Image *) NULL)
  434. X                {
  435. X                  DestroyImage(image);
  436. X                  image=enhanced_image;
  437. X                }
  438. X            }
  439. X          if (noise)
  440. X            {
  441. X              Image
  442. X                *noisy_image;
  443. X
  444. X              /*
  445. X                Reduce noise in image.
  446. X              */
  447. X              noisy_image=NoisyImage(image);
  448. X              if (noisy_image != (Image *) NULL)
  449. X                {
  450. X                  DestroyImage(image);
  451. X                  image=noisy_image;
  452. X                }
  453. X            }
  454. X          if (gamma > 0.0)
  455. X            GammaImage(image,gamma);
  456. X          if (inverse)
  457. X            InverseImage(image);
  458. X          if (normalize)
  459. X            NormalizeImage(image);
  460. X          if (verbose)
  461. X            {
  462. X              /*
  463. X                Initialize image error attributes.
  464. X              */
  465. X              if (image->class == DirectClass)
  466. X                image->colors=NumberColors(image);
  467. X              total_colors=image->colors;
  468. X            }
  469. X          if (resource_info.colorspace == GRAYColorspace)
  470. X            QuantizeImage(image,256,8,resource_info.dither,GRAYColorspace,True);
  471. X          if (resource_info.monochrome)
  472. X            QuantizeImage(image,2,8,resource_info.dither,GRAYColorspace,True);
  473. X          if (resource_info.number_colors > 0)
  474. X            if ((image->class == DirectClass) ||
  475. X                (image->colors > resource_info.number_colors))
  476. X              QuantizeImage(image,resource_info.number_colors,
  477. X                resource_info.tree_depth,resource_info.dither,
  478. X                resource_info.colorspace,True);
  479. X          /*
  480. X            Display image to X server.
  481. X          */
  482. X          if (compression != UndefinedCompression)
  483. X            image->compression=compression;
  484. X          else
  485. X            image->compression=info_image.compression;
  486. X          if (window_id != (char *) NULL)
  487. X            {
  488. X              /*
  489. X                Display image to a specified X window.
  490. X              */
  491. X              XDisplayBackgroundImage(display,&resource_info,window_id,image);
  492. X              state&=ExitState;
  493. X            }
  494. X          else
  495. X            if (image->montage == (char *) NULL)
  496. X              (void) XDisplayImage(display,&resource_info,argv,argc,&image,
  497. X                &state);
  498. X            else
  499. X              do
  500. X              {
  501. X                Image
  502. X                  *tile_image;
  503. X
  504. X                /*
  505. X                  Display montage image.
  506. X                */
  507. X                tile_image=
  508. X                  XDisplayImage(display,&resource_info,argv,argc,&image,&state);
  509. X                if ((!(state & TileImageState)) || (state & ExitState))
  510. X                  break;
  511. X                (void) XDisplayImage(display,&resource_info,argv,argc,
  512. X                  &tile_image,&state);
  513. X                DestroyImage(tile_image);
  514. X              } while (!(state & ExitState));
  515. X          if (resource_info.print_filename != (char *) NULL)
  516. X            {
  517. X              /*
  518. X                Print image as Encapsulated Postscript.
  519. X              */
  520. X              (void) strcpy(image->filename,resource_info.print_filename);
  521. X              (void) PrintImage(image,resource_info.image_geometry);
  522. X            }
  523. X          if (resource_info.write_filename != (char *) NULL)
  524. X            {
  525. X              /*
  526. X                Write image in MIFF format.
  527. X              */
  528. X              (void) strcpy(image->filename,resource_info.write_filename);
  529. X              (void) WriteAlienImage(image);
  530. X            }
  531. X          if (verbose)
  532. X            {
  533. X              /*
  534. X                Display detailed info about the image.
  535. X              */
  536. X              (void) fprintf(stderr,"[%u] %s",
  537. X                image->scene == 0 ? image_number : image->scene,
  538. X                info_image.filename);
  539. X              if (resource_info.write_filename != (char *) NULL)
  540. X                (void) fprintf(stderr,"=>%s",resource_info.write_filename);
  541. X              (void) fprintf(stderr," %ux%u",info_image.columns,
  542. X                info_image.rows);
  543. X              if ((info_image.columns != image->columns) ||
  544. X                  (info_image.rows != image->rows))
  545. X                (void) fprintf(stderr,"=>%ux%u",image->columns,image->rows);
  546. X              if (image->class == DirectClass)
  547. X                (void) fprintf(stderr," DirectClass ");
  548. X              else
  549. X                (void) fprintf(stderr," PseudoClass ");
  550. X              if (total_colors != image->colors)
  551. X                (void) fprintf(stderr,"%lu=>",total_colors);
  552. X              (void) fprintf(stderr,"%uc",image->colors);
  553. X              if ((resource_info.number_colors > 0) || resource_info.monochrome)
  554. X                {
  555. X                  double
  556. X                    normalized_maximum_error,
  557. X                    normalized_mean_error;
  558. X
  559. X                  unsigned int
  560. X                    mean_error_per_pixel;
  561. X
  562. X                  /*
  563. X                    Measure quantization error.
  564. X                  */
  565. X                  QuantizationError(image,&mean_error_per_pixel,
  566. X                    &normalized_mean_error,&normalized_maximum_error);
  567. X                  (void) fprintf(stderr," %u/%.6f/%.6fe",mean_error_per_pixel,
  568. X                    normalized_mean_error,normalized_maximum_error);
  569. X                }
  570. X              (void) fprintf(stderr," %s %lds\n",image->magick,
  571. X                time((time_t *) 0)-start_time+1);
  572. X            }
  573. X          /*
  574. X            Proceed to next/previous image.
  575. X          */
  576. X          if (state & LastImageState)
  577. X            next_image=image->last;
  578. X          else
  579. X            next_image=image->next;
  580. X          if (next_image != (Image *) NULL)
  581. X            image=next_image;
  582. X        } while ((next_image != (Image *) NULL) && !(state & ExitState));
  583. X        /*
  584. X          Free image resources.
  585. X        */
  586. X        DestroyImages(image);
  587. X        if (!(state & LastImageState))
  588. X          image_marker[i]=image_number++;
  589. X        else
  590. X          {
  591. X            /*
  592. X              Proceed to last image.
  593. X            */
  594. X            for (i--; i > 0; i--)
  595. X              if (image_marker[i] == (image_number-2))
  596. X                break;
  597. X            if (image_number > 0)
  598. X              image_number--;
  599. X          }
  600. X      }
  601. X  }
  602. X  if (image_number == 0)
  603. X    Error("missing an image file name",(char *) NULL);
  604. X  XCloseDisplay(display);
  605. X  (void) free((char *) image_marker);
  606. X  return(False);
  607. }
  608. SHAR_EOF
  609. echo 'File ImageMagick/display.c is complete' &&
  610. chmod 0644 ImageMagick/display.c ||
  611. echo 'restore of ImageMagick/display.c failed'
  612. Wc_c="`wc -c < 'ImageMagick/display.c'`"
  613. test 187475 -eq "$Wc_c" ||
  614.     echo 'ImageMagick/display.c: original size 187475, current size' "$Wc_c"
  615. rm -f _shar_wnt_.tmp
  616. fi
  617. # ============= ImageMagick/X.h ==============
  618. if test -f 'ImageMagick/X.h' -a X"$1" != X"-c"; then
  619.     echo 'x - skipping ImageMagick/X.h (File already exists)'
  620.     rm -f _shar_wnt_.tmp
  621. else
  622. > _shar_wnt_.tmp
  623. echo 'x - extracting ImageMagick/X.h (Text)'
  624. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/X.h' &&
  625. #undef False
  626. #undef True
  627. #include <X11/Xos.h>
  628. #include <X11/Xlib.h>
  629. #include <X11/Xutil.h>
  630. #include <X11/Xresource.h>
  631. #include <X11/Xproto.h>
  632. #include <X11/Xatom.h>
  633. #include <X11/cursorfont.h>
  634. #include <X11/keysym.h>
  635. #undef index
  636. #ifdef hpux
  637. #undef SYSV
  638. #endif
  639. X
  640. /*
  641. X  Colormap declarations.
  642. */
  643. #define UndefinedColormap  0
  644. #define PrivateColormap  1
  645. #define SharedColormap  2
  646. /*
  647. X  Define declarations.
  648. */
  649. #define MaxNumberFonts  9
  650. #define MaxNumberPens  9
  651. #define WindowBorderWidth  2
  652. #define XSetWindowExtents(window,text,border)  \
  653. X  window.width=XTextWidth(window.font_info,text,strlen(text))+  \
  654. X    (int) border*window.font_info->max_bounds.width;  \
  655. X  window.height=window.font_info->ascent+window.font_info->descent+4;  \
  656. X  XResizeWindow(display,window.id,window.width,window.height);
  657. #define XStandardPixel(map,color,shift)  (unsigned long) (map->base_pixel+  \
  658. X  ((color.red*map->red_max+(1 << (shift-1))) >> shift)*map->red_mult+  \
  659. X  ((color.green*map->green_max+(1 << (shift-1))) >> shift)*map->green_mult+  \
  660. X  ((color.blue*map->blue_max+(1 << (shift-1))) >> shift)*map->blue_mult)
  661. X
  662. /*
  663. X  Typedef declarations.
  664. */
  665. typedef struct _DiversityPacket
  666. {
  667. X  unsigned char
  668. X    red,
  669. X    green,
  670. X    blue;
  671. X
  672. X  unsigned short
  673. X    index;
  674. X
  675. X  unsigned long
  676. X    count;
  677. } DiversityPacket;
  678. X
  679. typedef struct _XAnnotateInfo
  680. {
  681. X  int
  682. X    x,
  683. X    y;
  684. X
  685. X  unsigned int
  686. X    width,
  687. X    height;
  688. X
  689. X  double
  690. X    degrees;
  691. X
  692. X  XFontStruct
  693. X    *font_info;
  694. X
  695. X  char
  696. X    *text,
  697. X    geometry[2048];
  698. X
  699. X  struct _XAnnotateInfo
  700. X    *previous,
  701. X    *next;
  702. } XAnnotateInfo;
  703. X
  704. typedef struct _XPixelInfo
  705. {
  706. X  unsigned int
  707. X    colors;
  708. X
  709. X  unsigned long
  710. X    *pixels;
  711. X
  712. X  XColor
  713. X    background_color,
  714. X    border_color,
  715. X    foreground_color,
  716. X    pen_color[MaxNumberPens],
  717. X    annotate_color;
  718. X
  719. X  unsigned short
  720. X    background_index,
  721. X    annotate_index;
  722. } XPixelInfo;
  723. X
  724. typedef struct _XResourceInfo
  725. {
  726. X  unsigned int
  727. X    backdrop;
  728. X
  729. X  char
  730. X    *background_color,
  731. X    *border_color;
  732. X
  733. X  unsigned int
  734. X    border_width,
  735. X    colormap,
  736. X    colorspace,
  737. X    debug,
  738. X    delay,
  739. X    dither;
  740. X
  741. X  char
  742. X    *font,
  743. X    *font_name[MaxNumberFonts],
  744. X    *foreground_color;
  745. X
  746. X  int
  747. X    gravity;
  748. X
  749. X  char
  750. X    *icon_geometry;
  751. X
  752. X  unsigned int
  753. X    iconic;
  754. X
  755. X  char
  756. X    *image_geometry;
  757. X
  758. X  unsigned int
  759. X    magnify;
  760. X
  761. X  char
  762. X    *map_type;
  763. X
  764. X  unsigned int
  765. X    monochrome;
  766. X
  767. X  char
  768. X    *name;
  769. X
  770. X  unsigned int
  771. X    number_colors;
  772. X
  773. X  char
  774. X    *pen_color[MaxNumberPens],
  775. X    *print_filename,
  776. X    *server_name,
  777. X    *title;
  778. X
  779. X  unsigned int
  780. X    tree_depth;
  781. X
  782. X  char
  783. X    *visual_type,
  784. X    *write_filename;
  785. } XResourceInfo;
  786. X
  787. typedef struct _XWindowInfo
  788. {
  789. X  Window
  790. X    id;
  791. X
  792. X  int
  793. X    screen;
  794. X
  795. X  unsigned int
  796. X    depth;
  797. X
  798. X  XVisualInfo
  799. X    *visual_info;
  800. X
  801. X  XStandardColormap
  802. X    *map_info;
  803. X
  804. X  XPixelInfo
  805. X    *pixel_info;
  806. X
  807. X  XFontStruct
  808. X    *font_info;
  809. X
  810. X  GC
  811. X    graphic_context,
  812. X    highlight_context;
  813. X
  814. X  Cursor
  815. X    cursor,
  816. X    busy_cursor;
  817. X
  818. X  char
  819. X    *name,
  820. X    *geometry,
  821. X    *icon_name,
  822. X    *icon_geometry,
  823. X    *clip_geometry;
  824. X
  825. X  unsigned long
  826. X    flags;
  827. X
  828. X  int
  829. X    x,
  830. X    y;
  831. X
  832. X  unsigned int
  833. X    width,
  834. X    height,
  835. X    min_width,
  836. X    min_height,
  837. X    width_inc,
  838. X    height_inc,
  839. X    border_width,
  840. X    immutable;
  841. X
  842. X  XImage
  843. X    *ximage;
  844. X
  845. X  Pixmap
  846. X    pixmap,
  847. X    *pixmaps;
  848. X
  849. X  XSetWindowAttributes
  850. X    attributes;
  851. } XWindowInfo;
  852. X
  853. typedef struct _XWindows
  854. {
  855. X  XWindowInfo
  856. X    superclass,
  857. X    backdrop,
  858. X    icon,
  859. X    info,
  860. X    image,
  861. X    magnify,
  862. X    pan,
  863. X    popup;
  864. } XWindows;
  865. X
  866. /*
  867. X  X utilities routines.
  868. */
  869. extern char 
  870. X  *XGetResource _Declare((XrmDatabase,char *,char *,char *,char *)),
  871. X  *XVisualClassName _Declare((XVisualInfo *));
  872. X
  873. extern Cursor 
  874. X  XMakeInvisibleCursor _Declare((Display *,Window));
  875. X
  876. extern Image
  877. X  *ReadTEXTImage _Declare((char *,char *,char *,char *)),
  878. X  *ReadXImage _Declare((char *,char *,unsigned int,unsigned int,unsigned int)),
  879. X  *ReadXCImage _Declare((char *,char *,char *));
  880. X
  881. extern int
  882. X  Latin1Compare _Declare((char *,char *)),
  883. X  XError _Declare((Display *,XErrorEvent *));
  884. X
  885. extern unsigned int 
  886. X  IsTrue _Declare((char *)),
  887. X  XAnnotateImage _Declare((Display *,XWindowInfo *,XAnnotateInfo *,
  888. X    unsigned int,Image *)),
  889. X  XMakeImage _Declare((Display *,XResourceInfo *,XWindowInfo *,Image *,
  890. X    unsigned int,unsigned int)),
  891. X  XMakePixmap _Declare((Display *,XResourceInfo *,XWindowInfo *)),
  892. X  XPopupMenu _Declare((Display *,XWindowInfo *,int,int,char *,char **,
  893. X    unsigned int,char *)),
  894. X  XReadColormap _Declare((Display *,XWindowAttributes *,XColor **));
  895. X
  896. extern XVisualInfo 
  897. X  *XBestVisualInfo _Declare((Display *,char *,char *,XStandardColormap *));
  898. X
  899. extern void 
  900. X  Latin1Upper _Declare((char *)),
  901. X  XBestIconSize _Declare((Display *,XWindowInfo *,Image *)),
  902. X  XFreeStandardColormap _Declare((Display *,XVisualInfo *,XPixelInfo *,
  903. X    XStandardColormap *)),
  904. X  XGetAnnotateInfo _Declare((XAnnotateInfo *)),
  905. X  XGetPixelInfo _Declare((Display *,XVisualInfo *,XStandardColormap *,
  906. X    XResourceInfo *,Image *,XPixelInfo *)),
  907. X  XGetResourceInfo _Declare((XrmDatabase,char *,XResourceInfo *)),
  908. X  XGetWindowInfo _Declare((XWindowInfo *,XWindowInfo *)),
  909. X  XMakeStandardColormap _Declare((Display *,XVisualInfo *,XResourceInfo *,
  910. X    XPixelInfo *,Image *,XStandardColormap *)),
  911. X  XMakeWindow _Declare((Display *,Window,char **,int,XClassHint *,XWMHints *,
  912. X    Atom,XWindowInfo *)),
  913. X  XPopupAlert _Declare((Display *,XWindowInfo *,char *,char *)),
  914. X  XPopupQuery _Declare((Display *,XWindowInfo *,char *,char *)),
  915. X  XRefreshWindow _Declare((Display *,XWindowInfo *,XEvent *));
  916. X
  917. extern Window 
  918. X  XClientWindow _Declare((Display *,Window)),
  919. X  XWindowByProperty _Declare((Display *,Window,Atom)),
  920. X  XSelectWindow _Declare((Display *,XRectangle *)),
  921. X  XWindowByID _Declare((Display *,Window,unsigned long)),
  922. X  XWindowByName _Declare((Display *,Window,char *));
  923. X
  924. extern XFontStruct 
  925. X  *XBestFont _Declare((Display *,XResourceInfo *,char *,unsigned int));
  926. X
  927. /*
  928. X  Invoke pre-X11R5 ICCCM routines if XlibSpecificationRelease is not defined.
  929. */
  930. #ifndef XlibSpecificationRelease
  931. #define PRE_R5_ICCCM
  932. #endif
  933. /*
  934. X  Invoke pre-X11R4 ICCCM routines if PWinGravity is not defined.
  935. */
  936. #ifndef PWinGravity
  937. #define PRE_R4_ICCCM
  938. #endif
  939. #include "PreRvIcccm.h"
  940. SHAR_EOF
  941. chmod 0644 ImageMagick/X.h ||
  942. echo 'restore of ImageMagick/X.h failed'
  943. Wc_c="`wc -c < 'ImageMagick/X.h'`"
  944. test 6075 -eq "$Wc_c" ||
  945.     echo 'ImageMagick/X.h: original size 6075, current size' "$Wc_c"
  946. rm -f _shar_wnt_.tmp
  947. fi
  948. # ============= ImageMagick/animate.man ==============
  949. if test -f 'ImageMagick/animate.man' -a X"$1" != X"-c"; then
  950.     echo 'x - skipping ImageMagick/animate.man (File already exists)'
  951.     rm -f _shar_wnt_.tmp
  952. else
  953. > _shar_wnt_.tmp
  954. echo 'x - extracting ImageMagick/animate.man (Text)'
  955. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/animate.man' &&
  956. .ad l
  957. .nh
  958. .TH ANIMATE 1 "10 October 1992" "ImageMagick"
  959. .SH NAME
  960. animate - display a sequence of images on any workstation running X
  961. .SH SYNOPSIS
  962. .B "animate" [ \fIoptions\fP ...] \fIfile\fP
  963. [ [ \fIoptions\fP ...] \fIfile\fP ...]
  964. .SH DESCRIPTION
  965. \fIAnimate\fP displays a sequence of images on any workstation display
  966. running an X server.  \fIAnimate\fP first determines the hardware
  967. capabilities of the workstation.  If the number of unique colors in an
  968. image is less than or equal to the number the workstation can support,
  969. the image is displayed in an X window.  Otherwise the number of colors
  970. in the image is first reduced to match the color resolution of the
  971. workstation before it is displayed.
  972. .PP
  973. This means that a continuous-tone 24 bits-per-pixel image can display on a
  974. 8 bit pseudo-color device or monochrome device.  In most instances the
  975. reduced color image closely resembles the original.  Alternatively, a
  976. monochrome or pseudo-color image sequence can display on a continuous-tone
  977. 24 bits-per-pixel device.
  978. .PP
  979. To help prevent color flashing on X server visuals that have colormaps,
  980. \fIanimate\fP creates a single colormap from the image sequence.  This can
  981. be rather time consuming.  You can speed this operation up by reducing
  982. the colors in the image before you `animate' them.  Use \fImogrify\fP
  983. to color reduce the images to a single colormap.  See \fBmogrify(1)\fP for
  984. details.  Alternatively, you can use a Standard Colormap; or a static, direct,
  985. or true color visual.  You can define a Standard Colormap with
  986. \fIxstdcmap\fP.  See \fBxstdcmap(1)\fP for details.
  987. .SH EXAMPLES
  988. To animate a set of images of a cockatoo, use:
  989. .PP
  990. X     animate cockatoo.*
  991. .PP
  992. To animate a cockatoo image sequence while using the Standard Colormap
  993. "best", use:
  994. .PP
  995. X     xstdcmap -best
  996. X     animate -map best cockatoo.*
  997. .PP
  998. To animate an image of a cockatoo without a border centered on a
  999. backdrop, use:
  1000. .PP
  1001. X     animate +borderwidth -backdrop cockatoo.*
  1002. .SH OPTIONS
  1003. .TP 5
  1004. .B "-backdrop"
  1005. display the image centered on a backdrop.
  1006. X
  1007. This backdrop covers the entire workstation screen and is useful for
  1008. hiding other X window activity while viewing the image sequence.   The color
  1009. of the backdrop is specified as the background color.  Refer to \fBX
  1010. RESOURCES\fP for details.
  1011. .TP 5
  1012. .B "-clip \fI<width>x<height>{\+-}<x offset>{\+-}<y offset>\fP"
  1013. preferred size and location of the clipped image.  See \fBX(1)\fP for details
  1014. about the geometry specification.
  1015. X
  1016. Use clipping to apply image processing options, or display, only a
  1017. particular area of an image.
  1018. X
  1019. The equivalent X resource for this option is \fBclipGeometry\fP
  1020. (class \fBClipGeometry\fP).  See \fBX RESOURCES\fP for details.
  1021. .TP 5
  1022. .B "-colormap \fItype\fP"
  1023. the type of colormap: \fIShared\fP or \fIPrivate\fP.
  1024. X
  1025. This option only applies when the default X server visual is
  1026. \fIPseudoColor\fP or \fIGrayScale\fP.  Refer to \fB-visual\fP for more
  1027. details.  By default, a shared colormap is allocated.  The image shares
  1028. colors with other X clients.  Some image colors could be approximated,
  1029. therefore your image may look very different than intended.  Choose
  1030. \fIPrivate\fP and the image colors appear exactly as they are
  1031. defined.  However, other clients may go "technicolor" when the image
  1032. colormap is installed.
  1033. .TP 5
  1034. .B "-colors \fIvalue\fP"
  1035. preferred number of colors in the image.
  1036. X
  1037. The actual number of colors in the image may be less than your request,
  1038. but never more.  Note, this is a color reduction option.  Images with
  1039. less unique colors than specified with this option will remain unchanged.
  1040. Refer to \fBQuantize(9)\fP for more details.
  1041. X
  1042. Note, options \fB-dither\fP, \fB-colorspace\fP, and \fB-treedepth\fP affect
  1043. the color reduction algorithm.
  1044. .TP 5
  1045. .B "-colorspace \fIvalue\fP"
  1046. the type of colorspace: \fIGRAY\fP, \fIRGB\fP, \fIXYZ\fP, \fIYIQ\fP, or
  1047. \fIYUV\fP.
  1048. Color reduction, by default, takes place in the RGB color space.
  1049. Empirical evidence suggests that distances in color spaces such as YUV
  1050. or YIQ correspond to perceptual color differences more closely
  1051. than do distances in RGB space.  These color spaces may give better
  1052. results when color reducing an image.  Refer to \fBQuantize(9)\fP for
  1053. more details.
  1054. X
  1055. The \fB-colors\fP or \fB-monochrome\fP option is required for this option
  1056. to take effect.
  1057. .TP 5
  1058. .B "-delay \fImilliseconds\fP"
  1059. display the next image after pausing.
  1060. X
  1061. This option is useful for regulating the display of the sequence of
  1062. images.  \fImilliseconds\fP milliseconds must expire before the display of
  1063. the next image.  The default is to display each image without delay.
  1064. .TP 5
  1065. .B "-density \fI<width>x<height>
  1066. vertical and horizonal density of the image.
  1067. X
  1068. This option specifies an image density whose interpretation changes
  1069. with the type of image.  The default is 72 dots per inch in the
  1070. horizonal and vertical direction for Postscript.  Text files default to
  1071. 80 characters in width and 60 lines in height.  Use this option to
  1072. alter the default density.
  1073. .TP 5
  1074. .B "-display \fIhost:display[.screen]\fP"
  1075. specifies the X server to contact; see \fBX(1)\fP.
  1076. .TP 5
  1077. .B "-dither"
  1078. apply Floyd/Steinberg error diffusion to the image.
  1079. X
  1080. The basic strategy of dithering is to trade intensity resolution for
  1081. spatial resolution by averaging the intensities of several neighboring
  1082. pixels.  Images which suffer from severe contouring when reducing colors
  1083. can be improved with this option.
  1084. X
  1085. The \fB-colors\fP or \fB-monochrome\fP option is required for this option
  1086. to take effect.
  1087. .TP 5
  1088. .B "-gamma \fIvalue\fP"
  1089. level of gamma correction.
  1090. X
  1091. The same color image displayed on two different workstations may look
  1092. different due to differences in the display monitor.  Use gamma
  1093. correction to adjust for this color difference.  Reasonable values
  1094. extend from 0.8 to 2.3.
  1095. .TP 5
  1096. .B "-geometry \fI<width>x<height>{\+-}<x offset>{\+-}<y offset>\fP"
  1097. preferred size and location of the image window.  See \fBX(1)\fP for details
  1098. about the geometry specification.  By default, the window size is the image
  1099. size and the location is choosen by you when it is mapped.
  1100. X
  1101. If the specified image size is smaller than the actual image size, the
  1102. image is first reduced to an integral of the specified image size with
  1103. an antialias digital filter.  The image is then scaled to the exact
  1104. specified image size with pixel replication.  If the specified image
  1105. size is greater than the actual image size, the image is first enlarged
  1106. to an integral of the specified image size with bilinear
  1107. interpolation.  The image is then scaled to the exact specified image
  1108. size with pixel replication.
  1109. X
  1110. When displaying an image on an X server, \fI<x offset>\fP and
  1111. \fI<y offset>\fP is relative to the root window.
  1112. X
  1113. The equivalent X resource for this option is \fBimageGeometry\fP
  1114. (class \fBImageGeometry\fP).  See \fBX RESOURCES\fP for details.
  1115. .TP 5
  1116. .B "-map \fItype\fP"
  1117. animate images using this Standard Colormap type.
  1118. X
  1119. Choose from these Standard Colormap types:
  1120. X
  1121. X    default
  1122. X    best
  1123. X    red
  1124. X    green
  1125. X    blue
  1126. X    gray
  1127. X
  1128. The X server must support the Standard Colormap you choose, otherwise an
  1129. error occurs.  See \fBxstdcmap(1)\fP for one way of creating Standard Colormaps.
  1130. .TP 5
  1131. .B "-monochrome"
  1132. transform the image to black and white.
  1133. X
  1134. Monochrome images can benefit from error diffusion.  Use \fB-dither\fP with
  1135. this option to diffuse the error.
  1136. .TP 5
  1137. .B "-reflect"
  1138. create a "mirror image" by reflecting the image scanlines.
  1139. .TP 5
  1140. .B "-rotate \fIdegrees\fP"
  1141. apply Paeth image rotation to the image.
  1142. .TP 5
  1143. .B "-scale \fI<width factor>x<height factor>\fP"
  1144. preferred size factors of the image.
  1145. X
  1146. This option behaves like \fB-geometry\fP except the width and height values
  1147. are relative instead of absolute.  The image size is multiplied by the
  1148. width and height factors to obtain the final image dimensions.  If only
  1149. one factor is specified, both the width and height factors assume the
  1150. value.
  1151. X
  1152. Factors may be fractional.  For example, a factor of 1.5 will increase the
  1153. image size by one and one-half.
  1154. X
  1155. The equivalent X resource for this option is \fBscaleGeometry\fP
  1156. (class \fBScaleGeometry\fP).  See \fBX RESOURCES\fP for details.
  1157. .TP 5
  1158. .B "-treedepth \fIvalue\fP"
  1159. Normally, this integer value is zero or one.  A zero or one tells
  1160. \fIAnimate\fP to choose a optimal tree depth for the color reduction
  1161. algorithm.
  1162. X
  1163. An optimal depth generally allows the best representation of the source
  1164. image with the fastest computational speed and the least amount of
  1165. memory.  However, the default depth is inappropriate for some images.
  1166. To assure the best representation, try values between 2 and 8 for this
  1167. parameter.  Refer to \fBQuantize(9)\fP for more details.
  1168. X
  1169. The \fB-colors\fP or \fB-monochrome\fP option is required for this option
  1170. to take effect.
  1171. .TP 5
  1172. .B "-visual \fItype\fP"
  1173. animate images using this visual type.
  1174. X
  1175. Choose from these visual classes:
  1176. X
  1177. X    StaticGray
  1178. X    GrayScale
  1179. X    StaticColor
  1180. X    PseudoColor
  1181. X    TrueColor
  1182. X    DirectColor
  1183. X    default
  1184. X    \fIvisual id\fP
  1185. X
  1186. The X server must support the visual you choose, otherwise an error occurs.
  1187. If a visual is not specified, the visual class that can display the most
  1188. simultaneous colors on the default screen is choosen.
  1189. .PP
  1190. In addition to those listed above, you can specify these standard X
  1191. resources as command line options:  \fB-background\fP,
  1192. \fB-bordercolor\fP, \fB-borderwidth\fP,  \fB-font\fP,
  1193. \fB-foreground\fP, \fB-iconGeometry\fP, \fB-iconic\fP, \fB-name\fP, or
  1194. \fB-title\fP.  See \fBX RESOURCES\fP for details.
  1195. .PP
  1196. Any option you specify on the command line remains in effect until it is
  1197. explicitly changed by specifying the option again with a different effect.
  1198. For example, to animate two images, the first with 32 colors and the
  1199. second with only 16 colors, use:
  1200. .PP
  1201. X     animate -colors 32 cockatoo.1 -colors 16 cockatoo.2
  1202. .PP
  1203. Change \fI-\fP to \fI\+\fP in any option above to reverse its effect.
  1204. For example, specify \fB\+dither\fP to not apply error diffusion to an image.
  1205. .PP
  1206. \fIfile\fP specifies the image filename.  By default, the image format
  1207. is determined by its magic number. To specify a particular image format, precede
  1208. the filename with an image format name and a colon (i.e.
  1209. mtv:image) or specify the image type as the filename suffix (i.e. image.mtv).
  1210. See \fBCONVERT(1)\fP for a list of valid image formats.  Specify \fIfile\fP
  1211. as \fI-\fP for standard input or output.  If \fIfile\fP has the
  1212. extension \fB.Z\fP, the file is decoded with \fIuncompress\fP.
  1213. .PP
  1214. Image filenames may appear in any order on the command line if the image
  1215. format is \fIMIFF\fI (refer to \fBMIFF(5)\fI) and the \fIscene\fP keyword is
  1216. specified in the image.  Otherwise the images will display in the order
  1217. they appear on the command line.
  1218. .SH BUTTONS
  1219. .TP 5
  1220. .B "1"
  1221. Press and drag to select a command from a pop-up menu.  Choose from
  1222. these commands:
  1223. X
  1224. X    Play
  1225. X    Step
  1226. X    Repeat
  1227. X    Auto Reverse
  1228. X    Slower
  1229. X    Faster
  1230. X    Forward
  1231. X    Reverse
  1232. X    Image Info
  1233. X    Quit
  1234. .SH KEYBOARD ACCELERATORS
  1235. .TP 5
  1236. .B "p"
  1237. Press to animate the sequence of images.
  1238. .TP 5
  1239. .B "s"
  1240. Press to display the next image in the sequence.
  1241. .TP 5
  1242. .B "."
  1243. Press to continually display the sequence of images.
  1244. .TP 5
  1245. .B "a"
  1246. Press to automatically reverse the sequence of images.
  1247. .TP 5
  1248. .B "<"
  1249. Press to slow the display of the images.  Refer to \fB-delay\fP for more
  1250. information.
  1251. .TP 5
  1252. .B ">"
  1253. Press to speed-up the display of the images.  Refer to \fB-delay\fP for more
  1254. information.
  1255. .TP 5
  1256. .B "f"
  1257. Press to animate in the forward direction.
  1258. .TP 5
  1259. .B "r"
  1260. Press to animate in the reverse direction.
  1261. .TP 5
  1262. .B "i"
  1263. Press to display information about the image.  Press any key or button
  1264. to erase the information.
  1265. X
  1266. This information is printed: image name;  image size; and the total
  1267. number of unique colors in the image.
  1268. .TP 5
  1269. .B "q"
  1270. Press to discard all images and exit program.
  1271. .SH "X RESOURCES"
  1272. \fIAnimate\fP options can appear on the command line or in your X
  1273. resource file.  Options on the command line supersede values specified
  1274. in your X resource file.  See \fBX(1)\fP for more information on X
  1275. resources.
  1276. X
  1277. All \fIanimate\fP options have a corresponding X resource.  In addition,
  1278. the \fIanimate\fP program uses the following X resources:
  1279. .TP 5
  1280. .B background (\fPclass\fB Background)
  1281. Specifies the preferred color to use for the image window background.  The
  1282. default is black.
  1283. .TP 5
  1284. .B borderColor (\fPclass\fB BorderColor)
  1285. Specifies the preferred color to use for the image window border.  The
  1286. default is white.
  1287. .TP 5
  1288. .B borderWidth (\fPclass\fB BorderWidth)
  1289. Specifies the width in pixels of the image window border.  The default is 2.
  1290. .TP 5
  1291. .B font (\fPclass\fB Font)
  1292. Specifies the name of the preferred font to use when displaying text
  1293. within the image window.  The default is \fI/g9x15\fP, \fIfixed\fP, or
  1294. \fI/g6x13\fP determined by the image window size.
  1295. .TP 5
  1296. .B foreground (\fPclass\fB Foreground)
  1297. Specifies the preferred color to use for text within the image window.  The
  1298. default is white.
  1299. .TP 5
  1300. .B iconGeometry (\fPclass\fB IconGeometry)
  1301. Specifies the preferred size and position of the application when
  1302. iconified.  It is not necessarily obeyed by all window managers.
  1303. .TP 5
  1304. .B iconic (\fPclass\fB Iconic)
  1305. This resource indicates that you would prefer that the application's
  1306. windows initially not be visible as if the windows had be immediately
  1307. iconified by you.  Window managers may choose not to honor the
  1308. application's request.
  1309. .TP 5
  1310. .B name (\fPclass\fB Name)
  1311. This resource specifies the name under which resources for the
  1312. application should be found.  This resource is useful in shell aliases to
  1313. distinguish between invocations of an application, without resorting to
  1314. creating links to alter the executable file name.  The default is the
  1315. application name.
  1316. .TP 5
  1317. .B title (\fPclass\fB Title)
  1318. This resource specifies the title to be used for the image window.  This
  1319. information is sometimes used by a window manager to provide some sort
  1320. of header identifying the window.  The default is the image file name.
  1321. .SH ENVIRONMENT
  1322. .TP 5
  1323. .B DISPLAY
  1324. To get the default host, display number, and screen.
  1325. .SH SEE ALSO
  1326. display(1), import(1), XtoPS(1), mogrify(1), convert(1), Quantize(9), MIFF(5),
  1327. XX(1), xstdcmap(1), compress(1),
  1328. MIFF(5)
  1329. .SH COPYRIGHT
  1330. Copyright 1992 E. I. du Pont de Nemours & Company
  1331. .PP
  1332. Permission to use, copy, modify, distribute, and sell this software and
  1333. its documentation for any purpose is hereby granted without fee,
  1334. provided that the above copyright notice appear in all copies and that
  1335. both that copyright notice and this permission notice appear in
  1336. supporting documentation, and that the name of E. I. du Pont de Nemours
  1337. & Company not be used in advertising or publicity pertaining to
  1338. distribution of the software without specific, written prior
  1339. permission.  E. I. du Pont de Nemours & Company makes no representations
  1340. about the suitability of this software for any purpose.  It is provided
  1341. "as is" without express or implied warranty.
  1342. .PP
  1343. E. I. du Pont de Nemours & Company disclaims all warranties with regard
  1344. to this software, including all implied warranties of merchantability
  1345. and fitness, in no event shall E. I. du Pont de Nemours & Company be
  1346. liable for any special, indirect or consequential damages or any
  1347. damages whatsoever resulting from loss of use, data or profits, whether
  1348. in an action of contract, negligence or other tortious action, arising
  1349. out of or in connection with the use or performance of this software.
  1350. .SH ACKNOWLEDGEMENTS
  1351. The MIT X Consortium for making network transparent graphics a reality.
  1352. .PP
  1353. Michael Halle, Spatial Imaging Group at MIT, for the initial
  1354. implementation of Alan Paeth's image rotation algorithm.
  1355. .PP
  1356. David Pensak, E. I. du Pont de Nemours & Company, for providing a
  1357. computing environment that made this program possible.
  1358. .PP
  1359. Paul Raveling, USC Information Sciences Institute, for the original
  1360. idea of using space subdivision for the color reduction algorithm.
  1361. .SH AUTHORS
  1362. John Cristy, E.I. du Pont de Nemours & Company Incorporated
  1363. SHAR_EOF
  1364. chmod 0644 ImageMagick/animate.man ||
  1365. echo 'restore of ImageMagick/animate.man failed'
  1366. Wc_c="`wc -c < 'ImageMagick/animate.man'`"
  1367. test 15842 -eq "$Wc_c" ||
  1368.     echo 'ImageMagick/animate.man: original size 15842, current size' "$Wc_c"
  1369. rm -f _shar_wnt_.tmp
  1370. fi
  1371. # ============= ImageMagick/X.c ==============
  1372. if test -f 'ImageMagick/X.c' -a X"$1" != X"-c"; then
  1373.     echo 'x - skipping ImageMagick/X.c (File already exists)'
  1374.     rm -f _shar_wnt_.tmp
  1375. else
  1376. > _shar_wnt_.tmp
  1377. echo 'x - extracting ImageMagick/X.c (Text)'
  1378. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/X.c' &&
  1379. /*
  1380. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1381. %                                                                             %
  1382. %                                                                             %
  1383. %                                                                             %
  1384. %                                                                             %
  1385. %                                     X   X                                   %
  1386. %                                      X X                                    %
  1387. %                                       X                                     %
  1388. %                                      X X                                    %
  1389. %                                     X   X                                   %
  1390. %                                                                             %
  1391. %                          X11 Utility Routines for Display.                  %
  1392. %                                                                             %
  1393. %                                                                             %
  1394. %                                 Software Design                             %
  1395. %                                   John Cristy                               %
  1396. %                                    July 1992                                %
  1397. %                                                                             %
  1398. %                                                                             %
  1399. %  Copyright 1992 E. I. du Pont de Nemours & Company                          %
  1400. %                                                                             %
  1401. %  Permission to use, copy, modify, distribute, and sell this software and    %
  1402. %  its documentation for any purpose is hereby granted without fee,           %
  1403. %  provided that the above Copyright notice appear in all copies and that     %
  1404. %  both that Copyright notice and this permission notice appear in            %
  1405. %  supporting documentation, and that the name of E. I. du Pont de Nemours    %
  1406. %  & Company not be used in advertising or publicity pertaining to            %
  1407. %  distribution of the software without specific, written prior               %
  1408. %  permission.  E. I. du Pont de Nemours & Company makes no representations   %
  1409. %  about the suitability of this software for any purpose.  It is provided    %
  1410. %  "as is" without express or implied warranty.                               %
  1411. %                                                                             %
  1412. %  E. I. du Pont de Nemours & Company disclaims all warranties with regard    %
  1413. %  to this software, including all implied warranties of merchantability      %
  1414. %  and fitness, in no event shall E. I. du Pont de Nemours & Company be       %
  1415. %  liable for any special, indirect or consequential damages or any           %
  1416. %  damages whatsoever resulting from loss of use, data or profits, whether    %
  1417. %  in an action of contract, negligence or other tortious action, arising     %
  1418. %  out of or in connection with the use or performance of this software.      %
  1419. %                                                                             %
  1420. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1421. %
  1422. %
  1423. */
  1424. X
  1425. /*
  1426. X  Include declarations.
  1427. */
  1428. #include "display.h"
  1429. #include "image.h"
  1430. #include "X.h"
  1431. X
  1432. /*
  1433. X  State declarations.
  1434. */
  1435. #define ControlState  0x0001
  1436. #define DefaultState  0x0000
  1437. #define ExitState  0x0002
  1438. X
  1439. /*
  1440. X  External declarations.
  1441. */
  1442. extern char
  1443. X  *application_name;
  1444. X
  1445. extern void
  1446. X  Error _Declare((char *,char *));
  1447. X
  1448. /*
  1449. X  Forward declarations.
  1450. */
  1451. int
  1452. X  Latin1Compare _Declare((char *,char *));
  1453. X
  1454. static void
  1455. X  XMakeImageLSBFirst _Declare((XWindowInfo *,Image *, XImage *)),
  1456. X  XMakeImageMSBFirst _Declare((XWindowInfo *,Image *, XImage *));
  1457. X
  1458. /*
  1459. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1460. %                                                                             %
  1461. %                                                                             %
  1462. %                                                                             %
  1463. %   I s T r u e                                                               %
  1464. %                                                                             %
  1465. %                                                                             %
  1466. %                                                                             %
  1467. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1468. %
  1469. %  Function IsTrue returns True if the boolean is "true", "on", "yes" or "1".
  1470. %
  1471. %  The format of the IsTrue routine is:
  1472. %
  1473. %      option=IsTrue(boolean)
  1474. %
  1475. %  A description of each parameter follows:
  1476. %
  1477. %    o option: either True or False depending on the boolean parameter.
  1478. %
  1479. %    o boolean: Specifies a pointer to a character array.
  1480. %
  1481. %
  1482. */
  1483. unsigned int IsTrue(boolean)
  1484. char
  1485. X  *boolean;
  1486. {
  1487. X  if (boolean == (char *) NULL)
  1488. X    return(False);
  1489. X  if (Latin1Compare(boolean,"true") == 0)
  1490. X    return(True);
  1491. X  if (Latin1Compare(boolean,"on") == 0)
  1492. X    return(True);
  1493. X  if (Latin1Compare(boolean,"yes") == 0)
  1494. X    return(True);
  1495. X  if (Latin1Compare(boolean,"1") == 0)
  1496. X    return(True);
  1497. X  return(False);
  1498. }
  1499. X
  1500. /*
  1501. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1502. %                                                                             %
  1503. %                                                                             %
  1504. %                                                                             %
  1505. %   L a t i n 1 C o m p a r e                                                 %
  1506. %                                                                             %
  1507. %                                                                             %
  1508. %                                                                             %
  1509. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1510. %
  1511. %  Function Latin1Compare compares two null terminated Latin-1 strings,
  1512. %  ignoring case differences, and returns an integer greater than, equal
  1513. %  to, or less than 0, according to whether first is lexicographically
  1514. %  greater than, equal to, or less than second.  The two strings are
  1515. %  assumed to be encoded using ISO 8859-1.
  1516. %
  1517. %  The format of the Latin1Upper routine is:
  1518. %
  1519. %      Latin1Upper(first,second)
  1520. %
  1521. %  A description of each parameter follows:
  1522. %
  1523. %    o first: A pointer to the string to convert to Latin1 string.
  1524. %
  1525. %    o second: A pointer to the string to convert to Latin1 string.
  1526. %
  1527. %
  1528. */
  1529. int Latin1Compare(first,second)
  1530. char
  1531. X  *first,
  1532. X  *second;
  1533. {
  1534. X  register unsigned char
  1535. X   *p,
  1536. X   *q;
  1537. X  p=(unsigned char *) first;
  1538. X  q=(unsigned char *) second;
  1539. X  while ((*p != '\0') && (*q != '\0'))
  1540. X  {
  1541. X    register unsigned char
  1542. X      c,
  1543. X      d;
  1544. X
  1545. X    c=(*p); 
  1546. X    d=(*q); 
  1547. X    if (c != d)
  1548. X      {
  1549. X        /* 
  1550. X          Try lowercasing and try again.
  1551. X        */
  1552. X        if ((c >= XK_A) && (c <= XK_Z))
  1553. X          c+=(XK_a-XK_A);
  1554. X        else 
  1555. X          if ((c >= XK_Agrave) && (c <= XK_Odiaeresis))
  1556. X            c+=(XK_agrave-XK_Agrave);
  1557. X          else 
  1558. X            if ((c >= XK_Ooblique) && (c <= XK_Thorn))
  1559. X              c+=(XK_oslash-XK_Ooblique);
  1560. X        if ((d >= XK_A) && (d <= XK_Z))
  1561. X          d+=(XK_a-XK_A);
  1562. X        else
  1563. X          if ((d >= XK_Agrave) && (d <= XK_Odiaeresis))
  1564. X            d+=(XK_agrave-XK_Agrave);
  1565. X          else if ((d >= XK_Ooblique) && (d <= XK_Thorn))
  1566. X            d+=(XK_oslash-XK_Ooblique);
  1567. X        if (c != d)
  1568. X          return(((int) c)-((int) d));
  1569. X      }
  1570. X    p++;
  1571. X    q++;
  1572. X  }
  1573. X  return(((int) *p)-((int) *q));
  1574. }
  1575. X
  1576. /*
  1577. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1578. %                                                                             %
  1579. %                                                                             %
  1580. %                                                                             %
  1581. %   L a t i n 1 U p p e r                                                     %
  1582. %                                                                             %
  1583. %                                                                             %
  1584. %                                                                             %
  1585. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1586. %
  1587. %  Function Latin1Upper copies a null terminated string from src to dst
  1588. %  (including the null), changing all Latin-1 lowercase letters to
  1589. %  uppercase.  The string is assumed to be encoded using ISO 8859-1.
  1590. %
  1591. %  The format of the Latin1Upper routine is:
  1592. %
  1593. %      Latin1Upper(string)
  1594. %
  1595. %  A description of each parameter follows:
  1596. %
  1597. %    o string: A pointer to the string to convert to upper-case Latin1.
  1598. %
  1599. %
  1600. */
  1601. void Latin1Upper(string)
  1602. char
  1603. X  *string;
  1604. {
  1605. X  unsigned char
  1606. X    c;
  1607. X  c=(*string);
  1608. X  while (c != '\0')
  1609. X  {
  1610. X    if ((c >= XK_a) && (c <= XK_z))
  1611. X      *string=c-(XK_a-XK_A);
  1612. X    else
  1613. X      if ((c >= XK_agrave) && (c <= XK_odiaeresis))
  1614. X        *string=c-(XK_agrave-XK_Agrave);
  1615. X      else
  1616. X        if ((c >= XK_oslash) && (c <= XK_thorn))
  1617. X          *string=c-(XK_oslash-XK_Ooblique);
  1618. X    string++;
  1619. X    c=(*string);
  1620. X  }
  1621. }
  1622. X
  1623. /*
  1624. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1625. %                                                                             %
  1626. %                                                                             %
  1627. %                                                                             %
  1628. %  R e a d T E X T I m a g e                                                  %
  1629. %                                                                             %
  1630. %                                                                             %
  1631. %                                                                             %
  1632. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1633. %
  1634. %  Function ReadTEXTImage reads a text file and returns it as an image.  It
  1635. %  allocates the memory necessary for the new Image structure and returns a
  1636. %  pointer to the new image.
  1637. %
  1638. %  The format of the ReadTEXTImage routine is:
  1639. %
  1640. %      image=ReadTEXTImage(filename,server_name,font,density)
  1641. %
  1642. %  A description of each parameter follows:
  1643. %
  1644. %    o image:  Function ReadTEXTImage returns a pointer to the image after
  1645. %      reading. A null image is returned if there is a a memory shortage or if
  1646. %      the image cannot be read.
  1647. %
  1648. %    o filename: Specifies the name of the image to read.
  1649. %
  1650. %    o server_name: Specifies the name of the X server to read fonts from.
  1651. %
  1652. %    o font: Specifies the name of an X font to use for writing the text.
  1653. %
  1654. %    o density: Specifies the vertical and horizonal density of the image.
  1655. %
  1656. %
  1657. */
  1658. Image *ReadTEXTImage(filename,server_name,font,density)
  1659. char
  1660. X  *filename,
  1661. X  *server_name,
  1662. X  *font,
  1663. X  *density;
  1664. {
  1665. #define PageHeight  60
  1666. #define PageWidth  80
  1667. X
  1668. X  char
  1669. X    *resource_value,
  1670. X    *text_status,
  1671. X    text[2048];
  1672. X
  1673. X  Display
  1674. X    *display;
  1675. X
  1676. X  Image
  1677. X    *image;
  1678. X
  1679. X  int
  1680. X    status,
  1681. X    x,
  1682. X    y;
  1683. X
  1684. X  register int
  1685. X    i;
  1686. X
  1687. X  register RunlengthPacket
  1688. X    *p;
  1689. X
  1690. X  RunlengthPacket
  1691. X    background_color;
  1692. X
  1693. X  unsigned int
  1694. X    height,
  1695. X    width;
  1696. X
  1697. X  XAnnotateInfo
  1698. X    annotate_info;
  1699. X
  1700. X  XFontStruct
  1701. X    *font_info;
  1702. X
  1703. X  XPixelInfo
  1704. X    pixel_info;
  1705. X
  1706. X  XResourceInfo
  1707. X    resource_info;
  1708. X
  1709. X  XrmDatabase
  1710. X    resource_database,
  1711. X    server_database;
  1712. X
  1713. X  XStandardColormap
  1714. X    map_info;
  1715. X
  1716. X  XVisualInfo
  1717. X    *visual_info;
  1718. X
  1719. X  XWindowInfo
  1720. X    image_window;
  1721. X
  1722. X  /*
  1723. X    Allocate image structure.
  1724. X  */
  1725. X  image=AllocateImage("TEXT");
  1726. X  if (image == (Image *) NULL)
  1727. X    return((Image *) NULL);
  1728. X  /*
  1729. X    Open image file.
  1730. X  */
  1731. X  (void) strcpy(image->filename,filename);
  1732. X  OpenImage(image,"r");
  1733. X  if (image->file == (FILE *) NULL)
  1734. X    {
  1735. X      Warning("unable to open file",image->filename);
  1736. X      DestroyImage(image);
  1737. X      return((Image *) NULL);
  1738. X    }
  1739. X  /*
  1740. X    Open X server connection.
  1741. X  */
  1742. X  display=XOpenDisplay(server_name);
  1743. X  if (display == (Display *) NULL)
  1744. X    {
  1745. X      Warning("unable to connect to X server",XDisplayName(server_name));
  1746. X      return((Image *) NULL);
  1747. X    }
  1748. X  /*
  1749. X    Set our forgiving error handler.
  1750. X  */
  1751. X  XSetErrorHandler(XError);
  1752. X  /*
  1753. X    Initialize resource database.
  1754. X  */
  1755. X  XrmInitialize();
  1756. X  resource_database=XrmGetDatabase(display);
  1757. X  resource_value=XResourceManagerString(display);
  1758. X  if (resource_value == (char *) NULL)
  1759. X    resource_value="";
  1760. X  server_database=XrmGetStringDatabase(resource_value);
  1761. X  XrmMergeDatabases(server_database,&resource_database);
  1762. X  /*
  1763. X    Get user defaults from X resource database.
  1764. X  */
  1765. X  XGetResourceInfo(resource_database,application_name,&resource_info);
  1766. X  /*
  1767. X    Initialize visual info.
  1768. X  */
  1769. X  visual_info=XBestVisualInfo(display,"default",(char *) NULL,
  1770. X    (XStandardColormap *) NULL);
  1771. X  if (visual_info == (XVisualInfo *) NULL)
  1772. X    {
  1773. X      Warning("unable to get visual",resource_info.visual_type);
  1774. X      return((Image *) NULL);
  1775. X    }
  1776. X  /*
  1777. X    Determine background and foreground colors.
  1778. X  */
  1779. X  map_info.colormap=XDefaultColormap(display,visual_info->screen);
  1780. X  XGetPixelInfo(display,visual_info,&map_info,&resource_info,(Image *) NULL,
  1781. X    &pixel_info);
  1782. X  pixel_info.annotate_color=pixel_info.foreground_color;
  1783. X  pixel_info.annotate_index=1;
  1784. X  /*
  1785. X    Initialize font info.
  1786. X  */
  1787. X  if (font != (char *) NULL)
  1788. X    resource_info.font=font;
  1789. X  font_info=XBestFont(display,&resource_info,(char *) NULL,~0);
  1790. X  if (font_info == (XFontStruct *) NULL)
  1791. X    {
  1792. X      Warning("unable to load font",resource_info.font);
  1793. X      return((Image *) NULL);
  1794. X    }
  1795. X  /*
  1796. X    Window superclass.
  1797. X  */
  1798. X  image_window.id=XRootWindow(display,visual_info->screen);
  1799. X  image_window.screen=visual_info->screen;
  1800. X  image_window.depth=visual_info->depth;
  1801. X  image_window.visual_info=visual_info;
  1802. X  image_window.pixel_info=(&pixel_info);
  1803. X  image_window.font_info=font_info;
  1804. X  /*
  1805. X    Initialize Image structure.
  1806. X  */
  1807. X  width=PageWidth;
  1808. X  height=PageHeight;
  1809. X  if (density != (char *) NULL)
  1810. X    (void) XParseGeometry(density,&x,&y,&width,&height);
  1811. X  image->columns=width*font_info->max_bounds.width+4;
  1812. X  image->rows=height*
  1813. X    (font_info->max_bounds.ascent+font_info->max_bounds.descent)+4;
  1814. X  image->packets=image->columns*image->rows;
  1815. X  image->pixels=(RunlengthPacket *)
  1816. X    malloc((unsigned int) image->packets*sizeof(RunlengthPacket));
  1817. X  image->comments=(char *) malloc((strlen(image->filename)+2048)*sizeof(char));
  1818. X  if ((image->pixels == (RunlengthPacket *) NULL) ||
  1819. SHAR_EOF
  1820. true || echo 'restore of ImageMagick/X.c failed'
  1821. fi
  1822. echo 'End of  part 14'
  1823. echo 'File ImageMagick/X.c is continued in part 15'
  1824. echo 15 > _shar_seq_.tmp
  1825. exit 0
  1826. exit 0 # Just in case...
  1827.