home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume20 / imagemgc / part32 < prev    next >
Encoding:
Text File  |  1993-07-13  |  50.3 KB  |  1,331 lines

  1. Newsgroups: comp.sources.x
  2. From: cristy@eplrx7.es.duPont.com (Cristy)
  3. Subject: v20i088:  imagemagic - X11 image processing and display, Part32/38
  4. Message-ID: <1993Jul14.232204.23200@sparky.sterling.com>
  5. X-Md4-Signature: f35ef75b7a90aaa02d6f003481089e02
  6. Sender: chris@sparky.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Wed, 14 Jul 1993 23:22:04 GMT
  9. Approved: chris@sterling.com
  10.  
  11. Submitted-by: cristy@eplrx7.es.duPont.com (Cristy)
  12. Posting-number: Volume 20, Issue 88
  13. Archive-name: imagemagic/part32
  14. Environment: X11
  15. Supersedes: imagemagic: Volume 13, Issue 17-37
  16.  
  17. #!/bin/sh
  18. # this is magick.32 (part 32 of ImageMagick)
  19. # do not concatenate these parts, unpack them in order with /bin/sh
  20. # file ImageMagick/montage.c continued
  21. #
  22. if test ! -r _shar_seq_.tmp; then
  23.     echo 'Please unpack part 1 first!'
  24.     exit 1
  25. fi
  26. (read Scheck
  27.  if test "$Scheck" != 32; then
  28.     echo Please unpack part "$Scheck" next!
  29.     exit 1
  30.  else
  31.     exit 0
  32.  fi
  33. ) < _shar_seq_.tmp || exit 1
  34. if test ! -f _shar_wnt_.tmp; then
  35.     echo 'x - still skipping ImageMagick/montage.c'
  36. else
  37. echo 'x - continuing file ImageMagick/montage.c'
  38. sed 's/^X//' << 'SHAR_EOF' >> 'ImageMagick/montage.c' &&
  39. X                  resource_info.number_colors=atoi(argv[i]);
  40. X                }
  41. X              break;
  42. X            }
  43. X          if (strncmp("colorspace",option+1,7) == 0)
  44. X            {
  45. X              resource_info.colorspace=RGBColorspace;
  46. X              if (*option == '-')
  47. X                {
  48. X                  i++;
  49. X                  if (i == argc)
  50. X                    Error("missing type on -colorspace",(char *) NULL);
  51. X                  option=argv[i];
  52. X                  resource_info.colorspace=UndefinedColorspace;
  53. X                  if (Latin1Compare("gray",option) == 0)
  54. X                    resource_info.colorspace=GRAYColorspace;
  55. X                  if (Latin1Compare("rgb",option) == 0)
  56. X                    resource_info.colorspace=RGBColorspace;
  57. X                  if (Latin1Compare("xyz",option) == 0)
  58. X                    resource_info.colorspace=XYZColorspace;
  59. X                  if (Latin1Compare("ycbcr",option) == 0)
  60. X                    resource_info.colorspace=YCbCrColorspace;
  61. X                  if (Latin1Compare("yiq",option) == 0)
  62. X                    resource_info.colorspace=YIQColorspace;
  63. X                  if (Latin1Compare("yuv",option) == 0)
  64. X                    resource_info.colorspace=YUVColorspace;
  65. X                  if (resource_info.colorspace == UndefinedColorspace)
  66. X                    Error("invalid colorspace type on -colorspace",option);
  67. X                }
  68. X              break;
  69. X            }
  70. X          if (strncmp("compress",option+1,5) == 0)
  71. X            {
  72. X              compression=NoCompression;
  73. X              if (*option == '-')
  74. X                {
  75. X                  i++;
  76. X                  if (i == argc)
  77. X                    Error("missing type on -compress",(char *) NULL);
  78. X                  option=argv[i];
  79. X                  if (Latin1Compare("runlengthencoded",option) == 0)
  80. X                    compression=RunlengthEncodedCompression;
  81. X                  else
  82. X                    if (Latin1Compare("qencoded",option) == 0)
  83. X                      compression=QEncodedCompression;
  84. X                    else
  85. X                      Error("invalid compression type on -compress",option);
  86. X                }
  87. X              break;
  88. X            }
  89. X          if (strncmp("compose",option+1,5) == 0)
  90. X            {
  91. X              compose=ReplaceCompositeOp;
  92. X              if (*option == '-')
  93. X                {
  94. X                  i++;
  95. X                  if (i == argc)
  96. X                    Error("missing type on -compose",(char *) NULL);
  97. X                  option=argv[i];
  98. X                  compose=UndefinedCompositeOp;
  99. X                  if (Latin1Compare("over",option) == 0)
  100. X                    compose=OverCompositeOp;
  101. X                  if (Latin1Compare("in",option) == 0)
  102. X                    compose=InCompositeOp;
  103. X                  if (Latin1Compare("out",option) == 0)
  104. X                    compose=OutCompositeOp;
  105. X                  if (Latin1Compare("atop",option) == 0)
  106. X                    compose=AtopCompositeOp;
  107. X                  if (Latin1Compare("xor",option) == 0)
  108. X                    compose=XorCompositeOp;
  109. X                  if (Latin1Compare("plus",option) == 0)
  110. X                    compose=PlusCompositeOp;
  111. X                  if (Latin1Compare("minus",option) == 0)
  112. X                    compose=MinusCompositeOp;
  113. X                  if (Latin1Compare("add",option) == 0)
  114. X                    compose=AddCompositeOp;
  115. X                  if (Latin1Compare("subtract",option) == 0)
  116. X                    compose=SubtractCompositeOp;
  117. X                  if (Latin1Compare("difference",option) == 0)
  118. X                    compose=DifferenceCompositeOp;
  119. X                  if (Latin1Compare("replace",option) == 0)
  120. X                    compose=ReplaceCompositeOp;
  121. X                  if (compose == UndefinedCompositeOp)
  122. X                    Error("invalid compose type on -compose",option);
  123. X                }
  124. X              break;
  125. X            }
  126. X          Error("unrecognized option",option);
  127. X          break;
  128. X        }
  129. X        case 'd':
  130. X        {
  131. X          if (strncmp("density",option+1,3) == 0)
  132. X            {
  133. X              density=(char *) NULL;
  134. X              if (*option == '-')
  135. X                {
  136. X                  i++;
  137. X                  if (i == argc)
  138. X                    Error("missing geometry on -density",(char *) NULL);
  139. X                  density=argv[i];
  140. X                }
  141. X              break;
  142. X            }
  143. X          if (strncmp("display",option+1,3) == 0)
  144. X            {
  145. X              resource_info.server_name=(char *) NULL;
  146. X              if (*option == '-')
  147. X                {
  148. X                  i++;
  149. X                  if (i == argc)
  150. X                    Error("missing server name on -display",(char *) NULL);
  151. X                  resource_info.server_name=argv[i];
  152. X                }
  153. X              break;
  154. X            }
  155. X          if (strncmp("dither",option+1,3) == 0)
  156. X            {
  157. X              resource_info.dither=(*option == '-');
  158. X              break;
  159. X            }
  160. X          Error("unrecognized option",option);
  161. X          break;
  162. X        }
  163. X        case 'f':
  164. X        {
  165. X          if (strncmp("font",option+1,3) == 0)
  166. X            {
  167. X              resource_info.font=(char *) NULL;
  168. X              if (*option == '-')
  169. X                {
  170. X                  i++;
  171. X                  if (i == argc)
  172. X                    Error("missing font name on -font",(char *) NULL);
  173. X                  resource_info.font=argv[i];
  174. X                }
  175. X              break;
  176. X            }
  177. X          if (strncmp("foreground",option+1,3) == 0)
  178. X            {
  179. X              resource_info.foreground_color=(char *) NULL;
  180. X              if (*option == '-')
  181. X                {
  182. X                  i++;
  183. X                  if (i == argc)
  184. X                    Error("missing foreground on -foreground",(char *) NULL);
  185. X                  resource_info.foreground_color=argv[i];
  186. X                }
  187. X              break;
  188. X            }
  189. X          if (strncmp("frame",option+1,2) == 0)
  190. X            {
  191. X              frame=(*option == '-');
  192. X              break;
  193. X            }
  194. X          Error("unrecognized option",option);
  195. X          break;
  196. X        }
  197. X        case 'g':
  198. X        {
  199. X          if (strncmp("gamma",option+1,2) == 0)
  200. X            {
  201. X              gamma=0.0;
  202. X              if (*option == '-')
  203. X                {
  204. X                  i++;
  205. X                  if ((i == argc) || !sscanf(argv[i],"%f",(float *) &x))
  206. X                    Error("missing gamma on -gamma",(char *) NULL);
  207. X                  gamma=atof(argv[i]);
  208. X                }
  209. X              break;
  210. X            }
  211. X          if (strncmp("geometry",option+1,2) == 0)
  212. X            {
  213. X              resource_info.image_geometry=(char *) NULL;
  214. X              if (*option == '-')
  215. X                {
  216. X                  i++;
  217. X                  if (i == argc)
  218. X                    Error("missing geometry on -geometry",(char *) NULL);
  219. X                  resource_info.image_geometry=argv[i];
  220. X                }
  221. X              break;
  222. X            }
  223. X          if (strncmp("gravity",option+1,2) == 0)
  224. X            {
  225. X              resource_info.gravity=CenterGravity;
  226. X              if (*option == '-')
  227. X                {
  228. X                  i++;
  229. X                  if (i == argc)
  230. X                    Error("missing type on -gravity",(char *) NULL);
  231. X                  option=argv[i];
  232. X                  resource_info.gravity=(-1);
  233. X                  if (Latin1Compare("Forget",option) == 0)
  234. X                    resource_info.gravity=ForgetGravity;
  235. X                  if (Latin1Compare("NorthWest",option) == 0)
  236. X                    resource_info.gravity=NorthWestGravity;
  237. X                  if (Latin1Compare("North",option) == 0)
  238. X                    resource_info.gravity=NorthGravity;
  239. X                  if (Latin1Compare("NorthEast",option) == 0)
  240. X                    resource_info.gravity=NorthEastGravity;
  241. X                  if (Latin1Compare("West",option) == 0)
  242. X                    resource_info.gravity=WestGravity;
  243. X                  if (Latin1Compare("Center",option) == 0)
  244. X                    resource_info.gravity=CenterGravity;
  245. X                  if (Latin1Compare("East",option) == 0)
  246. X                    resource_info.gravity=EastGravity;
  247. X                  if (Latin1Compare("SouthWest",option) == 0)
  248. X                    resource_info.gravity=SouthWestGravity;
  249. X                  if (Latin1Compare("South",option) == 0)
  250. X                    resource_info.gravity=SouthGravity;
  251. X                  if (Latin1Compare("SouthEast",option) == 0)
  252. X                    resource_info.gravity=SouthEastGravity;
  253. X                  if (Latin1Compare("Static",option) == 0)
  254. X                    resource_info.gravity=StaticGravity;
  255. X                  if (resource_info.gravity == (-1))
  256. X                    Error("invalid gravity type on -gravity",option);
  257. X                }
  258. X              break;
  259. X            }
  260. X          Error("unrecognized option",option);
  261. X          break;
  262. X        }
  263. X        case 'h':
  264. X        {
  265. X          if (strncmp("help",option+1,2) == 0)
  266. X            {
  267. X              Usage();
  268. X              break;
  269. X            }
  270. X          if (strncmp("highlight",option+1,2) == 0)
  271. X            {
  272. X              resource_info.highlight_color=(char *) NULL;
  273. X              if (*option == '-')
  274. X                {
  275. X                  i++;
  276. X                  if (i == argc)
  277. X                    Error("missing color on -highlight",(char *) NULL);
  278. X                  resource_info.highlight_color=argv[i];
  279. X                }
  280. X              break;
  281. X            }
  282. X          Error("unrecognized option",option);
  283. X          break;
  284. X        }
  285. X        case 'i':
  286. X        {
  287. X          if (strncmp("interlace",option+1,3) == 0)
  288. X            {
  289. X              interlace=NoneInterlace;
  290. X              if (*option == '-')
  291. X                {
  292. X                  i++;
  293. X                  if (i == argc)
  294. X                    Error("missing type on -interlace",(char *) NULL);
  295. X                  option=argv[i];
  296. X                  interlace=UndefinedInterlace;
  297. X                  if (Latin1Compare("none",option) == 0)
  298. X                    interlace=NoneInterlace;
  299. X                  if (Latin1Compare("line",option) == 0)
  300. X                    interlace=LineInterlace;
  301. X                  if (Latin1Compare("plane",option) == 0)
  302. X                    interlace=PlaneInterlace;
  303. X                  if (interlace == UndefinedInterlace)
  304. X                    Error("invalid interlace type on -interlace",option);
  305. X                }
  306. X              break;
  307. X            }
  308. X          Error("unrecognized option",option);
  309. X          break;
  310. X        }
  311. X        case 'm':
  312. X        {
  313. X          resource_info.monochrome=(*option == '-');
  314. X          break;
  315. X        }
  316. X        case 'p':
  317. X        {
  318. X          if (strncmp("page",option+1,2) == 0)
  319. X            {
  320. X              page_geometry=(char *) NULL;
  321. X              if (*option == '-')
  322. X                {
  323. X                  i++;
  324. X                  if (i == argc)
  325. X                    Error("missing page geometry on -page",(char *) NULL);
  326. X                  page_geometry=argv[i];
  327. X                }
  328. X              break;
  329. X            }
  330. X          Error("unrecognized option",option);
  331. X          break;
  332. X        }
  333. X        case 'q':
  334. X        {
  335. X          i++;
  336. X          if ((i == argc) || !sscanf(argv[i],"%d",&x))
  337. X            Error("missing quality on -quality",(char *) NULL);
  338. X          quality=atoi(argv[i]);
  339. X          break;
  340. X        }
  341. X        case 'r':
  342. X        {
  343. X          degrees=0;
  344. X          if (*option == '-')
  345. X            {
  346. X              i++;
  347. X              if ((i == argc) || !sscanf(argv[i],"%d",&x))
  348. X                Error("missing degrees on -rotate",(char *) NULL);
  349. X              degrees=atoi(argv[i]);
  350. X            }
  351. X          break;
  352. X        }
  353. X        case 't':
  354. X        {
  355. X          if (strncmp("tiles_per_row",option+1,3) == 0)
  356. X            {
  357. X              tiles_per_row=0;
  358. X              if (*option == '-')
  359. X                {
  360. X                  i++;
  361. X                  if ((i == argc) || !sscanf(argv[i],"%d",&x))
  362. X                    Error("missing value on -tiles_per_row",(char *) NULL);
  363. X                  tiles_per_row=atoi(argv[i]);
  364. X                }
  365. X              break;
  366. X            }
  367. X          if (strncmp("title",option+1,3) == 0)
  368. X            {
  369. X              resource_info.title=(char *) NULL;
  370. X              if (*option == '-')
  371. X                {
  372. X                  i++;
  373. X                  if (i == argc)
  374. X                    Error("missing title on -title",(char *) NULL);
  375. X                  resource_info.title=argv[i];
  376. X                }
  377. X              break;
  378. X            }
  379. X          if (strncmp("treedepth",option+1,2) == 0)
  380. X            {
  381. X              resource_info.tree_depth=0;
  382. X              if (*option == '-')
  383. X                {
  384. X                  i++;
  385. X                  if ((i == argc) || !sscanf(argv[i],"%d",&x))
  386. X                    Error("missing depth on -treedepth",(char *) NULL);
  387. X                  resource_info.tree_depth=atoi(argv[i]);
  388. X                }
  389. X              break;
  390. X            }
  391. X          Error("unrecognized option",option);
  392. X          break;
  393. X        }
  394. X        case 'v':
  395. X        {
  396. X          verbose=(*option == '-');
  397. X          break;
  398. X        }
  399. X        default:
  400. X        {
  401. X          Error("unrecognized option",option);
  402. X          break;
  403. X        }
  404. X      }
  405. X    else
  406. X      {
  407. X        char
  408. X          geometry[2048];
  409. X
  410. X        Image
  411. X          *image,
  412. X          info_image;
  413. X
  414. X        RectangleInfo
  415. X          tile_info;
  416. X
  417. X        unsigned int
  418. X          scale_factor;
  419. X
  420. X        /*
  421. X          Option is a file name: begin by reading image from specified file.
  422. X        */
  423. X        start_time=time((time_t *) NULL);
  424. X        GetImageInfo(&image_info);
  425. X        (void) strcpy(image_info.filename,option);
  426. X        image_info.server_name=resource_info.server_name;
  427. X        image_info.font=resource_info.font;
  428. X        image_info.geometry=resource_info.image_geometry;
  429. X        image_info.page=page_geometry;
  430. X        image_info.density=density;
  431. X        image_info.border_color=resource_info.border_color;
  432. X        image_info.interlace=interlace;
  433. X        image_info.monochrome=resource_info.monochrome;
  434. X        image_info.quality=quality;
  435. X        image_info.verbose=verbose;
  436. X        image=ReadImage(&image_info);
  437. X        if (image == (Image *) NULL)
  438. X          if (*option == '-')
  439. X            break;
  440. X          else
  441. X            continue;
  442. X        do
  443. X        {
  444. X          if (image->scene == 0)
  445. X            image->scene=image_number;
  446. X          info_image=(*image);
  447. X          /*
  448. X            Allocate and initialize image label.
  449. X          */
  450. X          image->label=(char *)
  451. X            malloc(((strlen(image->filename)+2048)*sizeof(char)));
  452. X          if (image->label == (char *) NULL)
  453. X            Error("unable to montage images","memory allocation failed");
  454. X          (void) sprintf(image->label,"%s  %ux%u",image->filename,
  455. X            image->columns,image->rows);
  456. X          /*
  457. X            Tile size maintains the aspect ratio of the image.
  458. X          */
  459. X          tile_info.width=256;
  460. X          tile_info.height=256;
  461. X          if (resource_info.image_geometry != (char *) NULL)
  462. X            {
  463. X              XParseGeometry(resource_info.image_geometry,
  464. X                &tile_info.x,&tile_info.y,&tile_info.width,&tile_info.height);
  465. X              if ((tile_info.width == 0) || (tile_info.height == 0))
  466. X                Error("invalid image geometry",resource_info.image_geometry);
  467. X            }
  468. X          if (aspect_ratio)
  469. X            {
  470. X              /*
  471. X                Respect aspect ratio of the image.
  472. X              */
  473. X              scale_factor=UpShift(tile_info.width)/image->columns;
  474. X              if (scale_factor > (UpShift(tile_info.height)/image->rows))
  475. X                scale_factor=UpShift(tile_info.height)/image->rows;
  476. X              tile_info.width=DownShift(image->columns*scale_factor);
  477. X              tile_info.height=DownShift(image->rows*scale_factor);
  478. X            }
  479. X          (void) sprintf(geometry,"%ux%u",tile_info.width,tile_info.height);
  480. X          TransformImage(&image,clip_geometry,geometry,(char *) NULL);
  481. X          if ((degrees % 360) != 0)
  482. X            {
  483. X              Image
  484. X                *rotated_image;
  485. X
  486. X              /*
  487. X                Rotate image.
  488. X              */
  489. X              rotated_image=RotateImage(image,(double) degrees,False);
  490. X              if (rotated_image != (Image *) NULL)
  491. X                {
  492. X                  DestroyImage(image);
  493. X                  image=rotated_image;
  494. X                }
  495. X            }
  496. X          if (gamma > 0.0)
  497. X            GammaImage(image,gamma);
  498. X          if (verbose)
  499. X            {
  500. X              /*
  501. X                Display detailed info about the image.
  502. X              */
  503. X              (void) fprintf(stderr,"[%u] %s",
  504. X                image->scene == 0 ? image_number : image->scene,
  505. X                image->filename);
  506. X              (void) fprintf(stderr," %ux%u",info_image.columns,
  507. X                info_image.rows);
  508. X              if ((info_image.columns != image->columns) ||
  509. X                  (info_image.rows != image->rows))
  510. X                (void) fprintf(stderr,"=>%ux%u",image->columns,image->rows);
  511. X              if (image->class == DirectClass)
  512. X                (void) fprintf(stderr," DirectClass");
  513. X              else
  514. X                (void) fprintf(stderr," PseudoClass %uc",image->colors);
  515. X              (void) fprintf(stderr," %s\n",image->magick);
  516. X            }
  517. X          /*
  518. X            Pack image data to conserve memory (memory <=> speed).
  519. X          */
  520. X          (void) RunlengthEncodeImage(image);
  521. X          (void) free((char *) image->pixels);
  522. X          image->pixels=(RunlengthPacket *) NULL;
  523. X          if (image_number == maximum_images)
  524. X            {
  525. X              /*
  526. X                Increase size of images array.
  527. X              */
  528. X              maximum_images<<=1;
  529. X              images=(Image **)
  530. X                realloc((char *) images,maximum_images*sizeof(Image *));
  531. X              if (images == (Image **) NULL)
  532. X                Error("unable to montage images","memory allocation failed");
  533. X            }
  534. X          images[image_number++]=image;
  535. X          image=image->next;
  536. X        } while (image != (Image *) NULL);
  537. X      }
  538. X    }
  539. X  if (image_number == 0)
  540. X    Error("missing an image file name",(char *) NULL);
  541. X  /*
  542. X    Create composite image.
  543. X  */
  544. X  montage_image=MontageImage(display,&resource_info,images,image_number,
  545. X    tiles_per_row,frame,compose);
  546. X  if (resource_info.colorspace == GRAYColorspace)
  547. X    QuantizeImage(montage_image,256,8,resource_info.dither,GRAYColorspace,True);
  548. X  if (resource_info.monochrome)
  549. X    QuantizeImage(montage_image,2,8,resource_info.dither,GRAYColorspace,True);
  550. X  if (resource_info.number_colors != 0)
  551. X    {
  552. X      QuantizeImage(montage_image,resource_info.number_colors,
  553. X        resource_info.tree_depth,resource_info.dither,resource_info.colorspace,
  554. X        True);
  555. X      SyncImage(montage_image);
  556. X    }
  557. X  if (compression != UndefinedCompression)
  558. X    montage_image->compression=compression;
  559. X  (void) strcpy(montage_image->filename,write_filename);
  560. X  (void) WriteImage(&image_info,montage_image);
  561. X  if (verbose)
  562. X    {
  563. X      /*
  564. X        Display detailed info about the image.
  565. X      */
  566. X      if (montage_image->class == DirectClass)
  567. X        montage_image->colors=NumberColors(montage_image,False);
  568. X      (void) fprintf(stderr,"[%u] %s %ux%u",montage_image->scene,
  569. X        montage_image->filename,montage_image->columns,montage_image->rows);
  570. X      if (montage_image->class == DirectClass)
  571. X        (void) fprintf(stderr," DirectClass ");
  572. X      else
  573. X        (void) fprintf(stderr," PseudoClass ");
  574. X      (void) fprintf(stderr,"%uc %s %lds\n",montage_image->colors,
  575. X        montage_image->magick,time((time_t *) NULL)-start_time+1);
  576. X    }
  577. X  DestroyImage(montage_image);
  578. X  (void) free((char *) images);
  579. X  if (display != (Display *) NULL)
  580. X    XCloseDisplay(display);
  581. X  return(False);
  582. }
  583. SHAR_EOF
  584. echo 'File ImageMagick/montage.c is complete' &&
  585. chmod 0644 ImageMagick/montage.c ||
  586. echo 'restore of ImageMagick/montage.c failed'
  587. Wc_c="`wc -c < 'ImageMagick/montage.c'`"
  588. test 56463 -eq "$Wc_c" ||
  589.     echo 'ImageMagick/montage.c: original size 56463, current size' "$Wc_c"
  590. rm -f _shar_wnt_.tmp
  591. fi
  592. # ============= ImageMagick/montage.man ==============
  593. if test -f 'ImageMagick/montage.man' -a X"$1" != X"-c"; then
  594.     echo 'x - skipping ImageMagick/montage.man (File already exists)'
  595.     rm -f _shar_wnt_.tmp
  596. else
  597. > _shar_wnt_.tmp
  598. echo 'x - extracting ImageMagick/montage.man (Text)'
  599. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/montage.man' &&
  600. .ad l
  601. .nh
  602. .TH montage 1 "10 October 1992" "ImageMagick"
  603. .SH NAME
  604. montage - creates a composite image by combining several separate images
  605. .SH SYNOPSIS
  606. .B "montage" [ \fIoptions\fP ...] \fIfile\fP
  607. [ [ \fIoptions\fP ...] \fIfile\fP ...] \fIoutput_file\fP
  608. .SH DESCRIPTION
  609. \fBmontage\fP creates a composite image by combining several separate images.
  610. The images are tiled on the composite image with the name of the image
  611. optionally appearing just below the individual tile.
  612. X
  613. The composite image is constructed in the following manner.  First,
  614. each image specified on the command line, except for the last, is
  615. scaled to fit the maximum tile size.  The maximum tile size by default
  616. is 256x256.  It can be modified with the \fB-geometry\fP command line
  617. argument or X resource.  See \fBOPTIONS\fP for more information on
  618. command line arguments. See \fBX(1)\fP for more information on X
  619. resources.  Note that the maximum tile size need not be a square.  The
  620. original aspect ratio of each image is maintainted unless 
  621. \fB\+aspect_ratio\fP is specified.
  622. X
  623. Next the composite image is initialized with the color specified by the
  624. \fP-background\fP command line argument or X resource.  The width and
  625. height of the composite image is determined by the title specified,
  626. the maximum tile size, the number of tiles per row, the tile border
  627. width and height, the image border width, and the label height.  The
  628. number of tiles per row specifies how many images are to appear in each
  629. row of the composite image.  The default is to have an equal number of
  630. images in each row and column of the composite.  A specific value is 
  631. specified with \fB-tiles_per_row\fP.  The tile border width and height,
  632. and the image border width defaults to the value of the X resource
  633. \fB-borderwidth\fP.  It can be changed with the \fB-borderwidth\fP or
  634. \fB-geometry\fP command line argument or X resource.  The label height
  635. is determined by the font you specify with the \fB-font\fP command line
  636. argument or X resource.  If you do not specify a font, a font is
  637. choosen that allows the name of the image to fit the maximum width of a
  638. tiled area.  The label colors is determined by the \fB-background\fP
  639. and \fB-foreground\fP command line argument or X resource.  Note, that
  640. if the background and foreground colors are the same, labels will not
  641. appear.
  642. X
  643. Initially, the composite image title is placed at the top if one is
  644. specified (refer to \fB-foreground\fP X resource).  Next, each image is
  645. set onto the composite image, surrounded by its border color, with its
  646. name centered just below it.  The individual images are left-justified
  647. within the width of the tiled area.  The order of the images is the
  648. same as they appear on the command line unless the images have a scene
  649. keyword.  If a scene number is specified in each image, then the images
  650. are tiled onto the composite in the order of their scene number.  Finally,
  651. the last argument on the command line is the name assigned to the
  652. composite image.  By default, the image is written in the \fBMIFF\fP format
  653. and can be viewed or printed with \fBdisplay(1)\fP.
  654. .SH EXAMPLES
  655. To create a montage of a cockatoo, a parrot, and a hummingbird and write
  656. it to a file called birds, use:
  657. .PP
  658. .B
  659. X     montage cockatoo.miff parrot.miff hummingbird.miff birds.miff
  660. .PP
  661. To tile several bird images so that they are at most 256 pixels in width and
  662. 192 pixels in height, surrounded by a red border, and separated by
  663. 10 pixels of background color, use:
  664. .PP
  665. .B
  666. X     montage -geometry 256x192+10+10 -bordercolor red birds.* montage.miff
  667. .PP
  668. To create an unlabeled parrot image, 640 by 480 pixels, and surrounded
  669. by a border of black, use:
  670. .PP
  671. .B
  672. X     montage +display -geometry 640x480 -bordercolor black parrot.miff bird.miff
  673. .SH OPTIONS
  674. .TP 5
  675. .B "-aspect_ratio
  676. The original aspect ratio of each image is adhered to unless
  677. \fB\+aspect_ratio\fP is specfified.
  678. X
  679. That is, as each image is tiled onto the composite image it is scaled
  680. to fit the maximum width and height of the tiled area while respecting
  681. the aspect ratio of the original image. \fB\+aspect_ratio\fP means the
  682. image is scaled to exactly the dimensions of the tiled image as
  683. specified by \fB\-geometry\fP.
  684. .TP 5
  685. .B "-clip \fI<width>x<height>+<x offset>+<y offset>\fP"
  686. preferred size and location of the clipped image.  See \fBX(1)\fP for details
  687. about the geometry specification.
  688. X
  689. Use clipping to tile only a particular area of an image.
  690. X
  691. The equivalent X resource for this option is \fBclipGeometry\fP
  692. (class \fBClipGeometry\fP).  See \fBX RESOURCES\fP for details.
  693. .TP 5
  694. .B "-colors \fIvalue\fP"
  695. preferred number of colors in the image.
  696. X
  697. The actual number of colors in the image may be less than your request,
  698. but never more.  Note, this is a color reduction option.  Images with
  699. less unique colors than specified with this option will remain unchanged.
  700. Refer to \fBquantize(9)\fP for more details.
  701. X
  702. Note, options \fB-dither\fP, \fB-colorspace\fP, and \fB-treedepth\fP affect
  703. the color reduction algorithm.
  704. .TP 5
  705. .B "-colorspace \fIvalue\fP"
  706. the type of colorspace: \fBGRAY\fP, \fBRGB\fP, \fBXYZ\fP, \fBYCbCr\fP,
  707. \fBYIQ\fP, or \fBYUV\fP.
  708. Color reduction, by default, takes place in the RGB color space.
  709. Empirical evidence suggests that distances in color spaces such as YUV
  710. or YIQ correspond to perceptual color differences more closely
  711. than do distances in RGB space.  These color spaces may give better
  712. results when color reducing an image.  Refer to \fBquantize(9)\fP for
  713. more details.
  714. X
  715. The \fB-colors\fP or \fB-monochrome\fP option is required for this option
  716. to take effect.
  717. .TP 5
  718. .B "-compose \fIoperator\fP"
  719. the type of image composition.
  720. X
  721. By default, each of the composite image pixels are replaced by the
  722. cooresponding image tile pixel. You can choose an alternate composite
  723. operation:
  724. X
  725. X    over
  726. X    in
  727. X    out
  728. X    atop
  729. X    xor
  730. X    plus
  731. X    minus
  732. X    add
  733. X    subtract
  734. X    difference
  735. X    replace
  736. .PP
  737. The operations behaves as follows:
  738. .TP 9
  739. .B over
  740. The result will be the union of the two image shapes, with \fIimage\fP
  741. obscuring \fIcomposite image\fP in the region of overlap.
  742. .TP 9
  743. .B in
  744. The result is simply \fIimage\fP cut by the shape of \fIimage
  745. window\fP.  None of the image data of \fIcomposite image\fP will be in the
  746. result.
  747. .TP 9
  748. .B out
  749. The resulting image is \fIimage\fP with the shape of \fIcomposite image\fP
  750. cut out.
  751. .TP 9
  752. .B atop
  753. The result is the same shape as image \fIcomposite image\fP, with
  754. \fIimage\fP obscuring \fIcomposite image\fP where the image shapes
  755. overlap.  Note this differs from \fBover\fP because the portion of
  756. \fIimage\fP outside \fIcomposite image\fP's shape does not appear in the
  757. result.
  758. .TP 9
  759. .B xor
  760. The result is the image data from both \fIimage\fP and \fIcomposite image\fP
  761. that is outside the overlap region.  The overlap region will be blank.
  762. .TP 9
  763. .B plus
  764. The result is just the sum of the image data.  Output values are
  765. clipped to 255 (no overflow).  This operation is independent
  766. of the alpha channels.
  767. .TP 9
  768. .B minus
  769. The result of \fIimage\fP \- \fIcomposite image\fP, with underflow clipped
  770. to zero.  The alpha channel is ignored (set to 255, full coverage).
  771. .TP 9
  772. .B add
  773. The result of \fIimage\fP + \fIcomposite image\fP, with overflow wrapping
  774. around (\fImod\fP 256).
  775. .TP 9
  776. .B subtract
  777. The result of \fIimage\fP - \fIcomposite image\fP, with underflow wrapping
  778. around (\fImod\fP 256).  The \fBadd\fP and \fBsubtract\fP operators can
  779. be used to perform reversible transformations.
  780. .TP 9
  781. .B difference
  782. The result of abs(\fIimage\fP \- \fIcomposite image\fP).  This is useful
  783. for comparing two very similar images.
  784. .TP 9
  785. .B replace
  786. The resulting image is \fIcomposite image\fP replaced with \fIimage\fP.
  787. Here the alpha information is ignored.
  788. X
  789. The image compositor requires an alpha, or matte channel in the image
  790. for some operations.  This extra channel usually defines a mask which
  791. represents a sort of a cookie-cutter for the image.  This is the case
  792. when alpha is 255 (full coverage) for pixels inside the shape, zero
  793. outside, and between zero and 255 on the boundary.  If \fIimage\fP does
  794. not have an alpha channel, it is initialized with 0 for any pixel
  795. matching in color to pixel location (0,0), otherwise 255 (to work
  796. properly \fBborderwidth\fP must be 0).
  797. .TP 5
  798. .B "-compress \fItype\fP"
  799. the type of image compression: \fIQEncoded\fP or \fIRunlengthEncoded\fP.
  800. X
  801. This option specifies the type of image compression for the composite
  802. image.  See \fBmiff(5)\fP for details.
  803. X
  804. Specify \fB\+compress\fP to store the binary image in an uncompressed format.
  805. The default is the compression type of the specified image file.
  806. .TP 5
  807. .B "-density \fI<width>x<height>
  808. vertical and horizonal density of the image.
  809. X
  810. This option specifies an image density whose interpretation changes
  811. with the type of image.  The default is 72 dots per inch in the
  812. horizonal and vertical direction for Postscript.  Text files default to
  813. 80 characters in width and 60 lines in height.  Use this option to
  814. alter the default density.
  815. .TP 5
  816. .B "-display \fIhost:display[.screen]\fP"
  817. specifies the X server to contact; see \fBX(1)\fP.
  818. X
  819. Specify \fB+display\fP if an X server is not available.  The label font
  820. is obtained from the X server.  If none is available, the composite image
  821. will not have labels.
  822. .TP 5
  823. .B "-dither"
  824. apply Floyd/Steinberg error diffusion to the image.
  825. X
  826. The basic strategy of dithering is to trade intensity resolution for
  827. spatial resolution by averaging the intensities of several neighboring
  828. pixels.  Images which suffer from severe contouring when reducing colors
  829. can be improved with this option.
  830. X
  831. The \fB-colors\fP or \fB-monochrome\fP option is required
  832. for this option to take effect.
  833. .TP 5
  834. .B "-frame"
  835. surround image with an ornamental border.
  836. X
  837. Specify the width of the border with \fB-borderwidth\fP.  Use
  838. \fB-gravity\fP to specify how the image is oriented within the
  839. ornamental border.
  840. .TP 5
  841. .B "-gamma \fIvalue\fP"
  842. level of gamma correction.
  843. X
  844. The same color image displayed on two different workstations may look
  845. different due to differences in the display monitor.  Use gamma
  846. correction to adjust for this color difference.  Reasonable values
  847. extend from 0.8 to 2.3.
  848. .TP 5
  849. .B "-geometry \fI<width>x<height>+<border width>+<border height>\fP"
  850. preferred tile and border size of each tile of the composite image.
  851. See \fBX(1)\fP for details about the geometry specification.  By default,
  852. the tile size is 256x256 and there is no border.
  853. X
  854. The tile size you specify is a maximum size.  Each image is scaled to
  855. fit the maximum size while still retaining its original aspect ratio.
  856. Each image is surrounded by a border whose size in pixels is specified
  857. as \fI<border width>\fP and \fI<border height>\fP and whose color is
  858. the background color.
  859. X
  860. The equivalent X resource for this option is \fBimageGeometry\fP
  861. (class \fBImageGeometry\fP).  See \fBX RESOURCES\fP for details.
  862. .TP 5
  863. .B "-gravity \fIdirection\fP"
  864. direction image gravitates to within a tile.  See \fBX(1)\fP for details
  865. about the gravity specification.
  866. X
  867. A tile of the composite image is a fixed width and height.  However,
  868. the image within the tile may not fill it completely (see
  869. \fB-aspect_ratio\fP).  The direction you specify indicates where to
  870. position the image within the tile.  For example \fICenter\fP gravity
  871. forces the image to be centered within the tile.  By default, the image
  872. gravity is \fINorth\fP.
  873. .TP 5
  874. .B "-interlace \fItype\fP"
  875. the type of interlacing scheme: \fBNONE\fP, \fBLINE\fP, or \fBPLANE\fP.
  876. X
  877. This option is used to specify the type of interlacing scheme for raw
  878. image formats such as \fBRGB\fP or \fBYUV\fP.  \fBNONE\fP means do not
  879. interlace (RGBRGBRGBRGBRGBRGB...), \fBLINE\fP uses scanline
  880. interlacing (RRR...GGG...BBB...RRR...GGG...BBB...), and \fBPLANE\fP uses
  881. plane interlacing (RRRRRR...GGGGGG...BBBBBB...).
  882. .TP 5
  883. .B "-monochrome"
  884. transform the image to black and white.
  885. X
  886. Monochrome images can benefit from error diffusion.  Use \fB-dither\fP with
  887. this option to diffuse the error.
  888. .TP 5
  889. .B "-page \fI<width>x<height>{\+-}<x offset>{\+-}<y offset>\fP"
  890. preferred size and location of the Postscript page.
  891. X
  892. Use this option to specify the dimensions of the Postscript page in picas.  The
  893. default is to center the image on a letter page, 612 by 792 picas.
  894. Other common sizes are:
  895. X
  896. X    540x720   Note
  897. X    612x1008  Legal
  898. X    842x1190  A3
  899. X    595x842   A4
  900. X    421x595   A5
  901. X    297x421   A6
  902. X    709x1002  B4
  903. X    612x936   U.S. Foolscap
  904. X    612x936   European Foolscap
  905. X    396x612   Half Letter
  906. X    792x1224  11x17
  907. X    1224x792  Ledger
  908. X
  909. The page geometry is relative to the vertical and horizonal density of the
  910. Postscript page.  See \fB-density\fP for details.
  911. .TP 5
  912. .B "-quality \fIvalue\fP"
  913. JPEG quality setting.
  914. X
  915. Quality is 0 (worst) to 100 (best). The default is 75.
  916. .TP 5
  917. .B "-rotate \fIdegrees\fP"
  918. apply Paeth image rotation to the image.
  919. X
  920. Empty triangles left over from rotating the image are filled with
  921. the color defined by the pixel at location (0,0).
  922. .TP 5
  923. .B "-tiles_per_row \fIvalue\fP"
  924. specifies how many images are to appear in each row of the composite image.
  925. The default is to have an equal number of images in each row and column of
  926. the composite.
  927. .TP 5
  928. .B "-treedepth \fIvalue\fP"
  929. Normally, this integer value is zero or one.  A zero or one tells
  930. \fBmontage\fP to choose a optimal tree depth for the color reduction
  931. algorithm.
  932. X
  933. An optimal depth generally allows the best representation of the source
  934. image with the fastest computational speed and the least amount of
  935. memory.  However, the default depth is inappropriate for some images.
  936. To assure the best representation, try values between 2 and 8 for this
  937. parameter.  Refer to \fBquantize(9)\fP for more details.
  938. X
  939. The \fB-colors\fP or \fB-monochrome\fP option is required for this option
  940. to take effect.
  941. .TP 5
  942. .B -verbose
  943. print detailed information about the image.
  944. This information is printed: image scene number;  image name;  image size;
  945. the image class (\fIDirectClass\fP or \fIPseudoClass\fP);  the total
  946. number of unique colors;  and the number of seconds to read and write the
  947. image.
  948. .PP
  949. In addition to those listed above, you can specify these standard X
  950. resources as command line options:  -background, -bordercolor, -borderwidth,
  951. -font, -foreground, -title.
  952. See \fBX RESOURCES\fP for details.
  953. .PP
  954. Any option you specify on the command line remains in effect until it is
  955. explicitly changed by specifying the option again with a different effect.
  956. For example, to montage two images, the first with 32 colors and the
  957. second with only 16 colors, use:
  958. .PP
  959. X     montage -colors 32 cockatoo.1 -colors 16 cockatoo.2 cockatoo.miff
  960. .PP
  961. Change \fI-\fP to \fI\+\fP in any option above to reverse its effect.
  962. For example, specify \fB\+dither\fP to not apply error diffusion to an
  963. image.
  964. .PP
  965. By default, the image format is determined by its magic number. To
  966. specify a particular image format, precede the filename with an image
  967. format name and a colon (i.e. ps:image) or specify the image type as
  968. the filename suffix (i.e. image.ps).  See \fBconvert(1)\fP for a list
  969. of valid image formats.
  970. .PP
  971. When you specify \fBX\fP as your image type, the filename has special
  972. meaning.  It specifies an X window by id, name, or \fBroot\fP.  If no
  973. filename is specified, the window is selected by clicking the mouse in
  974. the desired window.
  975. .PP
  976. Specify \fIfile\fP as \fI-\fP for standard input, \fIoutput_file\fP as
  977. \fI-\fP for standard output.  If \fIfile\fP has the extension \fB.Z\fP
  978. or \fB.gz\fP, the file is uncompressed with \fBuncompress\fP or
  979. \fBgunzip\fP respectively.  If \fIoutput_file\fP has the extension
  980. \fB.Z\fP or \fB.gz\fP, the file size is compressed using with
  981. \fBcompress\fP or \fBgzip\fP respectively.  If \fIoutput_file\fP
  982. already exists, you will be prompted as to whether it should be
  983. overwritten.
  984. .PP
  985. Note, a composite MIFF image displayed to an X server with
  986. \fBdisplay\fP behaves differently than other images.  You can think of
  987. the composite as a visual image directory.  Choose a particular tile of
  988. the composite and press a button to display it.  See \fBdisplay(1)\fP
  989. and \fBmiff(5)\fP for details.
  990. .SH "X RESOURCES"
  991. \fBmontage\fP options can appear on the command line or in your X
  992. resource file.  Options on the command line supersede values specified
  993. in your X resource file.  See \fBX(1)\fP for more information on X
  994. resources.
  995. X
  996. All \fBmontage\fP options have a corresponding X resource.  In addition,
  997. \fBmontage\fP uses the following X resources:
  998. .TP 5
  999. .B background (\fPclass\fB Background)
  1000. Specifies the preferred color to use for the composite image background.  The
  1001. default is black.
  1002. .TP 5
  1003. .B borderColor (\fPclass\fB BorderColor)
  1004. Specifies the preferred color to use for the composite image border.  The
  1005. default is white.
  1006. .TP 5
  1007. .B borderWidth (\fPclass\fB BorderWidth)
  1008. Specifies the width in pixels of the composite image border.  The default is 2.
  1009. .TP 5
  1010. .B font (\fPclass\fB Font)
  1011. Specifies the name of the preferred font to use when displaying text
  1012. within the composite image.  The default is 9x15, fixed, or 5x8 determined by
  1013. the composite image size.
  1014. .TP 5
  1015. .B foreground (\fPclass\fB Foreground)
  1016. Specifies the preferred color to use for text within the composite image.  The
  1017. default is white.
  1018. .TP 5
  1019. .B title (\fPclass\fB Title)
  1020. This resource specifies the title to be placed at the top of the composite 
  1021. image.  The default is not to place a title at the top of the composite image.
  1022. .SH ENVIRONMENT
  1023. .TP 5
  1024. .B display
  1025. To get the default host, display number, and screen.
  1026. .SH SEE ALSO
  1027. .B
  1028. display(1), mogrify(1), convert(1), X(1), quantize(9), miff(5), compress(1)
  1029. .SH COPYRIGHT
  1030. Copyright 1993 E. I. du Pont de Nemours & Company
  1031. .PP
  1032. Permission to use, copy, modify, distribute, and sell this software and
  1033. its documentation for any purpose is hereby granted without fee,
  1034. provided that the above copyright notice appear in all copies and that
  1035. both that copyright notice and this permission notice appear in
  1036. supporting documentation, and that the name of E. I. du Pont de Nemours
  1037. & Company not be used in advertising or publicity pertaining to
  1038. distribution of the software without specific, written prior
  1039. permission.  E. I. du Pont de Nemours & Company makes no representations
  1040. about the suitability of this software for any purpose.  It is provided
  1041. "as is" without express or implied warranty.
  1042. .PP
  1043. E. I. du Pont de Nemours & Company disclaims all warranties with regard
  1044. to this software, including all implied warranties of merchantability
  1045. and fitness, in no event shall E. I. du Pont de Nemours & Company be
  1046. liable for any special, indirect or consequential damages or any
  1047. damages whatsoever resulting from loss of use, data or profits, whether
  1048. in an action of contract, negligence or other tortious action, arising
  1049. out of or in connection with the use or performance of this software.
  1050. .SH ACKNOWLEDGEMENTS
  1051. The MIT X Consortium for making network transparent graphics a reality.
  1052. .PP
  1053. Michael Halle, Spatial Imaging Group at MIT, for the initial
  1054. implementation of Alan Paeth's image rotation algorithm.
  1055. .PP
  1056. David Pensak, E. I. du Pont de Nemours & Company, for providing a
  1057. computing environment that made this program possible.
  1058. .PP
  1059. Paul Raveling, USC Information Sciences Institute, for the original
  1060. idea of using space subdivision for the color reduction algorithm.
  1061. .SH AUTHORS
  1062. John Cristy, E.I. du Pont de Nemours & Company Incorporated
  1063. SHAR_EOF
  1064. chmod 0644 ImageMagick/montage.man ||
  1065. echo 'restore of ImageMagick/montage.man failed'
  1066. Wc_c="`wc -c < 'ImageMagick/montage.man'`"
  1067. test 19241 -eq "$Wc_c" ||
  1068.     echo 'ImageMagick/montage.man: original size 19241, current size' "$Wc_c"
  1069. rm -f _shar_wnt_.tmp
  1070. fi
  1071. # ============= ImageMagick/utility.c ==============
  1072. if test -f 'ImageMagick/utility.c' -a X"$1" != X"-c"; then
  1073.     echo 'x - skipping ImageMagick/utility.c (File already exists)'
  1074.     rm -f _shar_wnt_.tmp
  1075. else
  1076. > _shar_wnt_.tmp
  1077. echo 'x - extracting ImageMagick/utility.c (Text)'
  1078. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/utility.c' &&
  1079. /*
  1080. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1081. %                                                                             %
  1082. %                                                                             %
  1083. %                                                                             %
  1084. %             U   U  TTTTT  IIIII  L      IIIII  TTTTT  Y   Y                 %
  1085. %             U   U    T      I    L        I      T     Y Y                  %
  1086. %             U   U    T      I    L        I      T      Y                   %
  1087. %             U   U    T      I    L        I      T      Y                   %
  1088. %              UUU     T    IIIII  LLLLL  IIIII    T      Y                   %
  1089. %                                                                             %
  1090. %                                                                             %
  1091. %                       ImageMagick Utility Routines                          %
  1092. %                                                                             %
  1093. %                                                                             %
  1094. %                                                                             %
  1095. %                             Software Design                                 %
  1096. %                               John Cristy                                   %
  1097. %                              January 1993                                   %
  1098. %                                                                             %
  1099. %                                                                             %
  1100. %  Copyright 1993 E. I. du Pont de Nemours & Company                          %
  1101. %                                                                             %
  1102. %  Permission to use, copy, modify, distribute, and sell this software and    %
  1103. %  its documentation for any purpose is hereby granted without fee,           %
  1104. %  provided that the above Copyright notice appear in all copies and that     %
  1105. %  both that Copyright notice and this permission notice appear in            %
  1106. %  supporting documentation, and that the name of E. I. du Pont de Nemours    %
  1107. %  & Company not be used in advertising or publicity pertaining to            %
  1108. %  distribution of the software without specific, written prior               %
  1109. %  permission.  E. I. du Pont de Nemours & Company makes no representations   %
  1110. %  about the suitability of this software for any purpose.  It is provided    %
  1111. %  "as is" without express or implied warranty.                               %
  1112. %                                                                             %
  1113. %  E. I. du Pont de Nemours & Company disclaims all warranties with regard    %
  1114. %  to this software, including all implied warranties of merchantability      %
  1115. %  and fitness, in no event shall E. I. du Pont de Nemours & Company be       %
  1116. %  liable for any special, indirect or consequential damages or any           %
  1117. %  damages whatsoever resulting from loss of use, data or profits, whether    %
  1118. %  in an action of contract, negligence or other tortious action, arising     %
  1119. %  out of or in connection with the use or performance of this software.      %
  1120. %                                                                             %
  1121. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1122. %
  1123. %
  1124. */
  1125. X
  1126. /*
  1127. X  Include declarations.
  1128. */
  1129. #include "display.h"
  1130. X
  1131. /*
  1132. X  Forward declarations.
  1133. */
  1134. unsigned int
  1135. X  ReadData _Declare((char *,int,int,FILE *));
  1136. X
  1137. /*
  1138. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1139. %                                                                             %
  1140. %                                                                             %
  1141. %                                                                             %
  1142. %  L S B F i r s t R e a d L o n g                                            %
  1143. %                                                                             %
  1144. %                                                                             %
  1145. %                                                                             %
  1146. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1147. %
  1148. %  Function LSBFirstReadLong reads a long value as a 32 bit quantity in
  1149. %  least-significant byte first order.
  1150. %
  1151. %  The format of the LSBFirstReadLong routine is:
  1152. %
  1153. %       value=LSBFirstReadLong(file)
  1154. %
  1155. %  A description of each parameter follows.
  1156. %
  1157. %    o value:  Function LSBFirstReadLong returns an unsigned long read from
  1158. %      the file.
  1159. %
  1160. %   o  file:  Specifies the file to read the data from.
  1161. %
  1162. %
  1163. */
  1164. unsigned long LSBFirstReadLong(file)
  1165. FILE
  1166. X  *file;
  1167. {
  1168. X  unsigned char
  1169. X    buffer[4];
  1170. X
  1171. X  unsigned int
  1172. X    status;
  1173. X
  1174. X  unsigned long
  1175. X    value;
  1176. X
  1177. X  status=ReadData((char *) buffer,1,4,file);
  1178. X  if (status == False)
  1179. X    return((unsigned long) ~0);
  1180. X  value=(unsigned int) (buffer[3] << 24);
  1181. X  value|=(unsigned int) (buffer[2] << 16);
  1182. X  value|=(unsigned int) (buffer[1] << 8);
  1183. X  value|=(unsigned int) (buffer[0]);
  1184. X  return(value);
  1185. }
  1186. X
  1187. /*
  1188. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1189. %                                                                             %
  1190. %                                                                             %
  1191. %                                                                             %
  1192. %  L S B F i r s t R e a d S h o r t                                          %
  1193. %                                                                             %
  1194. %                                                                             %
  1195. %                                                                             %
  1196. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1197. %
  1198. %  Function LSBFirstReadShort reads a short value as a 16 bit quantity in
  1199. %  least-significant byte first order.
  1200. %
  1201. %  The format of the LSBFirstReadShort routine is:
  1202. %
  1203. %       value=LSBFirstReadShort(file)
  1204. %
  1205. %  A description of each parameter follows.
  1206. %
  1207. %    o value:  Function LSBFirstReadShort returns an unsigned short read from
  1208. %      the file.
  1209. %
  1210. %   o  file:  Specifies the file to read the data from.
  1211. %
  1212. %
  1213. */
  1214. unsigned short LSBFirstReadShort(file)
  1215. FILE
  1216. X  *file;
  1217. {
  1218. X  unsigned char
  1219. X    buffer[2];
  1220. X
  1221. X  unsigned int
  1222. X    status;
  1223. X
  1224. X  unsigned short
  1225. X    value;
  1226. X
  1227. X  status=ReadData((char *) buffer,1,2,file);
  1228. X  if (status == False)
  1229. X    return((unsigned long) ~0);
  1230. X  value=(unsigned short) (buffer[1] << 8);
  1231. X  value|=(unsigned short) (buffer[0]);
  1232. X  return(value);
  1233. }
  1234. X
  1235. /*
  1236. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1237. %                                                                             %
  1238. %                                                                             %
  1239. %                                                                             %
  1240. %  L S B F i r s t W r i t e L o n g                                          %
  1241. %                                                                             %
  1242. %                                                                             %
  1243. %                                                                             %
  1244. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1245. %
  1246. %  Function LSBFirstWriteLong writes a long value as a 32 bit quantity in
  1247. %  least-significant byte first order.
  1248. %
  1249. %  The format of the LSBFirstWriteLong routine is:
  1250. %
  1251. %       LSBFirstWriteLong(value,file)
  1252. %
  1253. %  A description of each parameter follows.
  1254. %
  1255. %   o  value:  Specifies the value to write.
  1256. %
  1257. %   o  file:  Specifies the file to write the data to.
  1258. %
  1259. %
  1260. */
  1261. void LSBFirstWriteLong(value,file)
  1262. unsigned long
  1263. X  value;
  1264. X
  1265. FILE
  1266. X  *file;
  1267. {
  1268. X  unsigned char
  1269. X    buffer[4];
  1270. X
  1271. X  buffer[0]=(unsigned char) (value);
  1272. X  buffer[1]=(unsigned char) ((value) >> 8);
  1273. X  buffer[2]=(unsigned char) ((value) >> 16);
  1274. X  buffer[3]=(unsigned char) ((value) >> 24);
  1275. X  (void) fwrite((char *) buffer,1,4,file);
  1276. }
  1277. X
  1278. /*
  1279. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1280. %                                                                             %
  1281. %                                                                             %
  1282. %                                                                             %
  1283. %  L S B F i r s t W r i t e S h o r t                                        %
  1284. %                                                                             %
  1285. %                                                                             %
  1286. %                                                                             %
  1287. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1288. %
  1289. %  Function LSBFirstWriteShort writes a long value as a 16 bit quantity in
  1290. %  least-significant byte first order.
  1291. %
  1292. %  The format of the LSBFirstWriteShort routine is:
  1293. %
  1294. %       LSBFirstWriteShort(value,file)
  1295. %
  1296. %  A description of each parameter follows.
  1297. %
  1298. %   o  value:  Specifies the value to write.
  1299. %
  1300. %   o  file:  Specifies the file to write the data to.
  1301. %
  1302. %
  1303. */
  1304. void LSBFirstWriteShort(value,file)
  1305. unsigned int
  1306. X  value;
  1307. X
  1308. FILE
  1309. X  *file;
  1310. {
  1311. X  unsigned char
  1312. X    buffer[2];
  1313. X
  1314. X  buffer[0]=(unsigned char) (value);
  1315. SHAR_EOF
  1316. true || echo 'restore of ImageMagick/utility.c failed'
  1317. fi
  1318. echo 'End of ImageMagick part 32'
  1319. echo 'File ImageMagick/utility.c is continued in part 33'
  1320. echo 33 > _shar_seq_.tmp
  1321. exit 0
  1322.  
  1323. exit 0 # Just in case...
  1324. -- 
  1325.   // chris@Sterling.COM           | Send comp.sources.x submissions to:
  1326. \X/  Amiga - The only way to fly! |    sources-x@sterling.com
  1327.  "It's intuitively obvious to the |
  1328.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  1329.