home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume34 / imagemagick / part14 < prev    next >
Encoding:
Text File  |  1992-12-14  |  57.0 KB  |  1,824 lines

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