home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / x / volume13 / imagemagic / part11 < prev    next >
Text File  |  1991-05-23  |  75KB  |  2,546 lines

  1. Path: uunet!uunet!cs.utexas.edu!sun-barr!newstop!exodus!dupont.com!cristy
  2. From: cristy@dupont.com
  3. Newsgroups: comp.sources.x
  4. Subject: v13i027: ImageMagick - Graphics display programs, Part11/21
  5. Message-ID: <13941@exodus.Eng.Sun.COM>
  6. Date: 24 May 91 03:18:56 GMT
  7. References: <csx-13i017:imagemagic@uunet.UU.NET>
  8. Sender: news@exodus.Eng.Sun.COM
  9. Lines: 2534
  10. Approved: argv@sun.com
  11.  
  12. Submitted-by: cristy@dupont.com
  13. Posting-number: Volume 13, Issue 27
  14. Archive-name: imagemagic/part11
  15.  
  16. #!/bin/sh
  17. # this is img.11 (part 11 of ImageMagick)
  18. # do not concatenate these parts, unpack them in order with /bin/sh
  19. # file ImageMagick/rotate.c continued
  20. #
  21. if test ! -r _shar_seq_.tmp; then
  22.     echo 'Please unpack part 1 first!'
  23.     exit 1
  24. fi
  25. (read Scheck
  26.  if test "$Scheck" != 11; then
  27.     echo Please unpack part "$Scheck" next!
  28.     exit 1
  29.  else
  30.     exit 0
  31.  fi
  32. ) < _shar_seq_.tmp || exit 1
  33. if test ! -f _shar_wnt_.tmp; then
  34.     echo 'x - still skipping ImageMagick/rotate.c'
  35. else
  36. echo 'x - continuing file ImageMagick/rotate.c'
  37. sed 's/^X//' << 'SHAR_EOF' >> 'ImageMagick/rotate.c' &&
  38. %                                                                             %
  39. %                 RRRR    OOO   TTTTT   AAA   TTTTT   EEEEE                   %
  40. %                 R   R  O   O    T    A   A    T     E                       %
  41. %                 RRRR   O   O    T    AAAAA    T     EEE                     %
  42. %                 R R    O   O    T    A   A    T     E                       %
  43. %                 R  R    OOO     T    A   A    T     EEEEE                   %
  44. %                                                                             %
  45. %                                                                             %
  46. %                Rotate a raster image by an arbitrary angle.                 %
  47. %                                                                             %
  48. %                                                                             %
  49. %                                                                             %
  50. %                           Software Design                                   %
  51. %                             John Cristy                                     %
  52. %                            January  1991                                    %
  53. %                                                                             %
  54. %                                                                             %
  55. %  Copyright 1991 E. I. Dupont de Nemours & Company                           %
  56. %                                                                             %
  57. %  Permission to use, copy, modify, distribute, and sell this software and    %
  58. %  its documentation for any purpose is hereby granted without fee,           %
  59. %  provided that the above Copyright notice appear in all copies and that     %
  60. %  both that Copyright notice and this permission notice appear in            %
  61. %  supporting documentation, and that the name of E. I. Dupont de Nemours     %
  62. %  & Company not be used in advertising or publicity pertaining to            %
  63. %  distribution of the software without specific, written prior               %
  64. %  permission.  E. I. Dupont de Nemours & Company makes no representations    %
  65. %  about the suitability of this software for any purpose.  It is provided    %
  66. %  "as is" without express or implied warranty.                               %
  67. %                                                                             %
  68. %  E. I. Dupont de Nemours & Company disclaims all warranties with regard     %
  69. %  to this software, including all implied warranties of merchantability      %
  70. %  and fitness, in no event shall E. I. Dupont de Nemours & Company be        %
  71. %  liable for any special, indirect or consequential damages or any           %
  72. %  damages whatsoever resulting from loss of use, data or profits, whether    %
  73. %  in an action of contract, negligence or other tortious action, arising     %
  74. %  out of or in connection with the use or performance of this software.      %
  75. %                                                                             %
  76. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  77. %
  78. %  Function RotateImage is based on the paper "A Fast Algorithm for General
  79. %  Raster Rotatation" by Alan W. Paeth.  RotateImage is adapted from a similiar
  80. %  routine based on the Paeth paper written by Michael Halle of the Spatial
  81. %  Imaging Group, MIT Media Lab.
  82. %
  83. */
  84. X
  85. /*
  86. X  Include declarations.
  87. */
  88. #include "display.h"
  89. #include "image.h"
  90. X
  91. /*
  92. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  93. %                                                                             %
  94. %                                                                             %
  95. %                                                                             %
  96. %   C o l u m n S h e a r                                                     %
  97. %                                                                             %
  98. %                                                                             %
  99. %                                                                             %
  100. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  101. %
  102. %  Procedure ColumnShear displaces a subcolumn of pixels a specified number of
  103. %  pixels.
  104. %
  105. %  The format of the ColumnShear routine is:
  106. %
  107. %      ColumnShear(source_image,source_columns,column,y,length,displacement,
  108. %        background)
  109. %
  110. %  A description of each parameter follows.
  111. %
  112. %    o source_image: A pointer to a ColorPacket structure which contains the
  113. %      source image.
  114. %
  115. %    o source_columns: Specifies the number of columns in the source image.
  116. %
  117. %    o column: Specifies which column in the image to move.
  118. %
  119. %    o y: Specifies the offset in the source image.
  120. %
  121. %    o length: Specifies the number of pixels to move.
  122. %
  123. %    o displacement: Specifies the number of pixels to displace the column of
  124. %      pixels.
  125. %
  126. %    o background: Specifies the background color.
  127. %
  128. %
  129. */
  130. static void ColumnShear(source_image,source_columns,column,y,length,
  131. X  displacement,background)
  132. ColorPacket
  133. X  *source_image;
  134. X
  135. register unsigned int
  136. X  source_columns;
  137. X
  138. unsigned int
  139. X  column,
  140. X  y,
  141. X  length;
  142. X
  143. double
  144. X  displacement;
  145. X
  146. ColorPacket
  147. X  background;
  148. {
  149. X  ColorPacket
  150. X    last_pixel;
  151. X
  152. X  double
  153. X    fractional_step;
  154. X
  155. X  enum {UP,DOWN}
  156. X    direction;
  157. X
  158. X  long int
  159. X    blue,
  160. X    green,
  161. X    int_fractional_step,
  162. X    red,
  163. X    step;
  164. X
  165. X  register ColorPacket
  166. X    *p,
  167. X    *q;
  168. X
  169. X  register int
  170. X    i;
  171. X
  172. X  if (displacement == 0.0)
  173. X    return;
  174. X  else
  175. X    if (displacement > 0.0)
  176. X      direction=DOWN;
  177. X    else
  178. X      {
  179. X        displacement*=(-1.0);
  180. X        direction=UP;
  181. X      }
  182. X  step=(int) floor(displacement);
  183. X  fractional_step=displacement-(double) step;
  184. X  if (fractional_step == 0.0)
  185. X    {
  186. X      /*
  187. X        No fractional displacement-- just copy the pixels.
  188. X      */
  189. X      switch (direction)
  190. X      {
  191. X        case UP:
  192. X        {
  193. X          p=source_image+y*source_columns+column;
  194. X          q=p-step*source_columns;
  195. X          for (i=0; i < length; i++)
  196. X          {
  197. X            *q=(*p);
  198. X            q+=source_columns;
  199. X            p+=source_columns;
  200. X          }
  201. X          /*
  202. X            Set old column to background color.
  203. X          */
  204. X          for (i=0; i < step; i++)
  205. X          {
  206. X            *q=background;
  207. X            q+=source_columns;
  208. X          }
  209. X          break;
  210. X        }
  211. X        case DOWN:
  212. X        {
  213. X          p=source_image+(y+length)*source_columns+column;
  214. X          q=p+step*source_columns;
  215. X          for (i=0; i < length; i++)
  216. X          {
  217. X            q-=source_columns;
  218. X            p-=source_columns;
  219. X            *q=(*p);
  220. X          }
  221. X          /*
  222. X            Set old column to background color.
  223. X          */
  224. X          for (i=0; i < step; i++)
  225. X          {
  226. X            q-=source_columns;
  227. X            *q=background;
  228. X          }
  229. X          break;
  230. X        }
  231. X      }
  232. X      return;
  233. X    }
  234. X  /*
  235. X    Fractional displacment.
  236. X  */
  237. X  step++;
  238. X  int_fractional_step=(int) (((double) (1 << 14))*fractional_step);
  239. X  last_pixel=background;
  240. X  switch (direction)
  241. X  {
  242. X    case UP:
  243. X    {
  244. X      p=source_image+y*source_columns+column;
  245. X      q=p-step*source_columns;
  246. X      for (i=0; i < length; i++)
  247. X      {
  248. X        red=(last_pixel.red*((1 << 14)-int_fractional_step)+p->red*
  249. X          int_fractional_step) >> 14;
  250. X        if (red > MaxRgb)
  251. X          q->red=MaxRgb;
  252. X        else
  253. X          if (red < 0)
  254. X            q->red=0;
  255. X          else
  256. X            q->red=(unsigned char) red;
  257. X        green=(last_pixel.green*((1 << 14)-int_fractional_step)+p->green*
  258. X          int_fractional_step) >> 14;
  259. X        if (green > MaxRgb)
  260. X          q->green=MaxRgb;
  261. X        else
  262. X          if (green < 0)
  263. X            q->green=0;
  264. X          else
  265. X            q->green=(unsigned char) green;
  266. X        blue=(last_pixel.blue*((1 << 14)-int_fractional_step)+p->blue*
  267. X          int_fractional_step) >> 14;
  268. X        if (blue > MaxRgb)
  269. X          q->blue=MaxRgb;
  270. X        else
  271. X          if (blue < 0)
  272. X            q->blue=0;
  273. X          else
  274. X            q->blue=(unsigned char) blue;
  275. X        last_pixel=(*p);
  276. X        q+=source_columns;
  277. X        p+=source_columns;
  278. X      }
  279. X      /*
  280. X        Set old column to background color.
  281. X      */
  282. X      red=(last_pixel.red*((1 << 14)-int_fractional_step)+background.red*
  283. X        int_fractional_step) >> 14;
  284. X      if (red > MaxRgb)
  285. X        q->red=MaxRgb;
  286. X      else
  287. X        if (red < 0)
  288. X          q->red=0;
  289. X        else
  290. X          q->red=(unsigned char) red;
  291. X      green=(last_pixel.green*((1 << 14)-int_fractional_step)+background.green*
  292. X        int_fractional_step) >> 14;
  293. X      if (green > MaxRgb)
  294. X        q->green=MaxRgb;
  295. X      else
  296. X        if (green < 0)
  297. X          q->green=0;
  298. X        else
  299. X          q->green=(unsigned char) green;
  300. X      blue=(last_pixel.blue*((1 << 14)-int_fractional_step)+background.blue*
  301. X        int_fractional_step) >> 14;
  302. X      if (blue > MaxRgb)
  303. X        q->blue=MaxRgb;
  304. X      else
  305. X        if (blue < 0)
  306. X          q->blue=0;
  307. X        else
  308. X          q->blue=(unsigned char) blue;
  309. X      q+=source_columns;
  310. X      for (i=0; i < step-1; i++)
  311. X      {
  312. X        *q=background;
  313. X        q+=source_columns;
  314. X      }
  315. X      break;
  316. X    }
  317. X    case DOWN:
  318. X    {
  319. X      p=source_image+(y+length)*source_columns+column;
  320. X      q=p+step*source_columns;
  321. X      for (i=0; i < length; i++)
  322. X      {
  323. X        q-=source_columns;
  324. X        p-=source_columns;
  325. X        red=(last_pixel.red*((1 << 14)-int_fractional_step)+p->red*
  326. X          int_fractional_step) >> 14;
  327. X        if (red > MaxRgb)
  328. X          q->red=MaxRgb;
  329. X        else
  330. X          if (red < 0)
  331. X            q->red=0;
  332. X          else
  333. X            q->red=(unsigned char) red;
  334. X        green=(last_pixel.green*((1 << 14)-int_fractional_step)+p->green*
  335. X          int_fractional_step) >> 14;
  336. X        if (green > MaxRgb)
  337. X          q->green=MaxRgb;
  338. X        else
  339. X          if (green < 0)
  340. X            q->green=0;
  341. X          else
  342. X            q->green=(unsigned char) green;
  343. X        blue=(last_pixel.blue*((1 << 14)-int_fractional_step)+p->blue*
  344. X          int_fractional_step) >> 14;
  345. X        if (blue > MaxRgb)
  346. X          q->blue=MaxRgb;
  347. X        else
  348. X          if (blue < 0)
  349. X            q->blue=0;
  350. X          else
  351. X            q->blue=(unsigned char) blue;
  352. X        last_pixel=(*p);
  353. X      }
  354. X      /*
  355. X        Set old column to background color.
  356. X      */
  357. X      q-=source_columns;
  358. X      red=(last_pixel.red*((1 << 14)-int_fractional_step)+background.red*
  359. X        int_fractional_step) >> 14;
  360. X      if (red > MaxRgb)
  361. X        q->red=MaxRgb;
  362. X      else
  363. X        if (red < 0)
  364. X          q->red=0;
  365. X        else
  366. X          q->red=(unsigned char) red;
  367. X      green=(last_pixel.green*((1 << 14)-int_fractional_step)+background.green*
  368. X        int_fractional_step) >> 14;
  369. X      if (green > MaxRgb)
  370. X        q->green=MaxRgb;
  371. X      else
  372. X        if (green < 0)
  373. X          q->green=0;
  374. X        else
  375. X          q->green=(unsigned char) green;
  376. X      blue=(last_pixel.blue*((1 << 14)-int_fractional_step)+background.blue*
  377. X        int_fractional_step) >> 14;
  378. X      if (blue > MaxRgb)
  379. X        q->blue=MaxRgb;
  380. X      else
  381. X        if (blue < 0)
  382. X          q->blue=0;
  383. X        else
  384. X          q->blue=(unsigned char) blue;
  385. X      for (i=0; i < step-1; i++)
  386. X      {
  387. X        q-=source_columns;
  388. X        *q=background;
  389. X      }
  390. X      break;
  391. X    }
  392. X  }
  393. X  return;
  394. }
  395. X
  396. /*
  397. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  398. %                                                                             %
  399. %                                                                             %
  400. %                                                                             %
  401. %   I n t e g r a l R o t a t i o n                                           %
  402. %                                                                             %
  403. %                                                                             %
  404. %                                                                             %
  405. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  406. %
  407. %  Function IntegralRotation rotates the source image starting at location
  408. %  (x,y) an integral of 90 degrees and copies the result to the rotated image
  409. %  buffer.
  410. %
  411. %  The format of the IntegralRotation routine is:
  412. %
  413. %      IntegralRotation(image,source_columns,source_rows,rotated_image,
  414. %        rotated_columns,x,y,rotations)
  415. %
  416. %  A description of each parameter follows.
  417. %
  418. %    o source_image: A pointer to a Image structure containing the source
  419. %      image.
  420. %
  421. %    o source_columns: Specifies the number of columns of pixels in the
  422. %      source image.
  423. %
  424. %    o source_rows: Specifies the number of rows of pixels in the source
  425. %      image.
  426. %
  427. %    o rotated_image: A pointer to a ColorPacket structure containing the
  428. %      rotated image.
  429. %
  430. %    o rotated_columns: Specifies the number of columns of pixels in the
  431. %      rotated image.
  432. %
  433. %    o x: Specifies the x offset in the source image.
  434. %
  435. %    o y: Specifies the y offset in the source image.
  436. %
  437. %    o rotations: Specifies the number of 90 degree rotations.
  438. %
  439. %
  440. */
  441. static void IntegralRotation(image,source_columns,source_rows,rotated_image,
  442. X  rotated_columns,x,y,rotations)
  443. Image
  444. X  *image;
  445. X
  446. unsigned int
  447. X  source_columns,
  448. X  source_rows;
  449. X
  450. ColorPacket
  451. X  *rotated_image;
  452. X
  453. unsigned int
  454. X  rotated_columns,
  455. X  x,
  456. X  y,
  457. X  rotations;
  458. {
  459. X  ColorPacket
  460. X    *q;
  461. X
  462. X  register RunlengthPacket
  463. X    *p;
  464. X
  465. X  register int
  466. X    i,
  467. X    j;
  468. X
  469. X  /*
  470. X    Expand runlength packets into a rectangular array of pixels.
  471. X  */
  472. X  p=image->pixels;
  473. X  image->runlength=p->length+1;
  474. X  switch (rotations)
  475. X  {
  476. X    case 0:
  477. X    {
  478. X      /*
  479. X        Rotate 0 degrees.
  480. X      */
  481. X      for (j=0; j < source_rows; j++)
  482. X      {
  483. X        q=rotated_image+rotated_columns*(y+j)+x;
  484. X        for (i=0; i < source_columns; i++)
  485. X        {
  486. X          if (image->runlength > 0)
  487. X            image->runlength--;
  488. X          else
  489. X            {
  490. X              p++;
  491. X              image->runlength=p->length;
  492. X            }
  493. X          q->red=p->red;
  494. X          q->green=p->green;
  495. X          q->blue=p->blue;
  496. X          q->index=p->index;
  497. X          q++;
  498. X        }
  499. X      }
  500. X      break;
  501. X    }
  502. X    case 1:
  503. X    {
  504. X      /*
  505. X        Rotate 90 degrees.
  506. X      */
  507. X      for (j=source_columns-1; j >= 0; j--)
  508. X      {
  509. X        q=rotated_image+rotated_columns*y+x+j;
  510. X        for (i=0; i < source_rows; i++)
  511. X        {
  512. X          if (image->runlength > 0)
  513. X            image->runlength--;
  514. X          else
  515. X            {
  516. X              p++;
  517. X              image->runlength=p->length;
  518. X            }
  519. X          q->red=p->red;
  520. X          q->green=p->green;
  521. X          q->blue=p->blue;
  522. X          q->index=p->index;
  523. X          q+=rotated_columns;
  524. X        }
  525. X      }
  526. X      break;
  527. X    }
  528. X    case 2:
  529. X    {
  530. X      /*
  531. X        Rotate 180 degrees.
  532. X      */
  533. X      q=rotated_image;
  534. X      for (j=source_rows-1; j >= 0; j--)
  535. X      {
  536. X        q=rotated_image+rotated_columns*(y+j)+x+source_columns;
  537. X        for (i=0; i < source_columns; i++)
  538. X        {
  539. X          if (image->runlength > 0)
  540. X            image->runlength--;
  541. X          else
  542. X            {
  543. X              p++;
  544. X              image->runlength=p->length;
  545. X            }
  546. X          q--;
  547. X          q->red=p->red;
  548. X          q->green=p->green;
  549. X          q->blue=p->blue;
  550. X          q->index=p->index;
  551. X        }
  552. X      }
  553. X      break;
  554. X    }
  555. X    case 3:
  556. X    {
  557. X      /*
  558. X        Rotate 270 degrees.
  559. X      */
  560. X      for (j=0; j < source_columns; j++)
  561. X      {
  562. X        q=rotated_image+rotated_columns*(y+source_rows)+x+j-rotated_columns;
  563. X        for (i=0; i < source_rows; i++)
  564. X        {
  565. X          if (image->runlength > 0)
  566. X            image->runlength--;
  567. X          else
  568. X            {
  569. X              p++;
  570. X              image->runlength=p->length;
  571. X            }
  572. X          q->red=p->red;
  573. X          q->green=p->green;
  574. X          q->blue=p->blue;
  575. X          q->index=p->index;
  576. X          q-=rotated_columns;
  577. X        }
  578. X      }
  579. X      break;
  580. X    }
  581. X    default:
  582. X      break;
  583. X  }
  584. }
  585. X
  586. /*
  587. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  588. %                                                                             %
  589. %                                                                             %
  590. %                                                                             %
  591. %   R o w S h e a r                                                           %
  592. %                                                                             %
  593. %                                                                             %
  594. %                                                                             %
  595. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  596. %
  597. %  Procedure RowShear displaces a subrow of pixels a specified number of
  598. %  pixels.
  599. %
  600. %  The format of the RowShear routine is:
  601. %
  602. %      RowShear(source_image,source_columns,row,y,length,displacement,
  603. %        background)
  604. %
  605. %  A description of each parameter follows.
  606. %
  607. %    o source_image: A pointer to a ColorPacket structure.
  608. %
  609. %    o source_columns: Specifies the number of columns in the source image.
  610. %
  611. %    o row: Specifies which row in the image to move.
  612. %
  613. %    o y: Specifies the offset in the source image.
  614. %
  615. %    o length: Specifies the number of pixels to move.
  616. %
  617. %    o displacement: Specifies the number of pixels to displace the row of
  618. %      pixels.
  619. %
  620. %    o background: Specifies the background color.
  621. %
  622. %
  623. */
  624. static void RowShear(source_image,source_columns,row,x,length,displacement,
  625. X  background)
  626. ColorPacket
  627. X  *source_image;
  628. X
  629. unsigned int
  630. X  source_columns,
  631. X  row,
  632. X  x,
  633. X  length;
  634. X
  635. double
  636. X  displacement;
  637. X
  638. ColorPacket
  639. X  background;
  640. {
  641. X  ColorPacket
  642. X    last_pixel;
  643. X
  644. X  double
  645. X    fractional_step;
  646. X
  647. X  enum {LEFT,RIGHT}
  648. X    direction;
  649. X
  650. X  long int
  651. X    blue,
  652. X    green,
  653. X    int_fractional_step,
  654. X    red,
  655. X    step;
  656. X
  657. X  register ColorPacket
  658. X    *p,
  659. X    *q;
  660. X
  661. X  register int
  662. X    i;
  663. X
  664. X  if (displacement == 0.0)
  665. X    return;
  666. X  else
  667. X    if (displacement > 0.0)
  668. X      direction=RIGHT;
  669. X    else
  670. X      {
  671. X        displacement*=(-1.0);
  672. X        direction=LEFT;
  673. X      }
  674. X  step=(int) floor(displacement);
  675. X  fractional_step=displacement-(double)step;
  676. X  if (fractional_step == 0.0)
  677. X    {
  678. X      /*
  679. X        No fractional displacement-- just copy.
  680. X      */
  681. X      switch (direction)
  682. X      {
  683. X        case LEFT:
  684. X        {
  685. X          p=source_image+row*source_columns+x;
  686. X          q=p-step;
  687. X          for (i=0; i < length; i++)
  688. X          {
  689. X            *q=(*p);
  690. X            q++;
  691. X            p++;
  692. X          }
  693. X          /*
  694. X            Set old row to background color.
  695. X          */
  696. X          for (i=0; i < step; i++)
  697. X          {
  698. X            *q=background;
  699. X            q++;
  700. X          }
  701. X          break;
  702. X        }
  703. X        case RIGHT:
  704. X        {
  705. X          /*
  706. X            Right is the same as left except data is transferred backwards
  707. X            to prevent deleting data we need later.
  708. X          */
  709. X          p=source_image+row*source_columns+x+length;
  710. X          q=p+step;
  711. X          for (i=0; i < length; i++)
  712. X          {
  713. X            p--;
  714. X            q--;
  715. X            *q=(*p);
  716. X          }
  717. X          /*
  718. X            Set old row to background color.
  719. X          */
  720. X          for (i=0; i < step; i++)
  721. X          {
  722. X            q--;
  723. X            *q=background;
  724. X          }
  725. X          break;
  726. X        }
  727. X      }
  728. X      return;
  729. X    }
  730. X  /*
  731. X    Fractional displacement.
  732. X  */
  733. X  step++;
  734. X  int_fractional_step=(int) (((double) (1 << 14))*fractional_step);
  735. X  last_pixel=background;
  736. X  switch (direction)
  737. X  {
  738. X    case LEFT:
  739. X    {
  740. X      p=source_image+row*source_columns+x;
  741. X      q=p-step;
  742. X      for (i=0; i < length; i++)
  743. X      {
  744. X        red=(last_pixel.red*((1 << 14)-int_fractional_step)+p->red*
  745. X          int_fractional_step) >> 14;
  746. X        if (red > MaxRgb)
  747. X          q->red=MaxRgb;
  748. X        else
  749. X          if (red < 0)
  750. X            q->red=0;
  751. X          else
  752. X            q->red=(unsigned char) red;
  753. X        green=(last_pixel.green*((1 << 14)-int_fractional_step)+p->green*
  754. X          int_fractional_step) >> 14;
  755. X        if (green > MaxRgb)
  756. X          q->green=MaxRgb;
  757. X        else
  758. X          if (green < 0)
  759. X            q->green=0;
  760. X          else
  761. X            q->green=(unsigned char) green;
  762. X        blue=(last_pixel.blue*((1 << 14)-int_fractional_step)+p->blue*
  763. X          int_fractional_step) >> 14;
  764. X        if (blue > MaxRgb)
  765. X          q->blue=MaxRgb;
  766. X        else
  767. X          if (blue < 0)
  768. X            q->blue=0;
  769. X          else
  770. X            q->blue=(unsigned char) blue;
  771. X        last_pixel=(*p);
  772. X        p++;
  773. X        q++;
  774. X      }
  775. X      /*
  776. X        Set old row to background color.
  777. X      */
  778. X      red=(last_pixel.red*((1 << 14)-int_fractional_step)+background.red*
  779. X        int_fractional_step) >> 14;
  780. X      if (red > MaxRgb)
  781. X        q->red=MaxRgb;
  782. X      else
  783. X        if (red < 0)
  784. X          q->red=0;
  785. X        else
  786. X          q->red=(unsigned char) red;
  787. X      green=(last_pixel.green*((1 << 14)-int_fractional_step)+background.green*
  788. X        int_fractional_step) >> 14;
  789. X      if (green > MaxRgb)
  790. X        q->green=MaxRgb;
  791. X      else
  792. X        if (green < 0)
  793. X          q->green=0;
  794. X        else
  795. X          q->green=(unsigned ) green;
  796. X      blue=(last_pixel.blue*((1 << 14)-int_fractional_step)+background.blue*
  797. X        int_fractional_step) >> 14;
  798. X      if (blue > MaxRgb)
  799. X        q->blue=MaxRgb;
  800. X      else
  801. X        if (blue < 0)
  802. X          q->blue=0;
  803. X        else
  804. X          q->blue=(unsigned char) blue;
  805. X      q++;
  806. X      for (i=0; i < step-1; i++)
  807. X      {
  808. X        *q=background;
  809. X        q++;
  810. X      }
  811. X      break;
  812. X    }
  813. X    case RIGHT:
  814. X    {
  815. X      p=source_image+row*source_columns+x+length;
  816. X      q=p+step;
  817. X      for (i=0; i < length; i++)
  818. X      {
  819. X        p--;
  820. X        q--;
  821. X        red=(last_pixel.red*((1 << 14)-int_fractional_step)+p->red*
  822. X          int_fractional_step) >> 14;
  823. X        if (red > MaxRgb)
  824. X          q->red=MaxRgb;
  825. X        else
  826. X          if (red < 0)
  827. X            q->red=0;
  828. X          else
  829. X            q->red=(unsigned char) red;
  830. X        green=(last_pixel.green*((1 << 14)-int_fractional_step)+p->green*
  831. X          int_fractional_step) >> 14;
  832. X        if (green > MaxRgb)
  833. X          q->green=MaxRgb;
  834. X        else
  835. X          if (green < 0)
  836. X            q->green=0;
  837. X          else
  838. X            q->green=(unsigned char) green;
  839. X        blue=(last_pixel.blue*((1 << 14)-int_fractional_step)+p->blue*
  840. X          int_fractional_step) >> 14;
  841. X        if (blue > MaxRgb)
  842. X          blue=MaxRgb;
  843. X        else
  844. X          if (blue < 0)
  845. X            blue=0;
  846. X          else
  847. X            q->blue=(unsigned char) blue;
  848. X        last_pixel=(*p);
  849. X      }
  850. X      /*
  851. X        Set old row to background color.
  852. X      */
  853. X      q--;
  854. X      red=(last_pixel.red*((1 << 14)-int_fractional_step)+background.red*
  855. X        int_fractional_step) >> 14;
  856. X      if (red > MaxRgb)
  857. X        red=MaxRgb;
  858. X      else
  859. X        if (red < 0)
  860. X          red=0;
  861. X        else
  862. X          q->red=(unsigned char) red;
  863. X      green=(last_pixel.green*((1 << 14)-int_fractional_step)+background.green*
  864. X        int_fractional_step) >> 14;
  865. X      if (green > MaxRgb)
  866. X        green=MaxRgb;
  867. X      else
  868. X        if (green < 0)
  869. X          green=0;
  870. X        else
  871. X          q->green=(unsigned char) green;
  872. X      blue=(last_pixel.blue*((1 << 14)-int_fractional_step)+background.blue*
  873. X        int_fractional_step) >> 14;
  874. X      if (blue > MaxRgb)
  875. X        blue=MaxRgb;
  876. X      else
  877. X        if (blue < 0)
  878. X          blue=0;
  879. X        else
  880. X          q->blue=(unsigned char) blue;
  881. X      for (i=0; i < step-1; i++)
  882. X      {
  883. X        q--;
  884. X        *q=background;
  885. X      }
  886. X      break;
  887. X    }
  888. X  }
  889. X  return;
  890. }
  891. X
  892. /*
  893. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  894. %                                                                             %
  895. %                                                                             %
  896. %                                                                             %
  897. %   R o t a t e I m a g e                                                     %
  898. %                                                                             %
  899. %                                                                             %
  900. %                                                                             %
  901. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  902. %
  903. %  Function RotateImage creates a new image that is a rotated copy of an
  904. %  existing one.  It allocates the memory necessary for the new Image structure %  and returns a pointer to the new image.
  905. %
  906. %  Function RotateImage is based on the paper "A Fast Algorithm for General
  907. %  Raster Rotatation" by Alan W. Paeth.  RotateImage is adapted from a similiar
  908. %  routine based on the Paeth paper written by Michael Halle of the Spatial
  909. %  Imaging Group, MIT Media Lab.
  910. %
  911. %  The format of the RotateImage routine is:
  912. %
  913. %      RotateImage(image,degrees,clip)
  914. %
  915. %  A description of each parameter follows.
  916. %
  917. %    o status: Function RotateImage returns a pointer to the image after
  918. %      rotating.  A null image is returned if there is a memory shortage.
  919. %
  920. %    o image: The address of a structure of type Image;  returned from
  921. %      ReadImage.
  922. %
  923. %    o degrees: Specifies the number of degrees to rotate the image.
  924. %
  925. %    o clip: A value other than zero clips the corners of the rotated
  926. %      image and retains the original image size.
  927. %
  928. %
  929. */
  930. Image *RotateImage(image,degrees,clip)
  931. Image
  932. X  *image;
  933. X
  934. double
  935. X  degrees;
  936. X
  937. int
  938. X  clip;
  939. {
  940. #define DegreesToRadians(x) ((x)/180.0*3.14159265359)
  941. X
  942. X  ColorPacket
  943. X    background,
  944. X    *rotated_pixels;
  945. X
  946. X  double
  947. X    x_shear,
  948. X    y_shear;
  949. X
  950. X  extern Image
  951. X    *CopyImage();
  952. X
  953. X  extern void
  954. X    DestroyImage();
  955. X
  956. X  Image
  957. X    *rotated_image;
  958. X
  959. X  register ColorPacket
  960. X    *p;
  961. X
  962. X  register int
  963. X    i,
  964. X    x,
  965. X    y;
  966. X
  967. X  register RunlengthPacket
  968. X    *q;
  969. X
  970. X  unsigned int
  971. X    number_rows,
  972. X    number_columns,
  973. X    rotations,
  974. X    x_offset,
  975. X    y_offset,
  976. X    y_width;
  977. X
  978. X  /*
  979. X    Adjust rotation angle.
  980. X  */
  981. X  while (degrees < -45.0)
  982. X    degrees+=360.0;
  983. X  rotations=0;
  984. X  while (degrees > 45.0)
  985. X  {
  986. X    degrees-=90.0;
  987. X    rotations++;
  988. X  }
  989. X  rotations%=4;
  990. X  /*
  991. X    Calculate shear equations.
  992. X  */
  993. X  x_shear=(-tan(DegreesToRadians(degrees)/2.0));
  994. X  y_shear=sin(DegreesToRadians(degrees));
  995. X  if ((rotations == 1) || (rotations == 3))
  996. X    {
  997. X      /*
  998. X        Invert image size.
  999. X      */
  1000. X      y_width=image->rows+
  1001. X        (int) ceil(fabs(x_shear)*(double) (image->columns-1));
  1002. X      number_columns=image->rows+2*
  1003. X        (int) ceil(fabs(x_shear)*(double) (image->columns-1));
  1004. X      number_rows=image->columns+
  1005. X        (int) ceil(fabs(y_shear)*(double) (y_width-1));
  1006. X      rotated_image=CopyImage(image,number_columns,number_rows);
  1007. X      if (rotated_image == (Image *) NULL)
  1008. X        {
  1009. X          Warning("unable to rotate image","memory allocation failed");
  1010. X          return((Image *) NULL);
  1011. X        }
  1012. X      rotated_image->columns=image->rows;
  1013. X      rotated_image->rows=image->columns;
  1014. X    }
  1015. X  else
  1016. X    {
  1017. X      y_width=image->columns+
  1018. X        (int) ceil(fabs(x_shear)*(double) (image->rows-1));
  1019. X      number_columns=image->columns+2*
  1020. X        (int) ceil(fabs(x_shear)*(double) (image->rows-1));
  1021. X      number_rows=image->rows+
  1022. X        (int) ceil(fabs(y_shear)*(double) (y_width-1));
  1023. X      rotated_image=CopyImage(image,number_columns,number_rows);
  1024. X      if (rotated_image == (Image *) NULL)
  1025. X        {
  1026. X          Warning("unable to rotate image","memory allocation failed");
  1027. X          return((Image *) NULL);
  1028. X        }
  1029. X      rotated_image->columns=image->columns;
  1030. X      rotated_image->rows=image->rows;
  1031. X    }
  1032. X  /*
  1033. X    Initialize rotated image attributes.
  1034. X  */
  1035. X  rotated_pixels=(ColorPacket *)
  1036. X    malloc(number_columns*(number_rows+2)*sizeof(ColorPacket));
  1037. X  if (rotated_pixels == (ColorPacket *) NULL)
  1038. X    {
  1039. X      Warning("unable to rotate image","memory allocation failed");
  1040. X      return((Image *) NULL);
  1041. X    }
  1042. X  if ((x_shear == 0.0) || (y_shear == 0.0))
  1043. X    {
  1044. X      /*
  1045. X        No shearing required; do integral rotation.
  1046. X      */
  1047. X      x_offset=0;
  1048. X      y_offset=0;
  1049. X      IntegralRotation(image,rotated_image->columns,rotated_image->rows,
  1050. X        rotated_pixels+number_columns,number_columns,x_offset,y_offset,
  1051. X        rotations);
  1052. X    }
  1053. X  else
  1054. X    {
  1055. X      typedef struct Point
  1056. X      {
  1057. X        double
  1058. X          x,
  1059. X          y;
  1060. X      } Point;
  1061. X
  1062. X      double
  1063. X        x_max,
  1064. X        x_min,
  1065. X        y_max,
  1066. X        y_min;
  1067. X
  1068. X      Point
  1069. X        corners[4];
  1070. X
  1071. X      unsigned int
  1072. X        column,
  1073. X        row;
  1074. X
  1075. X      /*
  1076. X        Initialize rotated image buffer to background color.
  1077. X      */
  1078. X      rotated_image->class=DirectClass;
  1079. X      background.red=image->pixels[0].red;
  1080. X      background.green=image->pixels[0].green;
  1081. X      background.blue=image->pixels[0].blue;
  1082. X      p=rotated_pixels;
  1083. X      for (i=0; i < (number_columns*(number_rows+2)); i++)
  1084. X      {
  1085. X        *p=background;
  1086. X        p++;
  1087. X      }
  1088. X      /*
  1089. X        Perform an initial integral 90 degree rotation.
  1090. X      */
  1091. X      x_offset=(number_columns-rotated_image->columns)/2;
  1092. X      y_offset=(number_rows-rotated_image->rows)/2;
  1093. X      IntegralRotation(image,rotated_image->columns,rotated_image->rows,
  1094. X        rotated_pixels+number_columns,number_columns,x_offset,y_offset,
  1095. X        rotations);
  1096. X      /*
  1097. X        Perform a fractional rotation.  First, shear the image rows.
  1098. X      */
  1099. X      row=(number_rows-rotated_image->rows)/2;
  1100. X      for (i=0; i < rotated_image->rows; i++)
  1101. X      {
  1102. X        RowShear(rotated_pixels+number_columns,number_columns,row,x_offset,
  1103. X          rotated_image->columns,x_shear*
  1104. X          (((double) i)-(rotated_image->rows-1)/2.0),background);
  1105. X        row++;
  1106. X      }
  1107. X      /*
  1108. X        Shear the image columns.
  1109. X      */
  1110. X      column=(number_columns-y_width)/2;
  1111. X      for (i=0; i < y_width; i++)
  1112. X      {
  1113. X        ColumnShear(rotated_pixels+number_columns,number_columns,column,
  1114. X          y_offset,rotated_image->rows,y_shear*(((double) i)-(y_width-1)/2.0),
  1115. X          background);
  1116. X        column++;
  1117. X      }
  1118. X      /*
  1119. X        Shear the image rows again.
  1120. X      */
  1121. X      for (i=0; i < number_rows; i++)
  1122. X        RowShear(rotated_pixels+number_columns,number_columns,(unsigned int) i,
  1123. X          (number_columns-y_width)/2,y_width,x_shear*
  1124. X          (((double) i)-(number_rows-1)/2.0),background);
  1125. X      /*
  1126. X        Calculate the rotated image size.
  1127. X      */
  1128. X      corners[0].x=(-((int) rotated_image->columns)/2.0);
  1129. X      corners[0].y=(-((int) rotated_image->rows)/2.0);
  1130. X      corners[1].x=((int) rotated_image->columns)/2.0;
  1131. X      corners[1].y=(-((int) rotated_image->rows)/2.0);
  1132. X      corners[2].x=(-((int) rotated_image->columns)/2.0);
  1133. X      corners[2].y=((int) rotated_image->rows)/2.0;
  1134. X      corners[3].x=((int) rotated_image->columns)/2.0;
  1135. X      corners[3].y=((int) rotated_image->rows)/2.0;
  1136. X      for (i=0; i < 4; i++)
  1137. X      {
  1138. X        corners[i].x+=x_shear*corners[i].y;
  1139. X        corners[i].y+=y_shear*corners[i].x;
  1140. X        corners[i].x+=x_shear*corners[i].y;
  1141. X        corners[i].x+=(number_columns-1)/2.0;
  1142. X        corners[i].y+=(number_rows-1)/2.0;
  1143. X      }
  1144. X      x_min=corners[0].x;
  1145. X      y_min=corners[0].y;
  1146. X      x_max=corners[0].x;
  1147. X      y_max=corners[0].y;
  1148. X      for (i=1; i < 4; i++)
  1149. X      {
  1150. X        if (x_min > corners[i].x)
  1151. X          x_min=corners[i].x;
  1152. X        if (y_min > corners[i].y)
  1153. X          y_min=corners[i].y;
  1154. X        if (x_max < corners[i].x)
  1155. X          x_max=corners[i].x;
  1156. X        if (y_max < corners[i].y)
  1157. X          y_max=corners[i].y;
  1158. X      }
  1159. X      x_min=floor((double) x_min);
  1160. X      x_max=ceil((double) x_max);
  1161. X      y_min=floor((double) y_min);
  1162. X      y_max=ceil((double) y_max);
  1163. X      if (!clip)
  1164. X        {
  1165. X          /*
  1166. X            Rotated image is not clipped.
  1167. X          */
  1168. X          rotated_image->columns=(unsigned int) (x_max-x_min);
  1169. X          rotated_image->rows=(unsigned int) (y_max-y_min);
  1170. X        }
  1171. X      x_offset=(int) x_min+((int) (x_max-x_min)-rotated_image->columns)/2;
  1172. X      y_offset=(int) y_min+((int) (y_max-y_min)-rotated_image->rows)/2;
  1173. X    }
  1174. X  /*
  1175. X    Convert the rectangular array of pixels to runlength packets.
  1176. X  */
  1177. X  rotated_image->packets=0;
  1178. X  q=rotated_image->pixels;
  1179. X  q->length=MaxRunlength;
  1180. X  for (y=0; y < rotated_image->rows; y++)
  1181. X  {
  1182. X    p=rotated_pixels+number_columns+(y+y_offset)*number_columns+x_offset;
  1183. X    for (x=0; x < rotated_image->columns; x++)
  1184. X    {
  1185. X      if ((p->red == q->red) && (p->green == q->green) &&
  1186. X          (p->blue == q->blue) && (q->length < MaxRunlength))
  1187. X        q->length++;
  1188. X      else
  1189. X        {
  1190. X          if (rotated_image->packets > 0)
  1191. X            q++;
  1192. X          rotated_image->packets++;
  1193. X          q->red=p->red;
  1194. X          q->green=p->green;
  1195. X          q->blue=p->blue;
  1196. X          q->index=p->index;
  1197. X          q->length=0;
  1198. X        }
  1199. X      p++;
  1200. X    }
  1201. X  }
  1202. X  (void) free((char *) rotated_pixels);
  1203. X  rotated_image->pixels=(RunlengthPacket *) realloc((char *)
  1204. X    rotated_image->pixels,rotated_image->packets*sizeof(RunlengthPacket));
  1205. X  return(rotated_image);
  1206. }
  1207. SHAR_EOF
  1208. echo 'File ImageMagick/rotate.c is complete' &&
  1209. chmod 0755 ImageMagick/rotate.c ||
  1210. echo 'restore of ImageMagick/rotate.c failed'
  1211. Wc_c="`wc -c < 'ImageMagick/rotate.c'`"
  1212. test 32713 -eq "$Wc_c" ||
  1213.     echo 'ImageMagick/rotate.c: original size 32713, current size' "$Wc_c"
  1214. rm -f _shar_wnt_.tmp
  1215. fi
  1216. # ============= ImageMagick/compress.c ==============
  1217. if test -f 'ImageMagick/compress.c' -a X"$1" != X"-c"; then
  1218.     echo 'x - skipping ImageMagick/compress.c (File already exists)'
  1219.     rm -f _shar_wnt_.tmp
  1220. else
  1221. > _shar_wnt_.tmp
  1222. echo 'x - extracting ImageMagick/compress.c (Text)'
  1223. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/compress.c' &&
  1224. /*
  1225. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1226. %                                                                             %
  1227. %                                                                             %
  1228. %                                                                             %
  1229. %           CCCC   OOO   M   M  PPPP   RRRR   EEEEE   SSSSS  SSSSS            %
  1230. %          C      O   O  MM MM  P   P  R   R  E       SS     SS               %
  1231. %          C      O   O  M M M  PPPP   RRRR   EEE      SSS    SSS             %
  1232. %          C      O   O  M   M  P      R R    E          SS     SS            %
  1233. %           CCCC   OOO   M   M  P      R  R   EEEEE   SSSSS  SSSSS            %
  1234. %                                                                             %
  1235. %                                                                             %
  1236. %                    Q-Coder Image Compression Algorithm                      %
  1237. %                                                                             %
  1238. %                                                                             %
  1239. %                                                                             %
  1240. %                           Software Design                                   %
  1241. %                             John Cristy                                     %
  1242. %                            January  1991                                    %
  1243. %                                                                             %
  1244. %                                                                             %
  1245. %  Copyright 1991 E. I. Dupont de Nemours & Company                           %
  1246. %                                                                             %
  1247. %  Permission to use, copy, modify, distribute, and sell this software and    %
  1248. %  its documentation for any purpose is hereby granted without fee,           %
  1249. %  provided that the above Copyright notice appear in all copies and that     %
  1250. %  both that Copyright notice and this permission notice appear in            %
  1251. %  supporting documentation, and that the name of E. I. Dupont de Nemours     %
  1252. %  & Company not be used in advertising or publicity pertaining to            %
  1253. %  distribution of the software without specific, written prior               %
  1254. %  permission.  E. I. Dupont de Nemours & Company makes no representations    %
  1255. %  about the suitability of this software for any purpose.  It is provided    %
  1256. %  "as is" without express or implied warranty.                               %
  1257. %                                                                             %
  1258. %  E. I. Dupont de Nemours & Company disclaims all warranties with regard     %
  1259. %  to this software, including all implied warranties of merchantability      %
  1260. %  and fitness, in no event shall E. I. Dupont de Nemours & Company be        %
  1261. %  liable for any special, indirect or consequential damages or any           %
  1262. %  damages whatsoever resulting from loss of use, data or profits, whether    %
  1263. %  in an action of contract, negligence or other tortious action, arising     %
  1264. %  out of or in connection with the use or performance of this software.      %
  1265. %                                                                             %
  1266. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1267. %
  1268. %  Procedures QEncodeImage and QDecodeImage is based on the document
  1269. %  "JPEG-9-R6 Working Draft for Develpment of JPEG CD", 14 January 1991.
  1270. %  These routines do not yet fully implement the lossless JPEG compression,
  1271. %  but will some time in the future.
  1272. %
  1273. %
  1274. */
  1275. X
  1276. /*
  1277. X  Include declarations.
  1278. */
  1279. #include "display.h"
  1280. /*
  1281. X  Define declarations.
  1282. */
  1283. #define LowerBound  0
  1284. #define MaxContextStates  121  
  1285. #define MinimumIntervalD  (unsigned short) 0xf000  /* ~-0.75 */
  1286. #define MinimumIntervalE  (unsigned short) 0x1000  /* ~0.75 */
  1287. #define No  0
  1288. #define UpperBound  2
  1289. #define Yes  1
  1290. /*
  1291. X  State classification.
  1292. */
  1293. #define ZeroState  0
  1294. #define SmallPostitiveState  1
  1295. #define SmallNegativeState  2
  1296. #define LargePostitiveState  3
  1297. #define LargeNegativeState  4
  1298. /*
  1299. X  Typedef declarations.
  1300. */
  1301. typedef struct _ScanlinePacket
  1302. {
  1303. X  unsigned char
  1304. X    pixel;
  1305. X
  1306. X  int
  1307. X    state;
  1308. } ScanlinePacket;
  1309. /*
  1310. X  Initialized declarations.
  1311. */
  1312. int decrement_less_probable[]=
  1313. {
  1314. X  0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 
  1315. X  2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 3, 2, 3, 2
  1316. };
  1317. X
  1318. int increment_more_probable[]=
  1319. {
  1320. X  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  1321. X  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0
  1322. };
  1323. X
  1324. int more_probable_exchange[]=
  1325. {
  1326. X  1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
  1327. X  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  1328. };
  1329. X
  1330. int statistics[][5]=
  1331. {
  1332. X   0,  4,  8, 12, 16, 
  1333. X  20, 24, 28, 32, 36, 
  1334. X  40, 44, 48, 52, 56, 
  1335. X  60, 64, 68, 72, 76, 
  1336. X  80, 84, 88, 92, 96,
  1337. };
  1338. X
  1339. unsigned short probability[]=
  1340. {
  1341. X  0x0ac1, 0x0a81, 0x0a01, 0x0901, 0x0701, 0x0681,
  1342. X  0x0601, 0x0501, 0x0481, 0x0441, 0x0381, 0x0301,
  1343. X  0x02c1, 0x0281, 0x0241, 0x0181, 0x0121, 0x00e1,
  1344. X  0x00a1, 0x0071, 0x0059, 0x0053, 0x0027, 0x0017,
  1345. X  0x0013, 0x000b, 0x0007, 0x0005, 0x0003, 0x0001
  1346. };
  1347. /*
  1348. X  Declarations and initializations for q-coder.
  1349. */
  1350. int
  1351. X  code,
  1352. X  less_probable[MaxContextStates],
  1353. X  more_probable[MaxContextStates],
  1354. X  probability_estimate[MaxContextStates];
  1355. X
  1356. unsigned char
  1357. X  *q;  
  1358. X
  1359. unsigned short
  1360. X  interval;
  1361. X
  1362. /*
  1363. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1364. %                                                                             %
  1365. %                                                                             %
  1366. %                                                                             %
  1367. %   D e c o d e                                                               %
  1368. %                                                                             %
  1369. %                                                                             %
  1370. %                                                                             %
  1371. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1372. %
  1373. %  Function Decode uncompresses a string.
  1374. %
  1375. %  The format of the Decode routine is:
  1376. %
  1377. %      (void) Decode(state,decision)
  1378. %
  1379. %  A description of each parameter follows:
  1380. %
  1381. %    o state:  An integer value representing the current state.
  1382. %
  1383. %    o decision:  A pointer to an integer.  The output of the binary
  1384. %      decision (Yes/No) is returned in this value.
  1385. %
  1386. %
  1387. */
  1388. void Decode(state,decision)
  1389. register int
  1390. X  state,
  1391. X  *decision;
  1392. {
  1393. X  interval+=probability[probability_estimate[state]];
  1394. X  if (((code >> 16) & 0xffff) < interval)
  1395. X    {
  1396. X      code-=(interval << 16);
  1397. X      interval=(-probability[probability_estimate[state]]);
  1398. X      *decision=less_probable[state];
  1399. X    }
  1400. X  else
  1401. X    {
  1402. X      *decision=more_probable[state];
  1403. X      if (interval <= MinimumIntervalD)
  1404. X        return;
  1405. X    }
  1406. X  do
  1407. X  {
  1408. X    if ((code & 0xff) == 0)
  1409. X      {
  1410. X        code&=0xffff0000;
  1411. X        if ((*q++) == 0xff)
  1412. X          code+=((*q) << 9)+0x02;
  1413. X        else
  1414. X          code+=((*q) << 8)+0x01;
  1415. X      }
  1416. X    interval<<=1;
  1417. X    code<<=1;
  1418. X  } while (interval > MinimumIntervalD);
  1419. X  /*
  1420. X    Update probability estimates
  1421. X  */
  1422. X  if (*decision == more_probable[state])
  1423. X    probability_estimate[state]+=
  1424. X      increment_more_probable[probability_estimate[state]];
  1425. X  else
  1426. X    probability_estimate[state]-=
  1427. X      decrement_less_probable[probability_estimate[state]];
  1428. X  if (more_probable_exchange[probability_estimate[state]] != 0)
  1429. X    {
  1430. X      /*
  1431. X        Exchange sense of most probable and least probable.
  1432. X      */
  1433. X      less_probable[state]=more_probable[state];
  1434. X      more_probable[state]=1-more_probable[state];
  1435. X    }
  1436. }
  1437. X
  1438. /*
  1439. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1440. %                                                                             %
  1441. %                                                                             %
  1442. %                                                                             %
  1443. %   E n c o d e                                                               %
  1444. %                                                                             %
  1445. %                                                                             %
  1446. %                                                                             %
  1447. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1448. %
  1449. %  Function Encode generate compressed data string by encoding yes-no decision
  1450. %  given state s.
  1451. %
  1452. %  The format of the Encode routine is:
  1453. %
  1454. %      (void) Encode(state,decision)
  1455. %
  1456. %  A description of each parameter follows:
  1457. %
  1458. %    o state:  An integer value representing the current state.
  1459. %
  1460. %    o decision:  An integer value representing a binary decision.
  1461. %
  1462. %
  1463. */
  1464. void Encode(state,decision)
  1465. register int
  1466. X  state,
  1467. X  decision;
  1468. {
  1469. X  /*
  1470. X    Test on "most-probable-symbol" for state s(more_probable[state])
  1471. X  */
  1472. X  interval-=probability[probability_estimate[state]];
  1473. X  if (more_probable[state] != decision)
  1474. X    {
  1475. X      code-=interval;
  1476. X      interval=probability[probability_estimate[state]];
  1477. X    }
  1478. X  else
  1479. X    if (interval >= MinimumIntervalE)
  1480. X      return;
  1481. X  /*
  1482. X    Encoder renormalization.
  1483. X  */
  1484. X  do
  1485. X  {
  1486. X    interval<<=1;
  1487. X    if (code >= 0)
  1488. X      code<<=1;
  1489. X    else
  1490. X      {
  1491. X        /*
  1492. X          Shift unsigned char of data from Code register to compressed string.
  1493. X        */
  1494. X        code<<=1;
  1495. X        if (code > 0)
  1496. X          {
  1497. X            /*
  1498. X              Add eight bits from Code register to compressed data string.
  1499. X            */
  1500. X            (*q++)--;
  1501. X            *q=(unsigned char) (code >> 16);
  1502. X            code&=0x0000ffff;
  1503. X            code|=0x01800000;
  1504. X          }
  1505. X        else
  1506. X          {
  1507. X            code&=0x01ffffff;
  1508. X            if (interval > code)
  1509. X              {
  1510. X                /*
  1511. X                  Add eight bits from Code register to compressed data string.
  1512. X                */
  1513. X                (*q++)--;
  1514. X                *q=0xff;
  1515. X                code|=0x01810000;
  1516. X              }
  1517. X            else
  1518. X              if ((*q++) == 0xff)
  1519. X                {
  1520. X                  /*
  1521. X                    Add seven bits from Code register plus one stuffed bit to
  1522. X                    compressed data string.
  1523. X                  */
  1524. X                  *q=(unsigned char) (code >> 17);
  1525. X                  code&=0x0001ffff;
  1526. X                  code|=0x03000000;
  1527. X                }
  1528. X              else
  1529. X                {
  1530. X                  /*
  1531. X                    Add eight bits from Code register to compressed data string.
  1532. X                  */
  1533. X                  *q=(unsigned char) (code >> 16);
  1534. X                  code&=0x0000ffff;
  1535. X                  code|=0x01800000;
  1536. X                }
  1537. X          }
  1538. X      }
  1539. X  } while (interval < MinimumIntervalE);
  1540. X  /*
  1541. X    Update probability estimates
  1542. X  */
  1543. X  if (decision == more_probable[state])
  1544. X    probability_estimate[state]+=
  1545. X      increment_more_probable[probability_estimate[state]];
  1546. X  else
  1547. X    probability_estimate[state]-=
  1548. X      decrement_less_probable[probability_estimate[state]];
  1549. X  if (more_probable_exchange[probability_estimate[state]] != 0)
  1550. X    more_probable[state]=1-more_probable[state];
  1551. }
  1552. X
  1553. /*
  1554. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1555. %                                                                             %
  1556. %                                                                             %
  1557. %                                                                             %
  1558. %   F l u s h                                                                 %
  1559. %                                                                             %
  1560. %                                                                             %
  1561. %                                                                             %
  1562. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1563. %
  1564. %  Function Flush flushes the final bits of data from the Code register to the
  1565. %  compressed data string.
  1566. %
  1567. %  The format of the Flush routine is:
  1568. %
  1569. %      (void) Flush()
  1570. %
  1571. %
  1572. */
  1573. void Flush()
  1574. {
  1575. X  register int
  1576. X    extra_bits;
  1577. X
  1578. X  code-=interval;
  1579. X  extra_bits=24;
  1580. X  extra_bits--;
  1581. X  while (code >= 0)
  1582. X  {
  1583. X    code<<=1;
  1584. X    extra_bits--;
  1585. X  }
  1586. X  code<<=1;
  1587. X  if (code > 0)
  1588. X    (*q)--;
  1589. X  /*
  1590. X    Add the final compressed data unsigned chars to the compressed data string.
  1591. X  */
  1592. X  do
  1593. X  {
  1594. X    if ((*q++) == 0xff)
  1595. X      {
  1596. X        /*
  1597. X          Add seven bits of data plus one stuffed bit to the compressed data
  1598. X          string during final Flush of Code register.
  1599. X        */
  1600. X        *q=(unsigned char) (code >> 17);
  1601. X        code&=0x0001ffff;
  1602. X        code<<=7;
  1603. X        extra_bits-=7;
  1604. X      }
  1605. X    else
  1606. X      {
  1607. X        /*
  1608. X           Add eight bits of data to the compressed data string during final
  1609. X           flush of Code register.
  1610. X        */
  1611. X        *q=(unsigned char) (code >> 16);
  1612. X        code&=0x0000ffff;
  1613. X        code<<=8;
  1614. X        extra_bits-=8;
  1615. X      }
  1616. X  } while (extra_bits > 0);
  1617. X  q++;
  1618. }
  1619. X
  1620. /*
  1621. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1622. %                                                                             %
  1623. %                                                                             %
  1624. %                                                                             %
  1625. %   Q D e c o d e I m a g e                                                   %
  1626. %                                                                             %
  1627. %                                                                             %
  1628. %                                                                             %
  1629. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1630. %
  1631. %  Function QDecodeImage uncompresses an image via Q-coding.
  1632. %
  1633. %  The format of the QDecodeImage routine is:
  1634. %
  1635. %      count=QDecodeImage(compressed_pixels,pixels,number_columns,number_rows)
  1636. %
  1637. %  A description of each parameter follows:
  1638. %
  1639. %    o count:  The QDecodeImage routine returns this integer value.  It is
  1640. %      the actual number of pixels created by the decompression process. 
  1641. %
  1642. %    o compressed_pixels:  The address of a byte (8 bits) array of compressed
  1643. %      pixel data.
  1644. %
  1645. %    o pixels:  The address of a byte (8 bits) array of pixel data created by 
  1646. %      the uncompression process.  The number of bytes in this array
  1647. %      must be at least equal to the number columns times the number of rows
  1648. %      of the source pixels.
  1649. %
  1650. %    o number_columns:  An integer value that is the number of columns or
  1651. %      width in pixels of your source image.
  1652. %
  1653. %    o number_rows:  An integer value that is the number of rows or
  1654. %      heigth in pixels of your source image.
  1655. %
  1656. %
  1657. */
  1658. unsigned int QDecodeImage(compressed_pixels,pixels,number_columns,number_rows)
  1659. unsigned char
  1660. X  *compressed_pixels,
  1661. X  *pixels;
  1662. X
  1663. unsigned int
  1664. X  number_columns,
  1665. X  number_rows;
  1666. {
  1667. X  int
  1668. X    decision,
  1669. X    i,
  1670. X    prediction,
  1671. X    row;
  1672. X
  1673. X  register int
  1674. X    column,
  1675. X    magnitude,
  1676. X    sign,
  1677. X    state,
  1678. X    value;
  1679. X
  1680. X  register ScanlinePacket
  1681. X    *cs,
  1682. X    *ls;
  1683. X
  1684. X  register unsigned char
  1685. X    *p;
  1686. X
  1687. X  ScanlinePacket
  1688. X    *scanline;
  1689. X
  1690. X  for (i=0; i < MaxContextStates; i++)
  1691. X  {
  1692. X    probability_estimate[i]=0;
  1693. X    more_probable[i]=0;
  1694. X    less_probable[i]=1;
  1695. X  }
  1696. X  /*
  1697. X    Allocate scanline for row values and states
  1698. X  */
  1699. X  scanline=(ScanlinePacket *)
  1700. X    malloc((unsigned int) (2*(number_columns+1)*sizeof(ScanlinePacket)));
  1701. X  if (scanline == (ScanlinePacket *) NULL)
  1702. X    {
  1703. X      Warning("unable to compress image, unable to allocate memory",
  1704. X        (char *) NULL);
  1705. X      exit(1);
  1706. X    }
  1707. X  cs=scanline;
  1708. X  for (i=0; i < 2*(number_columns+1); i++)
  1709. X  {
  1710. X    cs->pixel=0;
  1711. X    cs->state=ZeroState;
  1712. X    cs++;
  1713. X  }
  1714. X  interval=MinimumIntervalD;
  1715. X  p=pixels;
  1716. X  q=compressed_pixels+1;
  1717. X  /*
  1718. X    Add a new unsigned char of compressed data to the Code register.
  1719. X  */
  1720. X  code=(*q) << 16;
  1721. X  if ((*q++) == 0xff)
  1722. X    code+=((*q) << 9)+0x02;
  1723. X  else
  1724. X    code+=((*q) << 8)+0x01;
  1725. X  code<<=4;
  1726. X  code+=(interval << 16);
  1727. X  /*
  1728. X    Decode each image scanline.
  1729. X  */
  1730. X  for (row=0; row < number_rows; row++)
  1731. X  {
  1732. X    ls=scanline+(number_columns+1)*((row+0) % 2);
  1733. X    cs=scanline+(number_columns+1)*((row+1) % 2);
  1734. X    for (column=0; column < number_columns; column++)
  1735. X    {
  1736. X      prediction=(int) cs->pixel-(int) ls->pixel;
  1737. X      ls++;
  1738. X      prediction+=(int) ls->pixel;
  1739. X      state=statistics[cs->state][ls->state];
  1740. X      cs++;
  1741. X      cs->state=ZeroState;
  1742. X      /*
  1743. X        Branch for zero code value
  1744. X      */
  1745. X      (void) Decode(state,&decision);
  1746. X      if (decision == No)
  1747. X        value=0;
  1748. X      else
  1749. X        {
  1750. X          /*
  1751. X            Decode sign information
  1752. X          */
  1753. X          state++;
  1754. X          (void) Decode(state,&decision);
  1755. X          if (decision == Yes)
  1756. X            sign=(-1);
  1757. X          else
  1758. X            {
  1759. X              sign=1;
  1760. X              state++;
  1761. X            }
  1762. X          state++;
  1763. X          /*
  1764. X            Branch for value=+-1
  1765. X          */
  1766. X          (void) Decode(state,&decision);
  1767. X          if (decision == No)
  1768. X            value=1;
  1769. X          else
  1770. X            {
  1771. X              /*
  1772. X                Establish magnitude of value.
  1773. X              */
  1774. X              magnitude=2;
  1775. X              state=100;
  1776. X              (void) Decode(state,&decision);
  1777. X              while (decision != No)
  1778. X              {
  1779. X                if (state < 107)
  1780. X                  state++;
  1781. X                magnitude<<=1;
  1782. X                (void) Decode(state,&decision);
  1783. X              }
  1784. X              /*
  1785. X                Code remaining bits.
  1786. X              */
  1787. X              state+=7;
  1788. X              value=1;
  1789. X              magnitude>>=2;
  1790. X              if (magnitude != 0)
  1791. X                {
  1792. X                  (void) Decode(state,&decision);
  1793. X                  state+=6;
  1794. X                  value=(value << 1) | decision;
  1795. X                  magnitude>>=1;
  1796. X                  while (magnitude != 0)
  1797. X                  {
  1798. X                    (void) Decode(state,&decision);
  1799. X                    value=(value << 1) | decision;
  1800. X                    magnitude>>=1;
  1801. X                  }
  1802. X                }
  1803. X              value++;
  1804. X            }
  1805. X          if (value > LowerBound)
  1806. X            if (value <= UpperBound)
  1807. X              cs->state=
  1808. X                (sign < ZeroState ? SmallPostitiveState : SmallNegativeState);
  1809. X            else
  1810. X              cs->state=
  1811. X                (sign < ZeroState ? LargePostitiveState : LargeNegativeState);
  1812. X          if (sign < 0)
  1813. X            value=(-value);
  1814. X        }
  1815. X      cs->pixel=(unsigned char) (value+prediction);
  1816. X      *p++=cs->pixel;
  1817. X    }
  1818. X  }
  1819. X  (void) free((char *) scanline);
  1820. X  return((unsigned int) (p-pixels));
  1821. }
  1822. X
  1823. /*
  1824. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1825. %                                                                             %
  1826. %                                                                             %
  1827. %                                                                             %
  1828. %   Q E n c o d e I m a g e                                                   %
  1829. %                                                                             %
  1830. %                                                                             %
  1831. %                                                                             %
  1832. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1833. %
  1834. %  Function QEncodeImage compresses an image via q-coding.
  1835. %
  1836. %  The format of the QEncodeImage routine is:
  1837. %
  1838. %      count=QEncodeImage(pixels,compressed_pixels,number_columns,
  1839. %        number_rows)
  1840. %
  1841. %  A description of each parameter follows:
  1842. %
  1843. %    o count:  The QEncodeImage routine returns this integer value.  It is
  1844. %      the actual number of compressed pixels created by the compression
  1845. %      process. 
  1846. %
  1847. %    o pixels:  The address of a byte (8 bits) array of pixel data.
  1848. %
  1849. %    o compressed_pixels:  The address of a byte (8 bits) array of pixel data
  1850. %      created by the compression process.  The number of bytes in this array
  1851. %      must be at least equal to the number columns times the number of rows
  1852. %      of the source pixels to allow for the possibility that no compression
  1853. %      is possible.  The actual number of bytes used is reflected by the
  1854. %      count parameter.
  1855. %
  1856. %    o number_columns:  An integer value that is the number of columns or
  1857. %      width in pixels of your source image.
  1858. %
  1859. %    o number_rows:  An integer value that is the number of rows or
  1860. %      heigth in pixels of your source image.
  1861. %
  1862. %
  1863. %
  1864. */
  1865. unsigned int QEncodeImage(pixels,compressed_pixels,number_columns,number_rows)
  1866. unsigned char
  1867. X  *pixels,
  1868. X  *compressed_pixels;
  1869. X
  1870. unsigned int
  1871. X  number_columns,
  1872. X  number_rows;
  1873. {
  1874. X  int
  1875. X    i,
  1876. X    prediction,
  1877. X    row;
  1878. X
  1879. X  register int
  1880. X    column,
  1881. X    magnitude,
  1882. X    sign,
  1883. X    state,
  1884. X    value;
  1885. X
  1886. X  register ScanlinePacket
  1887. X    *cs,
  1888. X    *ls;
  1889. X
  1890. X  register unsigned char
  1891. X    *p;
  1892. X
  1893. X  ScanlinePacket
  1894. X    *scanline;
  1895. X
  1896. X  void
  1897. X    Encode(),
  1898. X    Flush();
  1899. X
  1900. X  for (i=0; i < MaxContextStates; i++)
  1901. X  {
  1902. X    probability_estimate[i]=0;
  1903. X    more_probable[i]=0;
  1904. X  }
  1905. X  /*
  1906. X    Allocate scanline for row values and states.
  1907. X  */
  1908. X  scanline=(ScanlinePacket *)
  1909. X    malloc((unsigned int) (2*(number_columns+1)*sizeof(ScanlinePacket)));
  1910. X  if (scanline == (ScanlinePacket *) NULL)
  1911. X    {
  1912. X      Warning("unable to compress image, unable to allocate memory",
  1913. X        (char *) NULL);
  1914. X      exit(1);
  1915. X    }
  1916. X  cs=scanline;
  1917. X  for (i=0; i < 2*(number_columns+1); i++)
  1918. X  {
  1919. X    cs->pixel=0;
  1920. X    cs->state=ZeroState;
  1921. X    cs++;
  1922. X  }
  1923. X  interval=MinimumIntervalE;
  1924. X  p=pixels;
  1925. X  q=compressed_pixels;
  1926. X  (*q)++;
  1927. X  code=0x00180000;
  1928. X  /*
  1929. X    Encode each scanline.
  1930. X  */
  1931. X  for (row=0; row < number_rows; row++)
  1932. X  {
  1933. X    ls=scanline+(number_columns+1)*((row+0) % 2);
  1934. X    cs=scanline+(number_columns+1)*((row+1) % 2);
  1935. X    for (column=0; column < number_columns; column++)
  1936. X    {
  1937. X      prediction=(int) cs->pixel-(int) ls->pixel;
  1938. X      ls++;
  1939. X      prediction+=(int) ls->pixel;
  1940. X      state=statistics[cs->state][ls->state];
  1941. X      cs++;
  1942. X      cs->pixel=(*p++);
  1943. X      cs->state=ZeroState;
  1944. X      value=(int) cs->pixel-prediction;
  1945. X      Encode(state,(value == 0 ? No : Yes));
  1946. X      if (value != 0)
  1947. X        {
  1948. X          /*
  1949. X            Code sign information
  1950. X          */
  1951. X          state++;
  1952. X          sign=(value < 0 ? -1 : 1);
  1953. X          Encode(state,(sign >= 0 ? No : Yes));
  1954. X          if (sign < 0)
  1955. X            value=(-value);
  1956. X          else
  1957. X            state++;
  1958. X          state++;
  1959. X          value--;
  1960. X          /*
  1961. X            Branch for code=+-1
  1962. X          */
  1963. X          Encode(state,(value == 0 ? No : Yes));
  1964. X          if (value != 0)
  1965. X            {
  1966. X              /*
  1967. X                Establish magnitude of value.
  1968. X              */
  1969. X              state=100;
  1970. X              magnitude=2;
  1971. X              while (value >= magnitude)
  1972. X              {
  1973. X                (void) Encode(state,Yes);
  1974. X                if (state < 107)
  1975. X                  state++;
  1976. X                magnitude<<=1;
  1977. X              }
  1978. X              (void) Encode(state,No);
  1979. X              /*
  1980. X                Code remaining bits
  1981. X              */
  1982. X              state+=7;
  1983. X              magnitude>>=2;
  1984. X              if (magnitude != 0)
  1985. X                {
  1986. X                  (void) Encode(state,((magnitude & value) == 0 ? No : Yes));
  1987. X                  state+=6;
  1988. X                  magnitude>>=1;
  1989. X                  while (magnitude != 0)
  1990. X                  {
  1991. X                    (void) Encode(state,((magnitude & value) == 0 ? No : Yes));
  1992. X                    magnitude>>=1;
  1993. X                  }
  1994. X                }
  1995. X            }
  1996. X          if (value >= LowerBound)
  1997. X            if (value < UpperBound)
  1998. X              cs->state=
  1999. X                (sign < ZeroState ? SmallPostitiveState : SmallNegativeState);
  2000. X            else
  2001. X              cs->state=
  2002. X                (sign < ZeroState ? LargePostitiveState : LargeNegativeState);
  2003. X        }
  2004. X    }
  2005. X  }
  2006. X  (void) Flush();
  2007. X  (void) free((char *) scanline);
  2008. X  return((unsigned int) (q-compressed_pixels));
  2009. }
  2010. SHAR_EOF
  2011. chmod 0755 ImageMagick/compress.c ||
  2012. echo 'restore of ImageMagick/compress.c failed'
  2013. Wc_c="`wc -c < 'ImageMagick/compress.c'`"
  2014. test 23716 -eq "$Wc_c" ||
  2015.     echo 'ImageMagick/compress.c: original size 23716, current size' "$Wc_c"
  2016. rm -f _shar_wnt_.tmp
  2017. fi
  2018. # ============= ImageMagick/image.h ==============
  2019. if test -f 'ImageMagick/image.h' -a X"$1" != X"-c"; then
  2020.     echo 'x - skipping ImageMagick/image.h (File already exists)'
  2021.     rm -f _shar_wnt_.tmp
  2022. else
  2023. > _shar_wnt_.tmp
  2024. echo 'x - extracting ImageMagick/image.h (Text)'
  2025. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/image.h' &&
  2026. X
  2027. /*
  2028. X  Define declarations.
  2029. */
  2030. #ifdef vms
  2031. #define pclose(file)  exit(1)
  2032. #define popen(command,mode)  exit(1)
  2033. #endif
  2034. /*
  2035. X  Image utilities routines.
  2036. */
  2037. extern Image
  2038. X  *CopyImage(),
  2039. X  *ClipImage(),
  2040. X  *EnhanceImage(),
  2041. X  *NoisyImage(),
  2042. X  *ReadImage(),
  2043. X  *ReduceImage(),
  2044. X  *ReflectImage(),
  2045. X  *RotateImage(),
  2046. X  *ScaleImage(),
  2047. X  *TransformImage(),
  2048. X  *ZoomImage();
  2049. X
  2050. extern unsigned int
  2051. X  NumberColors(),
  2052. X  PrintImage(),
  2053. X  ReadData(),
  2054. X  WriteImage();
  2055. X
  2056. extern void
  2057. X  DestroyImage(),
  2058. X  GammaImage(),
  2059. X  GrayImage(),
  2060. X  InverseImage(),
  2061. X  QuantizationError(),
  2062. X  QuantizeImage();
  2063. SHAR_EOF
  2064. chmod 0755 ImageMagick/image.h ||
  2065. echo 'restore of ImageMagick/image.h failed'
  2066. Wc_c="`wc -c < 'ImageMagick/image.h'`"
  2067. test 563 -eq "$Wc_c" ||
  2068.     echo 'ImageMagick/image.h: original size 563, current size' "$Wc_c"
  2069. rm -f _shar_wnt_.tmp
  2070. fi
  2071. # ============= ImageMagick/filters/Makefile ==============
  2072. if test ! -d 'ImageMagick/filters'; then
  2073.     echo 'x - creating directory ImageMagick/filters'
  2074.     mkdir 'ImageMagick/filters'
  2075. fi
  2076. if test -f 'ImageMagick/filters/Makefile' -a X"$1" != X"-c"; then
  2077.     echo 'x - skipping ImageMagick/filters/Makefile (File already exists)'
  2078.     rm -f _shar_wnt_.tmp
  2079. else
  2080. > _shar_wnt_.tmp
  2081. echo 'x - extracting ImageMagick/filters/Makefile (Text)'
  2082. sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/filters/Makefile' &&
  2083. # Makefile generated by imake - do not edit!
  2084. # $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $
  2085. #
  2086. # The cpp used on this machine replaces all newlines and multiple tabs and
  2087. # spaces in a macro expansion with a single space.  Imake tries to compensate
  2088. # for this, but is not always successful.
  2089. #
  2090. X
  2091. ###########################################################################
  2092. # Makefile generated from "Imake.tmpl" and <Imakefile>
  2093. # $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $
  2094. #
  2095. # Platform-specific parameters may be set in the appropriate .cf
  2096. # configuration files.  Site-wide parameters may be set in the file
  2097. # site.def.  Full rebuilds are recommended if any parameters are changed.
  2098. #
  2099. # If your C preprocessor doesn't define any unique symbols, you'll need
  2100. # to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  2101. # "make Makefile", "make Makefiles", or "make World").
  2102. #
  2103. # If you absolutely can't get imake to work, you'll need to set the
  2104. # variables at the top of each Makefile as well as the dependencies at the
  2105. # bottom (makedepend will do this automatically).
  2106. #
  2107. X
  2108. ###########################################################################
  2109. # platform-specific configuration parameters - edit sun.cf to change
  2110. X
  2111. # platform:  $XConsortium: sun.cf,v 1.38 89/12/23 16:10:10 jim Exp $
  2112. # operating system:  SunOS 4.0.3
  2113. X
  2114. ###########################################################################
  2115. # site-specific configuration parameters - edit site.def to change
  2116. X
  2117. # site:  $XConsortium: site.def,v 1.21 89/12/06 11:46:50 jim Exp $
  2118. X
  2119. X            SHELL = /bin/sh
  2120. X
  2121. X              TOP = .
  2122. X      CURRENT_DIR = .
  2123. X
  2124. X               AR = ar cq
  2125. X  BOOTSTRAPCFLAGS =
  2126. X               CC = cc
  2127. X
  2128. X         COMPRESS = compress
  2129. X              CPP = /lib/cpp $(STD_CPP_DEFINES)
  2130. X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
  2131. X          INSTALL = install
  2132. X               LD = ld
  2133. X             LINT = lint
  2134. X      LINTLIBFLAG = -C
  2135. X         LINTOPTS = -axz
  2136. X               LN = ln -s
  2137. X             MAKE = make
  2138. X               MV = mv
  2139. X               CP = cp
  2140. X           RANLIB = ranlib
  2141. X  RANLIBINSTFLAGS =
  2142. X               RM = rm -f
  2143. X     STD_INCLUDES =
  2144. X  STD_CPP_DEFINES =
  2145. X      STD_DEFINES =
  2146. X EXTRA_LOAD_FLAGS =
  2147. X  EXTRA_LIBRARIES =
  2148. X             TAGS = ctags
  2149. X
  2150. X    SHAREDCODEDEF = -DSHAREDCODE
  2151. X         SHLIBDEF = -DSUNSHLIB
  2152. X
  2153. X    PROTO_DEFINES =
  2154. X
  2155. X     INSTPGMFLAGS =
  2156. X
  2157. X     INSTBINFLAGS = -m 0755
  2158. X     INSTUIDFLAGS = -m 4755
  2159. X     INSTLIBFLAGS = -m 0664
  2160. X     INSTINCFLAGS = -m 0444
  2161. X     INSTMANFLAGS = -m 0444
  2162. X     INSTDATFLAGS = -m 0444
  2163. X    INSTKMEMFLAGS = -m 4755
  2164. X
  2165. X          DESTDIR =
  2166. X
  2167. X     TOP_INCLUDES = -I$(INCROOT)
  2168. X
  2169. X      CDEBUGFLAGS = -O
  2170. X        CCOPTIONS =
  2171. X      COMPATFLAGS =
  2172. X
  2173. X      ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES)
  2174. X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS)
  2175. X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
  2176. X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
  2177. X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  2178. X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS)
  2179. X   LDCOMBINEFLAGS = -X -r
  2180. X
  2181. X        MACROFILE = sun.cf
  2182. X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
  2183. X
  2184. X    IMAKE_DEFINES =
  2185. X
  2186. X         IRULESRC = $(CONFIGDIR)
  2187. X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
  2188. X
  2189. X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
  2190. X            $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
  2191. X            $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
  2192. X
  2193. ###########################################################################
  2194. # X Window System Build Parameters
  2195. # $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
  2196. X
  2197. ###########################################################################
  2198. # X Window System make variables; this need to be coordinated with rules
  2199. # $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
  2200. X
  2201. X          PATHSEP = /
  2202. X        USRLIBDIR = $(DESTDIR)/usr/lib
  2203. X           BINDIR = $(DESTDIR)/usr/bin/X11
  2204. X          INCROOT = $(DESTDIR)/usr/include
  2205. X     BUILDINCROOT = $(TOP)
  2206. X      BUILDINCDIR = $(BUILDINCROOT)/X11
  2207. X      BUILDINCTOP = ..
  2208. X           INCDIR = $(INCROOT)/X11
  2209. X           ADMDIR = $(DESTDIR)/usr/adm
  2210. X           LIBDIR = $(USRLIBDIR)/X11
  2211. X        CONFIGDIR = $(LIBDIR)/config
  2212. X       LINTLIBDIR = $(USRLIBDIR)/lint
  2213. X
  2214. X          FONTDIR = $(LIBDIR)/fonts
  2215. X         XINITDIR = $(LIBDIR)/xinit
  2216. X           XDMDIR = $(LIBDIR)/xdm
  2217. X           AWMDIR = $(LIBDIR)/awm
  2218. X           TWMDIR = $(LIBDIR)/twm
  2219. X           GWMDIR = $(LIBDIR)/gwm
  2220. X          MANPATH = $(DESTDIR)/usr/man
  2221. X    MANSOURCEPATH = $(MANPATH)/man
  2222. X           MANDIR = $(MANSOURCEPATH)n
  2223. X        LIBMANDIR = $(MANSOURCEPATH)3
  2224. X      XAPPLOADDIR = $(LIBDIR)/app-defaults
  2225. X
  2226. X        SOXLIBREV = 4.2
  2227. X          SOXTREV = 4.0
  2228. X         SOXAWREV = 4.0
  2229. X        SOOLDXREV = 4.0
  2230. X         SOXMUREV = 4.0
  2231. X        SOXEXTREV = 4.0
  2232. X
  2233. X       FONTCFLAGS = -t
  2234. X
  2235. X     INSTAPPFLAGS = $(INSTDATFLAGS)
  2236. X
  2237. X            IMAKE = imake
  2238. X           DEPEND = makedepend
  2239. X              RGB = rgb
  2240. X            FONTC = bdftosnf
  2241. X        MKFONTDIR = mkfontdir
  2242. X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier.sh
  2243. X
  2244. X        CONFIGSRC = $(TOP)/config
  2245. X        CLIENTSRC = $(TOP)/clients
  2246. X          DEMOSRC = $(TOP)/demos
  2247. X           LIBSRC = $(TOP)/lib
  2248. X          FONTSRC = $(TOP)/fonts
  2249. X       INCLUDESRC = $(TOP)/X11
  2250. X        SERVERSRC = $(TOP)/server
  2251. X          UTILSRC = $(TOP)/util
  2252. X        SCRIPTSRC = $(UTILSRC)/scripts
  2253. X       EXAMPLESRC = $(TOP)/examples
  2254. X       CONTRIBSRC = $(TOP)/../contrib
  2255. X           DOCSRC = $(TOP)/doc
  2256. X           RGBSRC = $(TOP)/rgb
  2257. X        DEPENDSRC = $(UTILSRC)/makedepend
  2258. X         IMAKESRC = $(CONFIGSRC)
  2259. X         XAUTHSRC = $(LIBSRC)/Xau
  2260. X          XLIBSRC = $(LIBSRC)/X
  2261. X           XMUSRC = $(LIBSRC)/Xmu
  2262. X       TOOLKITSRC = $(LIBSRC)/Xt
  2263. X       AWIDGETSRC = $(LIBSRC)/Xaw
  2264. X       OLDXLIBSRC = $(LIBSRC)/oldX
  2265. X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
  2266. X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  2267. X     MKFONTDIRSRC = $(FONTSRC)/mkfontdir
  2268. X     EXTENSIONSRC = $(TOP)/extensions
  2269. X
  2270. X  DEPEXTENSIONLIB = $(USRLIBDIR)/libXext.a
  2271. X     EXTENSIONLIB =  -lXext
  2272. X
  2273. X          DEPXLIB = $(DEPEXTENSIONLIB)
  2274. X             XLIB = $(EXTENSIONLIB) -lX11
  2275. X
  2276. X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
  2277. X         XAUTHLIB =  -lXau
  2278. X
  2279. X        DEPXMULIB =
  2280. X           XMULIB = -lXmu
  2281. X
  2282. X       DEPOLDXLIB =
  2283. X          OLDXLIB = -loldX
  2284. X
  2285. X      DEPXTOOLLIB =
  2286. X         XTOOLLIB = -lXt
  2287. X
  2288. X        DEPXAWLIB =
  2289. X           XAWLIB = -lXaw
  2290. X
  2291. X LINTEXTENSIONLIB = $(USRLIBDIR)/llib-lXext.ln
  2292. X         LINTXLIB = $(USRLIBDIR)/llib-lX11.ln
  2293. X          LINTXMU = $(USRLIBDIR)/llib-lXmu.ln
  2294. X        LINTXTOOL = $(USRLIBDIR)/llib-lXt.ln
  2295. X          LINTXAW = $(USRLIBDIR)/llib-lXaw.ln
  2296. X
  2297. X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
  2298. X
  2299. X         DEPLIBS1 = $(DEPLIBS)
  2300. X         DEPLIBS2 = $(DEPLIBS)
  2301. X         DEPLIBS3 = $(DEPLIBS)
  2302. X
  2303. ###########################################################################
  2304. # Imake rules for building libraries, programs, scripts, and data files
  2305. # rules:  $XConsortium: Imake.rules,v 1.67 89/12/18 17:14:15 jim Exp $
  2306. X
  2307. ###########################################################################
  2308. # start of Imakefile
  2309. X
  2310. EXTRA_INCLUDES= -I/usr/local/include -I..
  2311. EXTRA_LIBRARIES= -lX11 -lm
  2312. PPM_LIBRARIES= /usr/local/lib/libppm.a /usr/local/lib/libpgm.a  \
  2313. X  /usr/local/lib/libpbm.a
  2314. TIFF_LIBRARIES= /usr/local/lib/libtiff.a
  2315. X
  2316. AVStoMIFFSources= AVStoMIFF.c
  2317. AVStoMIFFObjects= AVStoMIFF.o image.o compress.o
  2318. GIFtoMIFFSources= GIFtoMIFF.c
  2319. GIFtoMIFFObjects= GIFtoMIFF.o image.o compress.o
  2320. GRAYtoMIFFSources= GRAYtoMIFF.c
  2321. GRAYtoMIFFObjects= GRAYtoMIFF.o image.o compress.o
  2322. MIFFtoAVSSources= MIFFtoAVS.c
  2323. MIFFtoAVSObjects= MIFFtoAVS.o image.o compress.o
  2324. MIFFtoGIFSources= MIFFtoGIF.c
  2325. MIFFtoGIFObjects= MIFFtoGIF.o image.o kolb.o quantize.o compress.o
  2326. MIFFtoGRAYSources= MIFFtoGRAY.c
  2327. MIFFtoGRAYObjects= MIFFtoGRAY.o image.o kolb.o quantize.o compress.o
  2328. MIFFtoPPMSources= MIFFtoPPM.c
  2329. MIFFtoPPMObjects= MIFFtoPPM.o image.o compress.o
  2330. MIFFtoRGBSources= MIFFtoRGB.c
  2331. MIFFtoRGBObjects= MIFFtoRGB.o image.o compress.o
  2332. MIFFtoSUNSources= MIFFtoSUN.c
  2333. MIFFtoSUNObjects= MIFFtoSUN.o image.o compress.o
  2334. MIFFtoTIFFSources= MIFFtoTIFF.c
  2335. MIFFtoTIFFObjects= MIFFtoTIFF.o image.o compress.o
  2336. MIFFtoXBMSources= MIFFtoXBM.c
  2337. MIFFtoXBMObjects= MIFFtoXBM.o image.o kolb.o quantize.o compress.o
  2338. MIFFtoXWDSources= MIFFtoXWD.c
  2339. MIFFtoXWDObjects= MIFFtoXWD.o image.o compress.o
  2340. MTVtoMIFFSources= MTVtoMIFF.c
  2341. MTVtoMIFFObjects= MTVtoMIFF.o image.o compress.o
  2342. SUNtoMIFFSources= SUNtoMIFF.c
  2343. SUNtoMIFFObjects= SUNtoMIFF.o image.o compress.o
  2344. RGBtoMIFFSources= RGBtoMIFF.c
  2345. RGBtoMIFFObjects= RGBtoMIFF.o image.o compress.o
  2346. PPMtoMIFFSources= PPMtoMIFF.c
  2347. PPMtoMIFFObjects= PPMtoMIFF.o image.o kolb.o quantize.o colors.o compress.o
  2348. TIFFtoMIFFSources= TIFFtoMIFF.c
  2349. TIFFtoMIFFObjects= TIFFtoMIFF.o image.o kolb.o quantize.o compress.o
  2350. XXBMtoMIFFSources= XBMtoMIFF.c
  2351. XXBMtoMIFFObjects= XBMtoMIFF.o image.o compress.o
  2352. XXWDtoMIFFSources= XWDtoMIFF.c
  2353. XXWDtoMIFFObjects= XWDtoMIFF.o image.o compress.o
  2354. X
  2355. PROGRAMS= AVStoMIFF MIFFtoAVS GIFtoMIFF MIFFtoGIF GRAYtoMIFF MIFFtoGRAY  \
  2356. X  MTVtoMIFF RGBtoMIFF MIFFtoRGB SUNtoMIFF MIFFtoSUN XBMtoMIFF MIFFtoXBM  \
  2357. X  XWDtoMIFF MIFFtoXWD PPMtoMIFF MIFFtoPPM TIFFtoMIFF MIFFtoTIFF
  2358. X
  2359. all:: $(PROGRAMS)
  2360. X
  2361. AVStoMIFF: $(AVStoMIFFObjects)
  2362. X    $(RM) $@
  2363. X    $(CC) -o $@ $(AVStoMIFFObjects) $(LDOPTIONS)   $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  2364. X
  2365. clean::
  2366. X    $(RM) AVStoMIFF
  2367. X
  2368. install:: AVStoMIFF
  2369. X    $(INSTALL) -c $(INSTPGMFLAGS)   AVStoMIFF $(BINDIR)
  2370. X
  2371. MIFFtoAVS: $(MIFFtoAVSObjects)
  2372. X    $(RM) $@
  2373. X    $(CC) -o $@ $(MIFFtoAVSObjects) $(LDOPTIONS)   $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  2374. X
  2375. clean::
  2376. X    $(RM) MIFFtoAVS
  2377. X
  2378. install:: MIFFtoAVS
  2379. X    $(INSTALL) -c $(INSTPGMFLAGS)   MIFFtoAVS $(BINDIR)
  2380. X
  2381. GIFtoMIFF: $(GIFtoMIFFObjects)
  2382. X    $(RM) $@
  2383. X    $(CC) -o $@ $(GIFtoMIFFObjects) $(LDOPTIONS)   $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  2384. X
  2385. clean::
  2386. X    $(RM) GIFtoMIFF
  2387. X
  2388. install:: GIFtoMIFF
  2389. X    $(INSTALL) -c $(INSTPGMFLAGS)   GIFtoMIFF $(BINDIR)
  2390. X
  2391. MIFFtoGIF: $(MIFFtoGIFObjects)
  2392. X    $(RM) $@
  2393. X    $(CC) -o $@ $(MIFFtoGIFObjects) $(LDOPTIONS)   $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  2394. X
  2395. clean::
  2396. X    $(RM) MIFFtoGIF
  2397. X
  2398. install:: MIFFtoGIF
  2399. X    $(INSTALL) -c $(INSTPGMFLAGS)   MIFFtoGIF $(BINDIR)
  2400. X
  2401. GRAYtoMIFF: $(GRAYtoMIFFObjects)
  2402. X    $(RM) $@
  2403. X    $(CC) -o $@ $(GRAYtoMIFFObjects) $(LDOPTIONS)   $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  2404. X
  2405. clean::
  2406. X    $(RM) GRAYtoMIFF
  2407. X
  2408. install:: GRAYtoMIFF
  2409. X    $(INSTALL) -c $(INSTPGMFLAGS)   GRAYtoMIFF $(BINDIR)
  2410. X
  2411. MIFFtoGRAY: $(MIFFtoGRAYObjects)
  2412. X    $(RM) $@
  2413. X    $(CC) -o $@ $(MIFFtoGRAYObjects) $(LDOPTIONS)   $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  2414. X
  2415. clean::
  2416. X    $(RM) MIFFtoGRAY
  2417. X
  2418. install:: MIFFtoGRAY
  2419. X    $(INSTALL) -c $(INSTPGMFLAGS)   MIFFtoGRAY $(BINDIR)
  2420. X
  2421. MTVtoMIFF: $(MTVtoMIFFObjects)
  2422. X    $(RM) $@
  2423. X    $(CC) -o $@ $(MTVtoMIFFObjects) $(LDOPTIONS)   $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  2424. X
  2425. clean::
  2426. X    $(RM) MTVtoMIFF
  2427. X
  2428. install:: MTVtoMIFF
  2429. X    $(INSTALL) -c $(INSTPGMFLAGS)   MTVtoMIFF $(BINDIR)
  2430. X
  2431. RGBtoMIFF: $(RGBtoMIFFObjects)
  2432. X    $(RM) $@
  2433. X    $(CC) -o $@ $(RGBtoMIFFObjects) $(LDOPTIONS)   $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  2434. X
  2435. clean::
  2436. X    $(RM) RGBtoMIFF
  2437. X
  2438. install:: RGBtoMIFF
  2439. X    $(INSTALL) -c $(INSTPGMFLAGS)   RGBtoMIFF $(BINDIR)
  2440. X
  2441. MIFFtoRGB: $(MIFFtoRGBObjects)
  2442. X    $(RM) $@
  2443. X    $(CC) -o $@ $(MIFFtoRGBObjects) $(LDOPTIONS)   $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  2444. X
  2445. clean::
  2446. X    $(RM) MIFFtoRGB
  2447. X
  2448. install:: MIFFtoRGB
  2449. X    $(INSTALL) -c $(INSTPGMFLAGS)   MIFFtoRGB $(BINDIR)
  2450. X
  2451. SUNtoMIFF: $(SUNtoMIFFObjects)
  2452. X    $(RM) $@
  2453. X    $(CC) -o $@ $(SUNtoMIFFObjects) $(LDOPTIONS)   $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  2454. X
  2455. clean::
  2456. X    $(RM) SUNtoMIFF
  2457. X
  2458. install:: SUNtoMIFF
  2459. X    $(INSTALL) -c $(INSTPGMFLAGS)   SUNtoMIFF $(BINDIR)
  2460. X
  2461. MIFFtoSUN: $(MIFFtoSUNObjects)
  2462. X    $(RM) $@
  2463. X    $(CC) -o $@ $(MIFFtoSUNObjects) $(LDOPTIONS)   $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  2464. X
  2465. clean::
  2466. X    $(RM) MIFFtoSUN
  2467. X
  2468. install:: MIFFtoSUN
  2469. X    $(INSTALL) -c $(INSTPGMFLAGS)   MIFFtoSUN $(BINDIR)
  2470. X
  2471. XXBMtoMIFF: $(XBMtoMIFFObjects)
  2472. X    $(RM) $@
  2473. X    $(CC) -o $@ $(XBMtoMIFFObjects) $(LDOPTIONS)   $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  2474. X
  2475. clean::
  2476. X    $(RM) XBMtoMIFF
  2477. X
  2478. install:: XBMtoMIFF
  2479. X    $(INSTALL) -c $(INSTPGMFLAGS)   XBMtoMIFF $(BINDIR)
  2480. X
  2481. MIFFtoXBM: $(MIFFtoXBMObjects)
  2482. X    $(RM) $@
  2483. X    $(CC) -o $@ $(MIFFtoXBMObjects) $(LDOPTIONS)   $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  2484. X
  2485. clean::
  2486. X    $(RM) MIFFtoXBM
  2487. X
  2488. install:: MIFFtoXBM
  2489. X    $(INSTALL) -c $(INSTPGMFLAGS)   MIFFtoXBM $(BINDIR)
  2490. X
  2491. XXWDtoMIFF: $(XWDtoMIFFObjects)
  2492. X    $(RM) $@
  2493. X    $(CC) -o $@ $(XWDtoMIFFObjects) $(LDOPTIONS)   $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  2494. X
  2495. clean::
  2496. X    $(RM) XWDtoMIFF
  2497. X
  2498. install:: XWDtoMIFF
  2499. X    $(INSTALL) -c $(INSTPGMFLAGS)   XWDtoMIFF $(BINDIR)
  2500. X
  2501. MIFFtoXWD: $(MIFFtoXWDObjects)
  2502. X    $(RM) $@
  2503. X    $(CC) -o $@ $(MIFFtoXWDObjects) $(LDOPTIONS)   $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  2504. X
  2505. clean::
  2506. X    $(RM) MIFFtoXWD
  2507. X
  2508. install:: MIFFtoXWD
  2509. X    $(INSTALL) -c $(INSTPGMFLAGS)   MIFFtoXWD $(BINDIR)
  2510. X
  2511. PPMtoMIFF: $(PPMtoMIFFObjects)
  2512. X    $(RM) $@
  2513. X    $(CC) -o $@ $(PPMtoMIFFObjects) $(LDOPTIONS) $(PPM_LIBRARIES) $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  2514. X
  2515. clean::
  2516. X    $(RM) PPMtoMIFF
  2517. X
  2518. install:: PPMtoMIFF
  2519. X    $(INSTALL) -c $(INSTPGMFLAGS)   PPMtoMIFF $(BINDIR)
  2520. X
  2521. MIFFtoPPM: $(MIFFtoPPMObjects)
  2522. X    $(RM) $@
  2523. X    $(CC) -o $@ $(MIFFtoPPMObjects) $(LDOPTIONS) $(PPM_LIBRARIES) $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  2524. X
  2525. clean::
  2526. X    $(RM) MIFFtoPPM
  2527. X
  2528. install:: MIFFtoPPM
  2529. X    $(INSTALL) -c $(INSTPGMFLAGS)   MIFFtoPPM $(BINDIR)
  2530. X
  2531. TIFFtoMIFF: $(TIFFtoMIFFObjects)
  2532. X    $(RM) $@
  2533. X    $(CC) -o $@ $(TIFFtoMIFFObjects) $(LDOPTIONS) $(TIFF_LIBRARIES) $(LDLIBS)   $(EXTRA_LOAD_FLAGS)
  2534. SHAR_EOF
  2535. true || echo 'restore of ImageMagick/filters/Makefile failed'
  2536. fi
  2537. echo 'End of ImageMagick part 11'
  2538. echo 'File ImageMagick/filters/Makefile is continued in part 12'
  2539. echo 12 > _shar_seq_.tmp
  2540. exit 0
  2541. --
  2542. Dan Heller
  2543. O'Reilly && Associates       Z-Code Software    Comp-sources-x:
  2544. Senior Writer                President          comp-sources-x@uunet.uu.net
  2545. argv@ora.com                 argv@zipcode.com
  2546.