home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sources / bugs / 315 < prev    next >
Encoding:
Text File  |  1992-12-22  |  75.3 KB  |  2,482 lines

  1. Newsgroups: comp.sources.bugs
  2. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!udel!louie!eplrx7!eplrx7.es.dupont.com!cristy
  3. From: cristy@eplrx7.es.duPont.com (Cristy)
  4. Subject: ImageMagick 2.2 - patch #1, Part 02/3
  5. Message-ID: <cristy.724966583@eplrx7.es.dupont.com>
  6. Summary: X11 image processing and display utilities
  7. Keywords: UNIX VMS X11 SGI DEC Cray Sun Vax
  8. Organization: DuPont Engineering Physics Laboratory
  9. Date: Mon, 21 Dec 1992 19:36:23 GMT
  10. Lines: 2470
  11.  
  12. Submitted-by: cristy@dupont.com
  13. Archive-name: ImageMagick/patch0102
  14.  
  15. #!/bin/sh
  16. # this is magick.02 (part 2 of ImageMagick/patch01)
  17. # do not concatenate these parts, unpack them in order with /bin/sh
  18. # file fix-01 continued
  19. #
  20. if test ! -r _shar_seq_.tmp; then
  21.     echo 'Please unpack part 1 first!'
  22.     exit 1
  23. fi
  24. (read Scheck
  25.  if test "$Scheck" != 2; then
  26.     echo Please unpack part "$Scheck" next!
  27.     exit 1
  28.  else
  29.     exit 0
  30.  fi
  31. ) < _shar_seq_.tmp || exit 1
  32. if test ! -f _shar_wnt_.tmp; then
  33.     echo 'x - still skipping fix-01'
  34. else
  35. echo 'x - continuing file fix-01'
  36. sed 's/^X//' << 'SHAR_EOF' >> 'fix-01' &&
  37. !   resource_value=XGetResource(resource_database,client_name,"scene","0");
  38. X    scene=atoi(resource_value);
  39. !   resource_value=XGetResource(resource_database,client_name,"verbose","False");
  40. X    verbose=IsTrue(resource_value);
  41. !   window_id=
  42. !     XGetResource(resource_database,client_name,"windowId",(char *) NULL);
  43. X    /*
  44. X      Parse command line.
  45. X    */
  46. ***************
  47. *** 5659,5665 ****
  48. X                  Initialize image error attributes.
  49. X                */
  50. X                if (image->class == DirectClass)
  51. !                 image->colors=NumberColors(image);
  52. X                total_colors=image->colors;
  53. X              }
  54. X            if (resource_info.colorspace == GRAYColorspace)
  55. --- 5660,5666 ----
  56. X                  Initialize image error attributes.
  57. X                */
  58. X                if (image->class == DirectClass)
  59. !                 image->colors=NumberColors(image,(FILE *) NULL);
  60. X                total_colors=image->colors;
  61. X              }
  62. X            if (resource_info.colorspace == GRAYColorspace)
  63. diff -r -c ImageMagick/display.h ImageMagick2.2.1/display.h
  64. *** ImageMagick/display.h    Mon Dec  7 09:23:25 1992
  65. --- ImageMagick2.2.1/display.h    Fri Dec 18 17:07:29 1992
  66. ***************
  67. *** 35,41 ****
  68. X  #define UpShifted(x) ((int) ((x)*(1L << 16)+0.5))
  69. X  #define Warning(message,qualifier)  \
  70. X  {  \
  71. !   (void) fprintf(stderr,"%s: %s",application_name,message);  \
  72. X    if (qualifier != (char *) NULL)  \
  73. X      (void) fprintf(stderr," (%s)",qualifier);  \
  74. X    (void) fprintf(stderr,".\n");  \
  75. --- 35,41 ----
  76. X  #define UpShifted(x) ((int) ((x)*(1L << 16)+0.5))
  77. X  #define Warning(message,qualifier)  \
  78. X  {  \
  79. !   (void) fprintf(stderr,"%s: %s",client_name,message);  \
  80. X    if (qualifier != (char *) NULL)  \
  81. X      (void) fprintf(stderr," (%s)",qualifier);  \
  82. X    (void) fprintf(stderr,".\n");  \
  83. ***************
  84. *** 51,55 ****
  85. X  */
  86. X  #ifndef lint
  87. X  static char 
  88. !   Version[]="@(#)ImageMagick 2.2 92/12/10 cristy@dupont.com";
  89. X  #endif
  90. --- 51,55 ----
  91. X  */
  92. X  #ifndef lint
  93. X  static char 
  94. !   Version[]="@(#)ImageMagick 2.2.1 92/12/10 cristy@dupont.com";
  95. X  #endif
  96. diff -r -c ImageMagick/display.man ImageMagick2.2.1/display.man
  97. *** ImageMagick/display.man    Mon Dec  7 19:53:00 1992
  98. --- ImageMagick2.2.1/display.man    Fri Dec 18 17:07:31 1992
  99. ***************
  100. *** 207,213 ****
  101. X  tranform image to span the full range of color values.  This is a contrast
  102. X  enhancement technique.
  103. X  .TP 5
  104. ! .B "-print \fIfile\fP"
  105. X  write image as encapsulated Postscript to a file.
  106. X  
  107. X  If \fIfile\fP already exists, you will be prompted as to whether
  108. --- 207,213 ----
  109. X  tranform image to span the full range of color values.  This is a contrast
  110. X  enhancement technique.
  111. X  .TP 5
  112. ! .B "-print \fIfilename\fP"
  113. X  write image as encapsulated Postscript to a file.
  114. X  
  115. X  If \fIfile\fP already exists, you will be prompted as to whether
  116. ***************
  117. *** 232,237 ****
  118. --- 232,240 ----
  119. X  .TP 5
  120. X  .B "-rotate \fIdegrees\fP"
  121. X  apply Paeth image rotation to the image.
  122. + Empty triangles left over from rotating the image are filled with
  123. + the color defined by the pixel at location (0,0).
  124. X  .TP 5
  125. X  .B "-scale \fI<width factor>x<height factor>\fP"
  126. X  preferred size factors of the image.
  127. ***************
  128. *** 242,249 ****
  129. X  one factor is specified, both the width and height factors assume the
  130. X  value.
  131. X  
  132. ! Factors may be fractional.  For example, a factor of 1.5 will increase the
  133. ! image size by one and one-half.
  134. X  
  135. X  The equivalent X resource for this option is \fBscaleGeometry\fP
  136. X  (class \fBScaleGeometry\fP).  See \fBX RESOURCES\fP for details.
  137. --- 245,253 ----
  138. X  one factor is specified, both the width and height factors assume the
  139. X  value.
  140. X  
  141. ! Factors may be fractional.  To increase the size of an image, use a
  142. ! scale factor greater than 1.0.  To decrease an image's size, use a
  143. ! scale factor less than 1.0.  Default is 1.0.
  144. X  
  145. X  The equivalent X resource for this option is \fBscaleGeometry\fP
  146. X  (class \fBScaleGeometry\fP).  See \fBX RESOURCES\fP for details.
  147. ***************
  148. *** 311,317 ****
  149. X  unique colors than the target window colormap allows.  Use
  150. X  \fB-colors\fP to reduce the number of colors.
  151. X  .TP 5
  152. ! .B "-write \fIfile\fP"
  153. X  write image to a file.
  154. X  
  155. X  If \fIfile\fP already exists, you will be prompted as to whether
  156. --- 315,321 ----
  157. X  unique colors than the target window colormap allows.  Use
  158. X  \fB-colors\fP to reduce the number of colors.
  159. X  .TP 5
  160. ! .B "-write \fIfilename\fP"
  161. X  write image to a file.
  162. X  
  163. X  If \fIfile\fP already exists, you will be prompted as to whether
  164. diff -r -c ImageMagick/image.c ImageMagick2.2.1/image.c
  165. *** ImageMagick/image.c    Mon Dec  7 09:18:21 1992
  166. --- ImageMagick2.2.1/image.c    Fri Dec 18 17:07:28 1992
  167. ***************
  168. *** 59,65 ****
  169. X    External declarations.
  170. X  */
  171. X  extern char
  172. !   *application_name;
  173. X  
  174. X  /*
  175. X  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  176. --- 59,65 ----
  177. X    External declarations.
  178. X  */
  179. X  extern char
  180. !   *client_name;
  181. X  
  182. X  /*
  183. X  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  184. ***************
  185. *** 4050,4055 ****
  186. --- 4050,4156 ----
  187. X  %                                                                             %
  188. X  %                                                                             %
  189. X  %                                                                             %
  190. + %   R o l l I m a g e                                                         %
  191. + %                                                                             %
  192. + %                                                                             %
  193. + %                                                                             %
  194. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  195. + %
  196. + %  Function RollImage rolls an image vertically and horizontally.  It
  197. + %  allocates the memory necessary for the new Image structure and returns a
  198. + %  pointer to the new image.
  199. + %
  200. + %  The format of the RollImage routine is:
  201. + %
  202. + %      rolled_image=RollImage(image,columns,rows)
  203. + %
  204. + %  A description of each parameter follows:
  205. + %
  206. + %    o rolled_image: Function RollImage returns a pointer to the image after
  207. + %      rolling.  A null image is returned if there is a memory shortage.
  208. + %
  209. + %    o image: The address of a structure of type Image.
  210. + %
  211. + %    o x_offset: An integer that specifies the number of columns to roll
  212. + %      in the horizonal direction.
  213. + %
  214. + %    o y_offset: An integer that specifies the number of rows to roll in the
  215. + %      veritical direction.
  216. + %
  217. + %
  218. + */
  219. + Image *RollImage(image,x_offset,y_offset)
  220. + Image
  221. +   *image;
  222. + unsigned int
  223. +   x_offset,
  224. +   y_offset;
  225. + {
  226. +   Image
  227. +     *rolled_image;
  228. +   register RunlengthPacket
  229. +     *p,
  230. +     *q;
  231. +   register unsigned int
  232. +     packets,
  233. +     x;
  234. +   unsigned int
  235. +     y;
  236. +   /*
  237. +     Initialize rolled image attributes.
  238. +   */
  239. +   rolled_image=CopyImage(image,image->columns,image->rows,False);
  240. +   if (rolled_image == (Image *) NULL)
  241. +     {
  242. +       Warning("unable to roll image","memory allocation failed");
  243. +       return((Image *) NULL);
  244. +     }
  245. +   /*
  246. +     Roll image.
  247. +   */
  248. +   p=image->pixels;
  249. +   image->runlength=p->length+1;
  250. +   packets=image->columns*image->rows;
  251. +   for (y=0; y < image->rows; y++)
  252. +   {
  253. +     /*
  254. +       Transfer scanline.
  255. +     */
  256. +     for (x=0; x < image->columns; x++)
  257. +     {
  258. +       if (image->runlength > 0)
  259. +         image->runlength--;
  260. +       else
  261. +         {
  262. +           p++;
  263. +           image->runlength=p->length;
  264. +         }
  265. +       q=rolled_image->pixels+(y_offset+y)*image->columns+x+x_offset;
  266. +       if (q < rolled_image->pixels)
  267. +         q+=packets;
  268. +       else
  269. +         if (q >= (rolled_image->pixels+packets))
  270. +           q-=packets;
  271. +       q->red=p->red;
  272. +       q->green=p->green;
  273. +       q->blue=p->blue;
  274. +       q->index=p->index;
  275. +       q->length=0;
  276. +     }
  277. +   }
  278. +   return(rolled_image);
  279. + }
  280. + /*
  281. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  282. + %                                                                             %
  283. + %                                                                             %
  284. + %                                                                             %
  285. X  %   S c a l e I m a g e                                                       %
  286. X  %                                                                             %
  287. X  %                                                                             %
  288. ***************
  289. *** 4477,4483 ****
  290. X  %      transformed image is returned as this parameter.
  291. X  %
  292. X  %    o clip_geometry: Specifies a pointer to a clip geometry string.
  293. ! %      This geometry defined a subregion of the image.
  294. X  %
  295. X  %    o image_geometry: Specifies a pointer to a image geometry string.
  296. X  %      The specified width and height of this geometry string are absolute.
  297. --- 4578,4584 ----
  298. X  %      transformed image is returned as this parameter.
  299. X  %
  300. X  %    o clip_geometry: Specifies a pointer to a clip geometry string.
  301. ! %      This geometry defines a subregion of the image.
  302. X  %
  303. X  %    o image_geometry: Specifies a pointer to a image geometry string.
  304. X  %      The specified width and height of this geometry string are absolute.
  305. ***************
  306. *** 4543,4558 ****
  307. X    if (scale_geometry != (char *) NULL)
  308. X      {
  309. X        float
  310. !         scale_height,
  311. !         scale_width;
  312. X  
  313. !       scale_width=0.0;
  314. !       scale_height=0.0;
  315. !       (void) sscanf(scale_geometry,"%fx%f",&scale_width,&scale_height);
  316. !       if (scale_height == 0.0)
  317. !         scale_height=scale_width;
  318. !       width=(unsigned int) (width*scale_width);
  319. !       height=(unsigned int) (height*scale_height);
  320. X      }
  321. X    if (image_geometry != (char *) NULL)
  322. X      (void) XParseGeometry(image_geometry,&x,&y,&width,&height);
  323. --- 4644,4659 ----
  324. X    if (scale_geometry != (char *) NULL)
  325. X      {
  326. X        float
  327. !         height_factor,
  328. !         width_factor;
  329. X  
  330. !       width_factor=0.0;
  331. !       height_factor=0.0;
  332. !       (void) sscanf(scale_geometry,"%fx%f",&width_factor,&height_factor);
  333. !       if (height_factor == 0.0)
  334. !         height_factor=width_factor;
  335. !       width=(unsigned int) (width*width_factor);
  336. !       height=(unsigned int) (height*height_factor);
  337. X      }
  338. X    if (image_geometry != (char *) NULL)
  339. X      (void) XParseGeometry(image_geometry,&x,&y,&width,&height);
  340. diff -r -c ImageMagick/image.h ImageMagick2.2.1/image.h
  341. *** ImageMagick/image.h    Mon Dec  7 17:10:46 1992
  342. --- ImageMagick2.2.1/image.h    Fri Dec 18 17:07:29 1992
  343. ***************
  344. *** 2,7 ****
  345. --- 2,8 ----
  346. X    Image define declarations.
  347. X  */
  348. X  #define AbsoluteValue(x)  ((x) < 0 ? -(x) : (x))
  349. + #define DegreesToRadians(x) ((x)*3.14159265358979323846/180.0)
  350. X  #define Intensity(color)  (unsigned int)  \
  351. X    ((unsigned int) ((color).red*77+(color).green*150+(color).blue*29) >> 8)
  352. X  #define MaxColormapSize  65535
  353. ***************
  354. *** 147,154 ****
  355. --- 148,157 ----
  356. X    *ReadImage _Declare((char *)),
  357. X    *ReduceImage _Declare((Image *)),
  358. X    *ReflectImage _Declare((Image *)),
  359. +   *RollImage _Declare((Image *,unsigned int,unsigned int)),
  360. X    *RotateImage _Declare((Image *,double,int)),
  361. X    *ScaleImage _Declare((Image *,unsigned int,unsigned int)),
  362. +   *ShearImage _Declare((Image *,double,double,unsigned int)),
  363. X    *StereoImage _Declare((Image *,Image *)),
  364. X    *ZoomImage _Declare((Image *));
  365. X  
  366. ***************
  367. *** 156,162 ****
  368. X    ReadDataBlock _Declare((char *,FILE *));
  369. X  
  370. X  extern unsigned int
  371. !   NumberColors _Declare((Image *)),
  372. X    PackImage _Declare((Image *)),
  373. X    PrintImage _Declare((Image *,char *)),
  374. X    ReadData _Declare((char *,int,int,FILE *)),
  375. --- 159,165 ----
  376. X    ReadDataBlock _Declare((char *,FILE *));
  377. X  
  378. X  extern unsigned int
  379. !   NumberColors _Declare((Image *,FILE *)),
  380. X    PackImage _Declare((Image *)),
  381. X    PrintImage _Declare((Image *,char *)),
  382. X    ReadData _Declare((char *,int,int,FILE *)),
  383. Common subdirectories: ImageMagick/images and ImageMagick2.2.1/images
  384. diff -r -c ImageMagick/import.c ImageMagick2.2.1/import.c
  385. *** ImageMagick/import.c    Mon Dec  7 09:18:45 1992
  386. --- ImageMagick2.2.1/import.c    Fri Dec 18 17:07:28 1992
  387. ***************
  388. *** 90,96 ****
  389. X    Global declarations.
  390. X  */
  391. X  char
  392. !   *application_name;
  393. X  
  394. X  /*
  395. X  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  396. --- 90,96 ----
  397. X    Global declarations.
  398. X  */
  399. X  char
  400. !   *client_name;
  401. X  
  402. X  /*
  403. X  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  404. ***************
  405. *** 123,129 ****
  406. X    *message,
  407. X    *qualifier;
  408. X  {
  409. !   (void) fprintf(stderr,"%s: %s",application_name,message);
  410. X    if (qualifier != (char *) NULL)
  411. X      (void) fprintf(stderr," (%s)",qualifier);
  412. X    (void) fprintf(stderr,".\n");
  413. --- 123,129 ----
  414. X    *message,
  415. X    *qualifier;
  416. X  {
  417. !   (void) fprintf(stderr,"%s: %s",client_name,message);
  418. X    if (qualifier != (char *) NULL)
  419. X      (void) fprintf(stderr," (%s)",qualifier);
  420. X    (void) fprintf(stderr,".\n");
  421. ***************
  422. *** 169,175 ****
  423. X        "-window id       select window with this id or name",
  424. X        (char *) NULL
  425. X      };
  426. !   (void) fprintf(stderr,"Usage: %s [options ...] file\n",application_name);
  427. X    (void) fprintf(stderr,"\nWhere options include:\n");
  428. X    for (p=options; *p != (char *) NULL; p++)
  429. X      (void) fprintf(stderr,"  %s\n",*p);
  430. --- 169,175 ----
  431. X        "-window id       select window with this id or name",
  432. X        (char *) NULL
  433. X      };
  434. !   (void) fprintf(stderr,"Usage: %s [options ...] file\n",client_name);
  435. X    (void) fprintf(stderr,"\nWhere options include:\n");
  436. X    for (p=options; *p != (char *) NULL; p++)
  437. X      (void) fprintf(stderr,"  %s\n",*p);
  438. ***************
  439. *** 247,253 ****
  440. X    /*
  441. X      Display usage profile if there are no command line arguments.
  442. X    */
  443. !   application_name=(*argv);
  444. X    if (argc < 2)
  445. X      Usage();
  446. X    /*
  447. --- 247,253 ----
  448. X    /*
  449. X      Display usage profile if there are no command line arguments.
  450. X    */
  451. !   client_name=(*argv);
  452. X    if (argc < 2)
  453. X      Usage();
  454. X    /*
  455. ***************
  456. *** 293,319 ****
  457. X    /*
  458. X      Get user defaults from X resource database.
  459. X    */
  460. !   XGetResourceInfo(resource_database,application_name,&resource_info);
  461. !   resource_value=XGetResource(resource_database,application_name,"borders",
  462. !     (char *) NULL,"False");
  463. X    borders=IsTrue(resource_value);
  464. !   resource_value=XGetResource(resource_database,application_name,
  465. !     "compression",(char *) NULL,"Runlength");
  466. X    if (Latin1Compare("qencoded",resource_value) == 0)
  467. X      compression=QEncodedCompression;
  468. X    else
  469. X      compression=RunlengthEncodedCompression;
  470. !   resource_value=XGetResource(resource_database,application_name,"frame",
  471. !     (char *) NULL,"False");
  472. X    frame=IsTrue(resource_value);
  473. !   resource_value=XGetResource(resource_database,application_name,"scene",
  474. !     (char *) NULL,"0");
  475. X    scene=atoi(resource_value);
  476. !   resource_value=XGetResource(resource_database,application_name,"screen",
  477. !     (char *) NULL,"False");
  478. X    screen=IsTrue(resource_value);
  479. !   resource_value=XGetResource(resource_database,application_name,"verbose",
  480. !     (char *) NULL,"False");
  481. X    verbose=IsTrue(resource_value);
  482. X    /*
  483. X      Check command syntax.
  484. --- 293,314 ----
  485. X    /*
  486. X      Get user defaults from X resource database.
  487. X    */
  488. !   XGetResourceInfo(resource_database,client_name,&resource_info);
  489. !   resource_value=XGetResource(resource_database,client_name,"borders","False");
  490. X    borders=IsTrue(resource_value);
  491. !   resource_value=
  492. !     XGetResource(resource_database,client_name,"compression","Runlength");
  493. X    if (Latin1Compare("qencoded",resource_value) == 0)
  494. X      compression=QEncodedCompression;
  495. X    else
  496. X      compression=RunlengthEncodedCompression;
  497. !   resource_value=XGetResource(resource_database,client_name,"frame","False");
  498. X    frame=IsTrue(resource_value);
  499. !   resource_value=XGetResource(resource_database,client_name,"scene","0");
  500. X    scene=atoi(resource_value);
  501. !   resource_value=XGetResource(resource_database,client_name,"screen","False");
  502. X    screen=IsTrue(resource_value);
  503. !   resource_value=XGetResource(resource_database,client_name,"verbose","False");
  504. X    verbose=IsTrue(resource_value);
  505. X    /*
  506. X      Check command syntax.
  507. ***************
  508. *** 457,463 ****
  509. X          Display detailed info about the image.
  510. X        */
  511. X        if (image->class == DirectClass)
  512. !         image->colors=NumberColors(image);
  513. X        (void) fprintf(stderr,"[%u] %s %ux%u",image->scene,image->filename,
  514. X          image->columns,image->rows);
  515. X        if (image->class == DirectClass)
  516. --- 452,458 ----
  517. X          Display detailed info about the image.
  518. X        */
  519. X        if (image->class == DirectClass)
  520. !         image->colors=NumberColors(image,(FILE *) NULL);
  521. X        (void) fprintf(stderr,"[%u] %s %ux%u",image->scene,image->filename,
  522. X          image->columns,image->rows);
  523. X        if (image->class == DirectClass)
  524. diff -r -c ImageMagick/montage.c ImageMagick2.2.1/montage.c
  525. *** ImageMagick/montage.c    Wed Dec  9 09:43:25 1992
  526. --- ImageMagick2.2.1/montage.c    Fri Dec 18 17:07:28 1992
  527. ***************
  528. *** 129,135 ****
  529. X    Global declarations.
  530. X  */
  531. X  char
  532. !   *application_name;
  533. X  
  534. X  /*
  535. X  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  536. --- 129,135 ----
  537. X    Global declarations.
  538. X  */
  539. X  char
  540. !   *client_name;
  541. X  
  542. X  /*
  543. X  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  544. ***************
  545. *** 162,168 ****
  546. X    *message,
  547. X    *qualifier;
  548. X  {
  549. !   (void) fprintf(stderr,"%s: %s",application_name,message);
  550. X    if (qualifier != (char *) NULL)
  551. X      (void) fprintf(stderr," (%s)",qualifier);
  552. X    (void) fprintf(stderr,".\n");
  553. --- 162,168 ----
  554. X    *message,
  555. X    *qualifier;
  556. X  {
  557. !   (void) fprintf(stderr,"%s: %s",client_name,message);
  558. X    if (qualifier != (char *) NULL)
  559. X      (void) fprintf(stderr," (%s)",qualifier);
  560. X    (void) fprintf(stderr,".\n");
  561. ***************
  562. *** 670,676 ****
  563. X      };
  564. X    (void) fprintf(stderr,
  565. X      "Usage: %s [-options ...] file [ [-options ...] file ...] file\n",
  566. !     application_name);
  567. X    (void) fprintf(stderr,"\nWhere options include: \n");
  568. X    for (p=options; *p != (char *) NULL; p++)
  569. X      (void) fprintf(stderr,"  %s\n",*p);
  570. --- 670,676 ----
  571. X      };
  572. X    (void) fprintf(stderr,
  573. X      "Usage: %s [-options ...] file [ [-options ...] file ...] file\n",
  574. !     client_name);
  575. X    (void) fprintf(stderr,"\nWhere options include: \n");
  576. X    for (p=options; *p != (char *) NULL; p++)
  577. X      (void) fprintf(stderr,"  %s\n",*p);
  578. ***************
  579. *** 762,768 ****
  580. X    /*
  581. X      Display usage profile if there are no command line arguments.
  582. X    */
  583. !   application_name=(*argv);
  584. X    if (argc < 3)
  585. X      Usage();
  586. X    /*
  587. --- 762,768 ----
  588. X    /*
  589. X      Display usage profile if there are no command line arguments.
  590. X    */
  591. !   client_name=(*argv);
  592. X    if (argc < 3)
  593. X      Usage();
  594. X    /*
  595. ***************
  596. *** 849,877 ****
  597. X        /*
  598. X          Get user defaults from X resource database.
  599. X        */
  600. !       XGetResourceInfo(resource_database,application_name,&resource_info);
  601. !       resource_value=XGetResource(resource_database,application_name,
  602. !         "aspect_ratio",(char *) NULL,"True");
  603. X        aspect_ratio=IsTrue(resource_value);
  604. !       clip_geometry=XGetResource(resource_database,application_name,
  605. !         "clipGeometry","ClipGeometry",(char *) NULL);
  606. !       resource_value=XGetResource(resource_database,application_name,
  607. !         "compression",(char *) NULL,"RunlengthEncoded");
  608. X        if (Latin1Compare("qencoded",resource_value) == 0)
  609. X          compression=QEncodedCompression;
  610. X        else
  611. X          compression=RunlengthEncodedCompression;
  612. !       resource_value=XGetResource(resource_database,application_name,"gamma",
  613. !         (char *) NULL,"0.0");
  614. X        gamma=atof(resource_value);
  615. !       resource_value=XGetResource(resource_database,application_name,"rotate",
  616. !         (char *) NULL,"0");
  617. X        degrees=atoi(resource_value);
  618. !       resource_value=XGetResource(resource_database,application_name,
  619. !         "tiles_per_row","TilesPerRow","0");
  620. X        tiles_per_row=atoi(resource_value);
  621. !       resource_value=XGetResource(resource_database,application_name,"verbose",
  622. !         (char *) NULL,"False");
  623. X        verbose=IsTrue(resource_value);
  624. X      }
  625. X    /*
  626. --- 849,877 ----
  627. X        /*
  628. X          Get user defaults from X resource database.
  629. X        */
  630. !       XGetResourceInfo(resource_database,client_name,&resource_info);
  631. !       resource_value=
  632. !         XGetResource(resource_database,client_name,"aspect_ratio","True");
  633. X        aspect_ratio=IsTrue(resource_value);
  634. !       clip_geometry=XGetResource(resource_database,client_name,"clipGeometry",
  635. !         (char *) NULL);
  636. !       resource_value=XGetResource(resource_database,client_name,
  637. !         "compression","RunlengthEncoded");
  638. X        if (Latin1Compare("qencoded",resource_value) == 0)
  639. X          compression=QEncodedCompression;
  640. X        else
  641. X          compression=RunlengthEncodedCompression;
  642. !       resource_value=XGetResource(resource_database,client_name,"gamma",
  643. !         "0.0");
  644. X        gamma=atof(resource_value);
  645. !       resource_value=XGetResource(resource_database,client_name,"rotate",
  646. !         "0");
  647. X        degrees=atoi(resource_value);
  648. !       resource_value=XGetResource(resource_database,client_name,
  649. !         "tiles_per_row","0");
  650. X        tiles_per_row=atoi(resource_value);
  651. !       resource_value=
  652. !         XGetResource(resource_database,client_name,"verbose","False");
  653. X        verbose=IsTrue(resource_value);
  654. X      }
  655. X    /*
  656. ***************
  657. *** 1410,1416 ****
  658. X          Display detailed info about the image.
  659. X        */
  660. X        if (montage_image->class == DirectClass)
  661. !         montage_image->colors=NumberColors(montage_image);
  662. X        (void) fprintf(stderr,"[%u] %s %ux%u",montage_image->scene,
  663. X          montage_image->filename,montage_image->columns,montage_image->rows);
  664. X        if (montage_image->class == DirectClass)
  665. --- 1410,1416 ----
  666. X          Display detailed info about the image.
  667. X        */
  668. X        if (montage_image->class == DirectClass)
  669. !         montage_image->colors=NumberColors(montage_image,False);
  670. X        (void) fprintf(stderr,"[%u] %s %ux%u",montage_image->scene,
  671. X          montage_image->filename,montage_image->columns,montage_image->rows);
  672. X        if (montage_image->class == DirectClass)
  673. diff -r -c ImageMagick/montage.man ImageMagick2.2.1/montage.man
  674. *** ImageMagick/montage.man    Mon Dec  7 19:53:01 1992
  675. --- ImageMagick2.2.1/montage.man    Fri Dec 18 17:07:31 1992
  676. ***************
  677. *** 279,284 ****
  678. --- 279,287 ----
  679. X  .TP 5
  680. X  .B "-rotate \fIdegrees\fP"
  681. X  apply Paeth image rotation to the image.
  682. + Empty triangles left over from rotating the image are filled with
  683. + the color defined by the pixel at location (0,0).
  684. X  .TP 5
  685. X  .B "-tiles_per_row \fIvalue\fP"
  686. X  specifies how many images are to appear in each row of the composite image.
  687. diff -r -c ImageMagick/quantize.c ImageMagick2.2.1/quantize.c
  688. *** ImageMagick/quantize.c    Thu Dec 10 12:53:06 1992
  689. --- ImageMagick2.2.1/quantize.c    Mon Dec 21 11:12:00 1992
  690. ***************
  691. *** 271,277 ****
  692. X    External declarations.
  693. X  */
  694. X  extern char
  695. !   *application_name;
  696. X  
  697. X  /*
  698. X    Forward declarations.
  699. --- 271,277 ----
  700. X    External declarations.
  701. X  */
  702. X  extern char
  703. !   *client_name;
  704. X  
  705. X  /*
  706. X    Forward declarations.
  707. ***************
  708. *** 396,402 ****
  709. X            Identify the deepest node containing the pixel's color.
  710. X          */
  711. X          node=cube.root;
  712. !         do
  713. X          {
  714. X            id=(p->red > node->mid_red ? 1 : 0) |
  715. X              (p->green > node->mid_green ? 1 : 0) << 1 |
  716. --- 396,402 ----
  717. X            Identify the deepest node containing the pixel's color.
  718. X          */
  719. X          node=cube.root;
  720. !         for ( ; ; )
  721. X          {
  722. X            id=(p->red > node->mid_red ? 1 : 0) |
  723. X              (p->green > node->mid_green ? 1 : 0) << 1 |
  724. ***************
  725. *** 404,410 ****
  726. X            if ((node->children & (1 << id)) == 0)
  727. X              break;
  728. X            node=node->child[id];
  729. !         } while (True);
  730. X          p->index=(unsigned short) node->color_number;
  731. X          p++;
  732. X        }
  733. --- 404,410 ----
  734. X            if ((node->children & (1 << id)) == 0)
  735. X              break;
  736. X            node=node->child[id];
  737. !         }
  738. X          p->index=(unsigned short) node->color_number;
  739. X          p++;
  740. X        }
  741. ***************
  742. *** 415,421 ****
  743. X            Identify the deepest node containing the pixel's color.
  744. X          */
  745. X          node=cube.root;
  746. !         do
  747. X          {
  748. X            id=(p->red > node->mid_red ? 1 : 0) |
  749. X              (p->green > node->mid_green ? 1 : 0) << 1 |
  750. --- 415,421 ----
  751. X            Identify the deepest node containing the pixel's color.
  752. X          */
  753. X          node=cube.root;
  754. !         for ( ; ; )
  755. X          {
  756. X            id=(p->red > node->mid_red ? 1 : 0) |
  757. X              (p->green > node->mid_green ? 1 : 0) << 1 |
  758. ***************
  759. *** 424,430 ****
  760. X              break;
  761. X            node=node->child[id];
  762. X          }
  763. -         while (True);
  764. X          /*
  765. X            Find closest color among siblings and their children.
  766. X          */
  767. --- 424,429 ----
  768. ***************
  769. *** 902,908 ****
  770. X              Identify the deepest node containing the pixel's color.
  771. X            */
  772. X            node=cube.root;
  773. !           do
  774. X            {
  775. X              id=(q->red > node->mid_red ? 1 : 0) |
  776. X                (q->green > node->mid_green ? 1 : 0) << 1 |
  777. --- 901,907 ----
  778. X              Identify the deepest node containing the pixel's color.
  779. X            */
  780. X            node=cube.root;
  781. !           for ( ; ; )
  782. X            {
  783. X              id=(q->red > node->mid_red ? 1 : 0) |
  784. X                (q->green > node->mid_green ? 1 : 0) << 1 |
  785. ***************
  786. *** 911,917 ****
  787. X                break;
  788. X              node=node->child[id];
  789. X            }
  790. -           while (True);
  791. X            /*
  792. X              Find closest color among siblings and their children.
  793. X            */
  794. --- 910,915 ----
  795. ***************
  796. *** 1061,1068 ****
  797. X    /*
  798. X      Initialize root node.
  799. X    */
  800. !   cube.root=
  801. !     InitializeNode(0,0,(Node *) NULL,MaxRGB >> 1,MaxRGB >> 1,MaxRGB >> 1);
  802. X    if (cube.root == (Node *) NULL)
  803. X      {
  804. X        Warning("unable to quantize image","memory allocation failed");
  805. --- 1059,1066 ----
  806. X    /*
  807. X      Initialize root node.
  808. X    */
  809. !   cube.root=InitializeNode(0,0,(Node *) NULL,(MaxRGB+1) >> 1,(MaxRGB+1) >> 1,
  810. !     (MaxRGB+1) >> 1);
  811. X    if (cube.root == (Node *) NULL)
  812. X      {
  813. X        Warning("unable to quantize image","memory allocation failed");
  814. ***************
  815. *** 1478,1486 ****
  816. X    */
  817. X    *mean_error_per_pixel=(unsigned int) total_error/(image->columns*image->rows);
  818. X    *normalized_mean_square_error=((double) *mean_error_per_pixel)/
  819. !     (3.0*MaxRGB*MaxRGB);
  820. X    *normalized_maximum_square_error=((double) maximum_error_per_pixel)/
  821. !     (3.0*MaxRGB*MaxRGB);
  822. X  }
  823. X  
  824. X  /*
  825. --- 1476,1484 ----
  826. X    */
  827. X    *mean_error_per_pixel=(unsigned int) total_error/(image->columns*image->rows);
  828. X    *normalized_mean_square_error=((double) *mean_error_per_pixel)/
  829. !     (3.0*(MaxRGB+1)*(MaxRGB+1));
  830. X    *normalized_maximum_square_error=((double) maximum_error_per_pixel)/
  831. !     (3.0*(MaxRGB+1)*(MaxRGB+1));
  832. X  }
  833. X  
  834. X  /*
  835. diff -r -c ImageMagick/rotate.c ImageMagick2.2.1/rotate.c
  836. *** ImageMagick/rotate.c    Mon Dec  7 09:22:11 1992
  837. --- ImageMagick2.2.1/rotate.c    Sat Dec 19 23:46:26 1992
  838. ***************
  839. *** 3,22 ****
  840. X  %                                                                             %
  841. X  %                                                                             %
  842. X  %                                                                             %
  843. ! %                 RRRR    OOO   TTTTT   AAA   TTTTT   EEEEE                   %
  844. ! %                 R   R  O   O    T    A   A    T     E                       %
  845. ! %                 RRRR   O   O    T    AAAAA    T     EEE                     %
  846. ! %                 R R    O   O    T    A   A    T     E                       %
  847. ! %                 R  R    OOO     T    A   A    T     EEEEE                   %
  848. X  %                                                                             %
  849. X  %                                                                             %
  850. ! %                Rotate a raster image by an arbitrary angle.                 %
  851. X  %                                                                             %
  852. X  %                                                                             %
  853. X  %                                                                             %
  854. ! %                           Software Design                                   %
  855. ! %                             John Cristy                                     %
  856. ! %                              July 1992                                      %
  857. X  %                                                                             %
  858. X  %                                                                             %
  859. X  %  Copyright 1992 E. I. du Pont de Nemours & Company                          %
  860. --- 3,22 ----
  861. X  %                                                                             %
  862. X  %                                                                             %
  863. X  %                                                                             %
  864. ! %                      SSSSS  H   H  EEEEE   AAA    RRRR                      %
  865. ! %                      SS     H   H  E      A   A   R   R                     %
  866. ! %                       SSS   HHHHH  EEE    AAAAA   RRRR                      %
  867. ! %                         SS  H   H  E      A   A   R R                       %
  868. ! %                      SSSSS  H   H  EEEEE  A   A   R  R                      %
  869. X  %                                                                             %
  870. X  %                                                                             %
  871. ! %              Shear or rotate a raster image by an arbitrary angle.          %
  872. X  %                                                                             %
  873. X  %                                                                             %
  874. X  %                                                                             %
  875. ! %                               Software Design                               %
  876. ! %                                 John Cristy                                 %
  877. ! %                                  July 1992                                  %
  878. X  %                                                                             %
  879. X  %                                                                             %
  880. X  %  Copyright 1992 E. I. du Pont de Nemours & Company                          %
  881. ***************
  882. *** 42,52 ****
  883. X  %                                                                             %
  884. X  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  885. X  %
  886. ! %  Function RotateImage is based on the paper "A Fast Algorithm for General
  887. ! %  Raster Rotatation" by Alan W. Paeth.  RotateImage is adapted from a similiar
  888. ! %  routine based on the Paeth paper written by Michael Halle of the Spatial
  889. ! %  Imaging Group, MIT Media Lab.
  890. X  %
  891. X  */
  892. X  
  893. X  /*
  894. --- 42,53 ----
  895. X  %                                                                             %
  896. X  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  897. X  %
  898. ! %  Function RotateImage, XShearImage, and YShearImage is based on the paper
  899. ! %  "A Fast Algorithm for General Raster Rotatation" by Alan W. Paeth.
  900. ! %  RotateImage is adapted from a similiar routine based on the Paeth paper
  901. ! %  written by Michael Halle of the Spatial Imaging Group, MIT Media Lab.
  902. X  %
  903. + %
  904. X  */
  905. X  
  906. X  /*
  907. ***************
  908. *** 59,65 ****
  909. X    External declarations.
  910. X  */
  911. X  extern char
  912. !   *application_name;
  913. X  
  914. X  /*
  915. X  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  916. --- 60,66 ----
  917. X    External declarations.
  918. X  */
  919. X  extern char
  920. !   *client_name;
  921. X  
  922. X  /*
  923. X  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  924. ***************
  925. *** 66,298 ****
  926. X  %                                                                             %
  927. X  %                                                                             %
  928. X  %                                                                             %
  929. ! %   C o l u m n S h e a r                                                     %
  930. X  %                                                                             %
  931. X  %                                                                             %
  932. X  %                                                                             %
  933. X  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  934. X  %
  935. ! %  Procedure ColumnShear displaces a subcolumn of pixels a specified number of
  936. ! %  pixels.
  937. X  %
  938. ! %  The format of the ColumnShear routine is:
  939. X  %
  940. ! %      ColumnShear(source_image,source_columns,column,y,length,displacement,
  941. ! %        background)
  942. X  %
  943. X  %  A description of each parameter follows.
  944. X  %
  945. ! %    o source_image: A pointer to a ColorPacket structure which contains the
  946. ! %      source image.
  947. X  %
  948. ! %    o source_columns: Specifies the number of columns in the source image.
  949. X  %
  950. ! %    o column: Specifies which column in the image to move.
  951. X  %
  952. - %    o y: Specifies the offset in the source image.
  953. X  %
  954. - %    o length: Specifies the number of pixels to move.
  955. - %
  956. - %    o displacement: Specifies the number of pixels to displace the column of
  957. - %      pixels.
  958. - %
  959. - %    o background: Specifies the background color.
  960. - %
  961. - %
  962. X  */
  963. ! static void ColumnShear(source_image,source_columns,column,y,length,
  964. !   displacement,background,range_limit)
  965. ! ColorPacket
  966. !   *source_image;
  967. X  
  968. - register unsigned int
  969. -   source_columns;
  970. - unsigned int
  971. -   column,
  972. -   y,
  973. -   length;
  974. X  double
  975. !   displacement;
  976. X  
  977. ! ColorPacket
  978. !   background;
  979. ! register unsigned char
  980. !   *range_limit;
  981. X  {
  982. !   ColorPacket
  983. !     last_pixel;
  984. X  
  985. !   enum {UP,DOWN}
  986. !     direction;
  987. X  
  988. X    int
  989. !     blue,
  990. !     green,
  991. !     red,
  992. !     step;
  993. X  
  994. !   long int
  995. !     fractional_step;
  996. X  
  997. -   register ColorPacket
  998. -     *p,
  999. -     *q;
  1000. X    register int
  1001. X      i;
  1002. X  
  1003. -   if (displacement == 0.0)
  1004. -     return;
  1005. -   else
  1006. -     if (displacement > 0.0)
  1007. -       direction=DOWN;
  1008. -     else
  1009. -       {
  1010. -         displacement*=(-1.0);
  1011. -         direction=UP;
  1012. -       }
  1013. -   step=(int) floor(displacement);
  1014. -   fractional_step=UpShifted(displacement-(double) step);
  1015. -   if (fractional_step == 0)
  1016. -     {
  1017. -       /*
  1018. -         No fractional displacement-- just copy the pixels.
  1019. -       */
  1020. -       switch (direction)
  1021. -       {
  1022. -         case UP:
  1023. -         {
  1024. -           p=source_image+y*source_columns+column;
  1025. -           q=p-step*source_columns;
  1026. -           for (i=0; i < length; i++)
  1027. -           {
  1028. -             *q=(*p);
  1029. -             q+=source_columns;
  1030. -             p+=source_columns;
  1031. -           }
  1032. -           /*
  1033. -             Set old column to background color.
  1034. -           */
  1035. -           for (i=0; i < step; i++)
  1036. -           {
  1037. -             *q=background;
  1038. -             q+=source_columns;
  1039. -           }
  1040. -           break;
  1041. -         }
  1042. -         case DOWN:
  1043. -         {
  1044. -           p=source_image+(y+length)*source_columns+column;
  1045. -           q=p+step*source_columns;
  1046. -           for (i=0; i < length; i++)
  1047. -           {
  1048. -             q-=source_columns;
  1049. -             p-=source_columns;
  1050. -             *q=(*p);
  1051. -           }
  1052. -           /*
  1053. -             Set old column to background color.
  1054. -           */
  1055. -           for (i=0; i < step; i++)
  1056. -           {
  1057. -             q-=source_columns;
  1058. -             *q=background;
  1059. -           }
  1060. -           break;
  1061. -         }
  1062. -       }
  1063. -       return;
  1064. -     }
  1065. X    /*
  1066. !     Fractional displacment.
  1067. X    */
  1068. !   step++;
  1069. !   last_pixel=background;
  1070. !   switch (direction)
  1071. X    {
  1072. !     case UP:
  1073. X      {
  1074. -       p=source_image+y*source_columns+column;
  1075. -       q=p-step*source_columns;
  1076. -       for (i=0; i < length; i++)
  1077. -       {
  1078. -         red=DownShift(last_pixel.red*(UpShift(1)-fractional_step)+p->red*
  1079. -           fractional_step);
  1080. -         green=DownShift(last_pixel.green*(UpShift(1)-fractional_step)+p->green*
  1081. -           fractional_step);
  1082. -         blue=DownShift(last_pixel.blue*(UpShift(1)-fractional_step)+p->blue*
  1083. -           fractional_step);
  1084. -         last_pixel=(*p);
  1085. -         p+=source_columns;
  1086. -         q->red=range_limit[red];
  1087. -         q->green=range_limit[green];
  1088. -         q->blue=range_limit[blue];
  1089. -         q+=source_columns;
  1090. -       }
  1091. X        /*
  1092. !         Set old column to background color.
  1093. X        */
  1094. !       red=DownShift(last_pixel.red*(UpShift(1)-fractional_step)+
  1095. !         background.red*fractional_step);
  1096. !       green=DownShift(last_pixel.green*(UpShift(1)-fractional_step)+
  1097. !         background.green*fractional_step);
  1098. !       blue=DownShift(last_pixel.blue*(UpShift(1)-fractional_step)+
  1099. !         background.blue*fractional_step);
  1100. !       q->red=range_limit[red];
  1101. !       q->green=range_limit[green];
  1102. !       q->blue=range_limit[blue];
  1103. !       q+=source_columns;
  1104. !       for (i=0; i < step-1; i++)
  1105. !       {
  1106. !         *q=background;
  1107. !         q+=source_columns;
  1108. !       }
  1109. !       break;
  1110. X      }
  1111. !     case DOWN:
  1112. !     {
  1113. !       p=source_image+(y+length)*source_columns+column;
  1114. !       q=p+step*source_columns;
  1115. !       for (i=0; i < length; i++)
  1116. !       {
  1117. !         p-=source_columns;
  1118. !         red=DownShift(last_pixel.red*(UpShift(1)-fractional_step)+p->red*
  1119. !           fractional_step);
  1120. !         green=DownShift(last_pixel.green*(UpShift(1)-fractional_step)+p->green*
  1121. !           fractional_step);
  1122. !         blue=DownShift(last_pixel.blue*(UpShift(1)-fractional_step)+p->blue*
  1123. !           fractional_step);
  1124. !         last_pixel=(*p);
  1125. !         q-=source_columns;
  1126. !         q->red=range_limit[red];
  1127. !         q->green=range_limit[green];
  1128. !         q->blue=range_limit[blue];
  1129. !       }
  1130. !       /*
  1131. !         Set old column to background color.
  1132. !       */
  1133. !       red=DownShift(last_pixel.red*(UpShift(1)-fractional_step)+
  1134. !         background.red*fractional_step);
  1135. !       green=DownShift(last_pixel.green*(UpShift(1)-fractional_step)+
  1136. !         background.green*fractional_step);
  1137. !       blue=DownShift(last_pixel.blue*(UpShift(1)-fractional_step)+
  1138. !         background.blue*fractional_step);
  1139. !       q-=source_columns;
  1140. !       q->red=range_limit[red];
  1141. !       q->green=range_limit[green];
  1142. !       q->blue=range_limit[blue];
  1143. !       for (i=0; i < step-1; i++)
  1144. !       {
  1145. !         q-=source_columns;
  1146. !         *q=background;
  1147. !       }
  1148. !       break;
  1149. !     }
  1150. !   }
  1151. !   return;
  1152. X  }
  1153. X  
  1154. X  /*
  1155. --- 67,188 ----
  1156. X  %                                                                             %
  1157. X  %                                                                             %
  1158. X  %                                                                             %
  1159. ! %   C l i p S h e a r I m a g e                                               %
  1160. X  %                                                                             %
  1161. X  %                                                                             %
  1162. X  %                                                                             %
  1163. X  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1164. X  %
  1165. ! %  Function ClipShearImage clips the sheared image as determined by the
  1166. ! %  bounding box as defined by width and height and shearing angles.
  1167. X  %
  1168. ! %  The format of the ClipShearImage routine is:
  1169. X  %
  1170. ! %      ClipShearImage(image,x_shear,y_shear,width,height,clip)
  1171. X  %
  1172. X  %  A description of each parameter follows.
  1173. X  %
  1174. ! %    o image: The address of a structure of type Image.
  1175. X  %
  1176. ! %    o x_shear, y_shear, width, height: Defines a region of the image to clip.
  1177. X  %
  1178. ! %    o clip: A value other than zero clips the corners of the rotated
  1179. ! %      image and retains the original image size.
  1180. X  %
  1181. X  %
  1182. X  */
  1183. ! static Image *ClipShearImage(image,x_shear,y_shear,width,height,clip)
  1184. ! Image
  1185. !   *image;
  1186. X  
  1187. X  double
  1188. !   x_shear,
  1189. !   y_shear;
  1190. X  
  1191. ! unsigned int
  1192. !   width,
  1193. !   height,
  1194. !   clip;
  1195. X  {
  1196. !   typedef struct Point
  1197. !   {
  1198. !     double
  1199. !       x,
  1200. !       y;
  1201. !   } Point;
  1202. X  
  1203. !   double
  1204. !     x_max,
  1205. !     x_min,
  1206. !     y_max,
  1207. !     y_min;
  1208. X  
  1209. +   Image
  1210. +     *clipped_image;
  1211. X    int
  1212. !     x_offset,
  1213. !     y_offset;
  1214. X  
  1215. !   Point
  1216. !     corners[4];
  1217. X  
  1218. X    register int
  1219. X      i;
  1220. X  
  1221. X    /*
  1222. !     Calculate the rotated image size.
  1223. X    */
  1224. !   corners[0].x=(-((int) width)/2.0);
  1225. !   corners[0].y=(-((int) height)/2.0);
  1226. !   corners[1].x=((int) width)/2.0;
  1227. !   corners[1].y=(-((int) height)/2.0);
  1228. !   corners[2].x=(-((int) width)/2.0);
  1229. !   corners[2].y=((int) height)/2.0;
  1230. !   corners[3].x=((int) width)/2.0;
  1231. !   corners[3].y=((int) height)/2.0;
  1232. !   for (i=0; i < 4; i++)
  1233. X    {
  1234. !     corners[i].x+=x_shear*corners[i].y;
  1235. !     corners[i].y+=y_shear*corners[i].x;
  1236. !     corners[i].x+=x_shear*corners[i].y;
  1237. !     corners[i].x+=(image->columns-1)/2.0;
  1238. !     corners[i].y+=(image->rows-3)/2.0;
  1239. !   }
  1240. !   x_min=corners[0].x;
  1241. !   y_min=corners[0].y;
  1242. !   x_max=corners[0].x;
  1243. !   y_max=corners[0].y;
  1244. !   for (i=1; i < 4; i++)
  1245. !   {
  1246. !     if (x_min > corners[i].x)
  1247. !       x_min=corners[i].x;
  1248. !     if (y_min > corners[i].y)
  1249. !       y_min=corners[i].y;
  1250. !     if (x_max < corners[i].x)
  1251. !       x_max=corners[i].x;
  1252. !     if (y_max < corners[i].y)
  1253. !       y_max=corners[i].y;
  1254. !   }
  1255. !   x_min=floor((double) x_min);
  1256. !   x_max=ceil((double) x_max);
  1257. !   y_min=floor((double) y_min);
  1258. !   y_max=ceil((double) y_max);
  1259. !   if (!clip)
  1260. X      {
  1261. X        /*
  1262. !         Do not clip sheared image.
  1263. X        */
  1264. !       width=(unsigned int) (x_max-x_min);
  1265. !       height=(unsigned int) (y_max-y_min);
  1266. X      }
  1267. !   x_offset=(int) x_min+((int) (x_max-x_min)-width)/2;
  1268. !   y_offset=(int) y_min+((int) (y_max-y_min)-height)/2;
  1269. !   /*
  1270. !     Clip image and return.
  1271. !   */
  1272. !   clipped_image=ClipImage(image,x_offset,y_offset+1,width,height);
  1273. !   return(clipped_image);
  1274. X  }
  1275. X  
  1276. X  /*
  1277. ***************
  1278. *** 300,374 ****
  1279. X  %                                                                             %
  1280. X  %                                                                             %
  1281. X  %                                                                             %
  1282. ! %   I n t e g r a l R o t a t i o n                                           %
  1283. X  %                                                                             %
  1284. X  %                                                                             %
  1285. X  %                                                                             %
  1286. X  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1287. X  %
  1288. ! %  Function IntegralRotation rotates the source image starting at location
  1289. ! %  (x,y) an integral of 90 degrees and copies the result to the rotated image
  1290. ! %  buffer.
  1291. X  %
  1292. ! %  The format of the IntegralRotation routine is:
  1293. X  %
  1294. ! %      IntegralRotation(image,source_columns,source_rows,rotated_image,
  1295. ! %        rotated_columns,x,y,rotations)
  1296. X  %
  1297. X  %  A description of each parameter follows.
  1298. X  %
  1299. ! %    o source_image: A pointer to a Image structure containing the source
  1300. ! %      image.
  1301. X  %
  1302. ! %    o source_columns: Specifies the number of columns of pixels in the
  1303. ! %      source image.
  1304. X  %
  1305. - %    o source_rows: Specifies the number of rows of pixels in the source
  1306. - %      image.
  1307. - %
  1308. - %    o rotated_image: A pointer to a ColorPacket structure containing the
  1309. - %      rotated image.
  1310. - %
  1311. - %    o rotated_columns: Specifies the number of columns of pixels in the
  1312. - %      rotated image.
  1313. - %
  1314. - %    o x: Specifies the x offset in the source image.
  1315. - %
  1316. - %    o y: Specifies the y offset in the source image.
  1317. - %
  1318. X  %    o rotations: Specifies the number of 90 degree rotations.
  1319. X  %
  1320. X  %
  1321. X  */
  1322. ! static void IntegralRotation(image,source_columns,source_rows,rotated_image,
  1323. !   rotated_columns,x,y,rotations)
  1324. X  Image
  1325. X    *image;
  1326. X  
  1327. X  unsigned int
  1328. -   source_columns,
  1329. -   source_rows;
  1330. - ColorPacket
  1331. -   *rotated_image;
  1332. - unsigned int
  1333. -   rotated_columns,
  1334. -   x,
  1335. -   y,
  1336. X    rotations;
  1337. X  {
  1338. !   ColorPacket
  1339. !     *q;
  1340. X  
  1341. X    register RunlengthPacket
  1342. !     *p;
  1343. X  
  1344. X    register int
  1345. !     i,
  1346. !     j;
  1347. X  
  1348. X    /*
  1349. X      Expand runlength packets into a rectangular array of pixels.
  1350. X    */
  1351. X    p=image->pixels;
  1352. --- 190,252 ----
  1353. X  %                                                                             %
  1354. X  %                                                                             %
  1355. X  %                                                                             %
  1356. ! %   I n t e g r a l R o t a t e I m a g e                                     %
  1357. X  %                                                                             %
  1358. X  %                                                                             %
  1359. X  %                                                                             %
  1360. X  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1361. X  %
  1362. ! %  Function IntegralRotateImage rotates the image an integral of 90 degrees.
  1363. ! %  It allocates the memory necessary for the new Image structure and returns
  1364. ! %  a pointer to the rotated image.
  1365. X  %
  1366. ! %  The format of the IntegralRotateImage routine is:
  1367. X  %
  1368. ! %      rotated_image=IntegralRotateImage(image,rotations)
  1369. X  %
  1370. X  %  A description of each parameter follows.
  1371. X  %
  1372. ! %    o rotated_image: Function IntegralRotateImage returns a pointer to the
  1373. ! %      rotated image.  A null image is returned if there is a a memory shortage.
  1374. X  %
  1375. ! %    o image: The address of a structure of type Image.
  1376. X  %
  1377. X  %    o rotations: Specifies the number of 90 degree rotations.
  1378. X  %
  1379. X  %
  1380. X  */
  1381. ! static Image *IntegralRotateImage(image,rotations)
  1382. X  Image
  1383. X    *image;
  1384. X  
  1385. X  unsigned int
  1386. X    rotations;
  1387. X  {
  1388. !   Image
  1389. !     *rotated_image;
  1390. X  
  1391. X    register RunlengthPacket
  1392. !     *p,
  1393. !     *q;
  1394. X  
  1395. X    register int
  1396. !     x,
  1397. !     y;
  1398. X  
  1399. X    /*
  1400. +     Initialize rotated image attributes.
  1401. +   */
  1402. +   rotations%=4;
  1403. +   if ((rotations == 1) || (rotations == 3))
  1404. +     rotated_image=CopyImage(image,image->rows,image->columns,False);
  1405. +   else
  1406. +     rotated_image=CopyImage(image,image->columns,image->rows,False);
  1407. +   if (rotated_image == (Image *) NULL)
  1408. +     {
  1409. +       Warning("unable to rotate image","memory allocation failed");
  1410. +       return((Image *) NULL);
  1411. +     }
  1412. +   /*
  1413. X      Expand runlength packets into a rectangular array of pixels.
  1414. X    */
  1415. X    p=image->pixels;
  1416. ***************
  1417. *** 380,389 ****
  1418. X        /*
  1419. X          Rotate 0 degrees.
  1420. X        */
  1421. !       for (j=0; j < source_rows; j++)
  1422. X        {
  1423. !         q=rotated_image+rotated_columns*(y+j)+x;
  1424. !         for (i=0; i < source_columns; i++)
  1425. X          {
  1426. X            if (image->runlength > 0)
  1427. X              image->runlength--;
  1428. --- 258,267 ----
  1429. X        /*
  1430. X          Rotate 0 degrees.
  1431. X        */
  1432. !       for (y=0; y < image->rows; y++)
  1433. X        {
  1434. !         q=rotated_image->pixels+rotated_image->columns*y;
  1435. !         for (x=0; x < image->columns; x++)
  1436. X          {
  1437. X            if (image->runlength > 0)
  1438. X              image->runlength--;
  1439. ***************
  1440. *** 396,401 ****
  1441. --- 274,280 ----
  1442. X            q->green=p->green;
  1443. X            q->blue=p->blue;
  1444. X            q->index=p->index;
  1445. +           q->length=0;
  1446. X            q++;
  1447. X          }
  1448. X        }
  1449. ***************
  1450. *** 406,415 ****
  1451. X        /*
  1452. X          Rotate 90 degrees.
  1453. X        */
  1454. !       for (j=source_columns-1; j >= 0; j--)
  1455. X        {
  1456. !         q=rotated_image+rotated_columns*y+x+j;
  1457. !         for (i=0; i < source_rows; i++)
  1458. X          {
  1459. X            if (image->runlength > 0)
  1460. X              image->runlength--;
  1461. --- 285,294 ----
  1462. X        /*
  1463. X          Rotate 90 degrees.
  1464. X        */
  1465. !       for (x=0; x < rotated_image->columns; x++)
  1466. X        {
  1467. !         q=rotated_image->pixels+(rotated_image->columns-x-1);
  1468. !         for (y=0; y < rotated_image->rows; y++)
  1469. X          {
  1470. X            if (image->runlength > 0)
  1471. X              image->runlength--;
  1472. ***************
  1473. *** 422,428 ****
  1474. X            q->green=p->green;
  1475. X            q->blue=p->blue;
  1476. X            q->index=p->index;
  1477. !           q+=rotated_columns;
  1478. X          }
  1479. X        }
  1480. X        break;
  1481. --- 301,308 ----
  1482. X            q->green=p->green;
  1483. X            q->blue=p->blue;
  1484. X            q->index=p->index;
  1485. !           q->length=0;
  1486. !           q+=rotated_image->columns;
  1487. X          }
  1488. X        }
  1489. X        break;
  1490. ***************
  1491. *** 432,442 ****
  1492. X        /*
  1493. X          Rotate 180 degrees.
  1494. X        */
  1495. !       q=rotated_image;
  1496. !       for (j=source_rows-1; j >= 0; j--)
  1497. X        {
  1498. !         q=rotated_image+rotated_columns*(y+j)+x+source_columns;
  1499. !         for (i=0; i < source_columns; i++)
  1500. X          {
  1501. X            if (image->runlength > 0)
  1502. X              image->runlength--;
  1503. --- 312,322 ----
  1504. X        /*
  1505. X          Rotate 180 degrees.
  1506. X        */
  1507. !       q=rotated_image->pixels;
  1508. !       for (y=image->rows-1; y >= 0; y--)
  1509. X        {
  1510. !         q=rotated_image->pixels+rotated_image->columns*y+rotated_image->columns;
  1511. !         for (x=0; x < image->columns; x++)
  1512. X          {
  1513. X            if (image->runlength > 0)
  1514. X              image->runlength--;
  1515. ***************
  1516. *** 450,455 ****
  1517. --- 330,336 ----
  1518. X            q->green=p->green;
  1519. X            q->blue=p->blue;
  1520. X            q->index=p->index;
  1521. +           q->length=0;
  1522. X          }
  1523. X        }
  1524. X        break;
  1525. ***************
  1526. *** 459,468 ****
  1527. X        /*
  1528. X          Rotate 270 degrees.
  1529. X        */
  1530. !       for (j=0; j < source_columns; j++)
  1531. X        {
  1532. !         q=rotated_image+rotated_columns*(y+source_rows)+x+j-rotated_columns;
  1533. !         for (i=0; i < source_rows; i++)
  1534. X          {
  1535. X            if (image->runlength > 0)
  1536. X              image->runlength--;
  1537. --- 340,350 ----
  1538. X        /*
  1539. X          Rotate 270 degrees.
  1540. X        */
  1541. !       for (x=0; x < rotated_image->columns; x++)
  1542. X        {
  1543. !         q=rotated_image->pixels+(rotated_image->columns*rotated_image->rows)-
  1544. !           (rotated_image->columns-x-1)-1;
  1545. !         for (y=0; y < rotated_image->rows; y++)
  1546. X          {
  1547. X            if (image->runlength > 0)
  1548. X              image->runlength--;
  1549. ***************
  1550. *** 475,488 ****
  1551. X            q->green=p->green;
  1552. X            q->blue=p->blue;
  1553. X            q->index=p->index;
  1554. !           q-=rotated_columns;
  1555. X          }
  1556. X        }
  1557. X        break;
  1558. X      }
  1559. -     default:
  1560. -       break;
  1561. X    }
  1562. X  }
  1563. X  
  1564. X  /*
  1565. --- 357,370 ----
  1566. X            q->green=p->green;
  1567. X            q->blue=p->blue;
  1568. X            q->index=p->index;
  1569. !           q->length=0;
  1570. !           q-=rotated_image->columns;
  1571. X          }
  1572. X        }
  1573. X        break;
  1574. X      }
  1575. X    }
  1576. +   return(rotated_image);
  1577. X  }
  1578. X  
  1579. X  /*
  1580. ***************
  1581. *** 490,541 ****
  1582. X  %                                                                             %
  1583. X  %                                                                             %
  1584. X  %                                                                             %
  1585. ! %   R o w S h e a r                                                           %
  1586. X  %                                                                             %
  1587. X  %                                                                             %
  1588. X  %                                                                             %
  1589. X  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1590. X  %
  1591. ! %  Procedure RowShear displaces a subrow of pixels a specified number of
  1592. ! %  pixels.
  1593. X  %
  1594. ! %  The format of the RowShear routine is:
  1595. X  %
  1596. ! %      RowShear(source_image,source_columns,row,y,length,displacement,
  1597. ! %        background)
  1598. X  %
  1599. X  %  A description of each parameter follows.
  1600. X  %
  1601. ! %    o source_image: A pointer to a ColorPacket structure.
  1602. X  %
  1603. ! %    o source_columns: Specifies the number of columns in the source image.
  1604. X  %
  1605. ! %    o row: Specifies which row in the image to move.
  1606. X  %
  1607. ! %    o y: Specifies the offset in the source image.
  1608. X  %
  1609. - %    o length: Specifies the number of pixels to move.
  1610. X  %
  1611. - %    o displacement: Specifies the number of pixels to displace the row of
  1612. - %      pixels.
  1613. - %
  1614. - %    o background: Specifies the background color.
  1615. - %
  1616. - %
  1617. X  */
  1618. ! static void RowShear(source_image,source_columns,row,x,length,displacement,
  1619. !   background,range_limit)
  1620. ! ColorPacket
  1621. !   *source_image;
  1622. X  
  1623. X  unsigned int
  1624. !   source_columns,
  1625. !   row,
  1626. !   x,
  1627. !   length;
  1628. X  
  1629. ! double
  1630. !   displacement;
  1631. X  
  1632. X  ColorPacket
  1633. X    background;
  1634. --- 372,423 ----
  1635. X  %                                                                             %
  1636. X  %                                                                             %
  1637. X  %                                                                             %
  1638. ! %   X S h e a r I m a g e                                                     %
  1639. X  %                                                                             %
  1640. X  %                                                                             %
  1641. X  %                                                                             %
  1642. X  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1643. X  %
  1644. ! %  Procedure XShearImage shears the image in the X direction with a shear angle
  1645. ! %  of 'degrees'.  Positive angles shear counter-clockwise (right-hand rule),
  1646. ! %  and negative angles shear clockwise.  Angles are measured relative to a
  1647. ! %  vertical Y-axis.  X shears will widen an image creating 'empty' triangles
  1648. ! %  on the left and right sides of the source image.
  1649. X  %
  1650. ! %  The format of the XShearImage routine is:
  1651. X  %
  1652. ! %      XShearImage(image,degrees,width,height,x_offset,y_offset,background,
  1653. ! %        range_limit)
  1654. X  %
  1655. X  %  A description of each parameter follows.
  1656. X  %
  1657. ! %    o image: The address of a structure of type Image.
  1658. X  %
  1659. ! %    o degrees: A double representing the shearing angle along the X axis.
  1660. X  %
  1661. ! %    o width, height, x_offset, y_offset: Defines a region of the image
  1662. ! %      to shear.
  1663. X  %
  1664. ! %    o background: Specifies a ColorPacket used to fill empty triangles
  1665. ! %      left over from shearing.
  1666. X  %
  1667. X  %
  1668. X  */
  1669. ! static void XShearImage(image,degrees,width,height,x_offset,y_offset,background,
  1670. !   range_limit)
  1671. ! Image
  1672. !   *image;
  1673. X  
  1674. + double
  1675. +   degrees;
  1676. X  unsigned int
  1677. !   width,
  1678. !   height;
  1679. X  
  1680. ! int
  1681. !   x_offset,
  1682. !   y_offset;
  1683. X  
  1684. X  ColorPacket
  1685. X    background;
  1686. ***************
  1687. *** 543,573 ****
  1688. X  register unsigned char
  1689. X    *range_limit;
  1690. X  {
  1691. !   ColorPacket
  1692. !     last_pixel;
  1693. X  
  1694. X    enum {LEFT,RIGHT}
  1695. X      direction;
  1696. X  
  1697. X    int
  1698. !     blue,
  1699. !     green,
  1700. !     red,
  1701. !     step;
  1702. X  
  1703. X    long int
  1704. X      fractional_step;
  1705. X  
  1706. !   register ColorPacket
  1707. X      *p,
  1708. X      *q;
  1709. X  
  1710. X    register int
  1711. !     i;
  1712. X  
  1713. !   if (displacement == 0.0)
  1714. !     return;
  1715. !   else
  1716. X      if (displacement > 0.0)
  1717. X        direction=RIGHT;
  1718. X      else
  1719. --- 425,463 ----
  1720. X  register unsigned char
  1721. X    *range_limit;
  1722. X  {
  1723. !   double
  1724. !     displacement;
  1725. X  
  1726. X    enum {LEFT,RIGHT}
  1727. X      direction;
  1728. X  
  1729. X    int
  1730. !     step,
  1731. !     y;
  1732. X  
  1733. X    long int
  1734. X      fractional_step;
  1735. X  
  1736. !   register RunlengthPacket
  1737. X      *p,
  1738. X      *q;
  1739. X  
  1740. X    register int
  1741. !     blue,
  1742. !     green,
  1743. !     i,
  1744. !     red;
  1745. X  
  1746. !   RunlengthPacket
  1747. !     last_pixel;
  1748. !   y_offset--;
  1749. !   for (y=0; y < height; y++)
  1750. !   {
  1751. !     y_offset++;
  1752. !     displacement=degrees*(((double) y)-(height-1)/2.0);
  1753. !     if (displacement == 0.0)
  1754. !       continue;
  1755. X      if (displacement > 0.0)
  1756. X        direction=RIGHT;
  1757. X      else
  1758. ***************
  1759. *** 575,723 ****
  1760. X          displacement*=(-1.0);
  1761. X          direction=LEFT;
  1762. X        }
  1763. !   step=(int) floor(displacement);
  1764. !   fractional_step=UpShifted(displacement-(double) step);
  1765. !   if (fractional_step == 0)
  1766. !     {
  1767. !       /*
  1768. !         No fractional displacement-- just copy.
  1769. !       */
  1770. !       switch (direction)
  1771. X        {
  1772. !         case LEFT:
  1773. X          {
  1774. !           p=source_image+row*source_columns+x;
  1775. !           q=p-step;
  1776. !           for (i=0; i < length; i++)
  1777. X            {
  1778. !             *q=(*p);
  1779. !             q++;
  1780. !             p++;
  1781. X            }
  1782. !           /*
  1783. !             Set old row to background color.
  1784. !           */
  1785. !           for (i=0; i < step; i++)
  1786. X            {
  1787. !             *q=background;
  1788. !             q++;
  1789. X            }
  1790. -           break;
  1791. X          }
  1792. !         case RIGHT:
  1793. !         {
  1794. !           /*
  1795. !             Right is the same as left except data is transferred backwards
  1796. !             to prevent deleting data we need later.
  1797. !           */
  1798. !           p=source_image+row*source_columns+x+length;
  1799. !           q=p+step;
  1800. !           for (i=0; i < length; i++)
  1801. !           {
  1802. !             p--;
  1803. !             q--;
  1804. !             *q=(*p);
  1805. !           }
  1806. !           /*
  1807. !             Set old row to background color.
  1808. !           */
  1809. !           for (i=0; i < step; i++)
  1810. !           {
  1811. !             q--;
  1812. !             *q=background;
  1813. !           }
  1814. !           break;
  1815. !         }
  1816. X        }
  1817. !       return;
  1818. !     }
  1819. !   /*
  1820. !     Fractional displacement.
  1821. !   */
  1822. !   step++;
  1823. !   last_pixel=background;
  1824. !   switch (direction)
  1825. !   {
  1826. !     case LEFT:
  1827. X      {
  1828. !       p=source_image+row*source_columns+x;
  1829. !       q=p-step;
  1830. !       for (i=0; i < length; i++)
  1831. X        {
  1832. !         red=DownShift(last_pixel.red*(UpShift(1)-fractional_step)+p->red*
  1833. !           fractional_step);
  1834. !         green=DownShift(last_pixel.green*(UpShift(1)-fractional_step)+p->green*
  1835. !           fractional_step);
  1836. !         blue=DownShift(last_pixel.blue*(UpShift(1)-fractional_step)+p->blue*
  1837. !           fractional_step);
  1838. !         last_pixel=(*p);
  1839. !         p++;
  1840. X          q->red=range_limit[red];
  1841. X          q->green=range_limit[green];
  1842. X          q->blue=range_limit[blue];
  1843. X          q++;
  1844. X        }
  1845. !       /*
  1846. !         Set old row to background color.
  1847. !       */
  1848. !       red=DownShift(last_pixel.red*(UpShift(1)-fractional_step)+
  1849. !         background.red*fractional_step);
  1850. !       green=DownShift(last_pixel.green*(UpShift(1)-fractional_step)+
  1851. !         background.green*fractional_step);
  1852. !       blue=DownShift(last_pixel.blue*(UpShift(1)-fractional_step)+
  1853. !         background.blue*fractional_step);
  1854. !       q->red=range_limit[red];
  1855. !       q->green=range_limit[green];
  1856. !       q->blue=range_limit[blue];
  1857. !       q++;
  1858. !       for (i=0; i < step-1; i++)
  1859. X        {
  1860. !         *q=background;
  1861. !         q++;
  1862. X        }
  1863. -       break;
  1864. X      }
  1865. !     case RIGHT:
  1866. X      {
  1867. !       p=source_image+row*source_columns+x+length;
  1868. !       q=p+step;
  1869. !       for (i=0; i < length; i++)
  1870. X        {
  1871. !         p--;
  1872. !         red=DownShift(last_pixel.red*(UpShift(1)-fractional_step)+p->red*
  1873. !           fractional_step);
  1874. !         green=DownShift(last_pixel.green*(UpShift(1)-fractional_step)+p->green*
  1875. !           fractional_step);
  1876. !         blue=DownShift(last_pixel.blue*(UpShift(1)-fractional_step)+p->blue*
  1877. !           fractional_step);
  1878. !         last_pixel=(*p);
  1879. !         q--;
  1880. X          q->red=range_limit[red];
  1881. X          q->green=range_limit[green];
  1882. X          q->blue=range_limit[blue];
  1883. X        }
  1884. !       /*
  1885. !         Set old row to background color.
  1886. !       */
  1887. !       red=DownShift(last_pixel.red*(UpShift(1)-fractional_step)+
  1888. !         background.red*fractional_step);
  1889. !       green=DownShift(last_pixel.green*(UpShift(1)-fractional_step)+
  1890. !         background.green*fractional_step);
  1891. !       blue=DownShift(last_pixel.blue*(UpShift(1)-fractional_step)+
  1892. !         background.blue*fractional_step);
  1893. !       q--;
  1894. !       q->red=range_limit[red];
  1895. !       q->green=range_limit[green];
  1896. !       q->blue=range_limit[blue];
  1897. !       for (i=0; i < step-1; i++)
  1898. X        {
  1899. !         q--;
  1900. !         *q=background;
  1901. X        }
  1902. -       break;
  1903. X      }
  1904. X    }
  1905. -   return;
  1906. X  }
  1907. X  
  1908. X  /*
  1909. --- 465,892 ----
  1910. X          displacement*=(-1.0);
  1911. X          direction=LEFT;
  1912. X        }
  1913. !     step=(int) floor(displacement);
  1914. !     fractional_step=UpShifted(displacement-(double) step);
  1915. !     if (fractional_step == 0)
  1916. X        {
  1917. !         /*
  1918. !           No fractional displacement-- just copy.
  1919. !         */
  1920. !         switch (direction)
  1921. X          {
  1922. !           case LEFT:
  1923. X            {
  1924. !             /*
  1925. !               Transfer pixels left-to-right.
  1926. !             */
  1927. !             p=image->pixels+image->columns*y_offset+x_offset;
  1928. !             q=p-step;
  1929. !             for (i=0; i < width; i++)
  1930. !             {
  1931. !               *q=(*p);
  1932. !               q++;
  1933. !               p++;
  1934. !             }
  1935. !             /*
  1936. !               Set old row to background color.
  1937. !             */
  1938. !             for (i=0; i < step; i++)
  1939. !             {
  1940. !               q->red=background.red;
  1941. !               q->green=background.green;
  1942. !               q->blue=background.blue;
  1943. !               q++;
  1944. !             }
  1945. !             break;
  1946. X            }
  1947. !           case RIGHT:
  1948. X            {
  1949. !             /*
  1950. !               Transfer pixels right-to-left.
  1951. !             */
  1952. !             p=image->pixels+image->columns*y_offset+x_offset+width;
  1953. !             q=p+step;
  1954. !             for (i=0; i < width; i++)
  1955. !             {
  1956. !               p--;
  1957. !               q--;
  1958. !               *q=(*p);
  1959. !             }
  1960. !             /*
  1961. !               Set old row to background color.
  1962. !             */
  1963. !             for (i=0; i < step; i++)
  1964. !             {
  1965. !               q--;
  1966. !               q->red=background.red;
  1967. !               q->green=background.green;
  1968. !               q->blue=background.blue;
  1969. !             }
  1970. !             break;
  1971. X            }
  1972. X          }
  1973. !         continue;
  1974. X        }
  1975. !     /*
  1976. !       Fractional displacement.
  1977. !     */
  1978. !     step++;
  1979. !     last_pixel.red=background.red;
  1980. !     last_pixel.green=background.green;
  1981. !     last_pixel.blue=background.blue;
  1982. !     switch (direction)
  1983. X      {
  1984. !       case LEFT:
  1985. X        {
  1986. !         /*
  1987. !           Transfer pixels left-to-right.
  1988. !         */
  1989. !         p=image->pixels+image->columns*y_offset+x_offset;
  1990. !         q=p-step;
  1991. !         for (i=0; i < width; i++)
  1992. !         {
  1993. !           red=DownShift(last_pixel.red*(UpShift(1)-fractional_step)+p->red*
  1994. !             fractional_step);
  1995. !           green=DownShift(last_pixel.green*(UpShift(1)-fractional_step)+
  1996. !             p->green*fractional_step);
  1997. !           blue=DownShift(last_pixel.blue*(UpShift(1)-fractional_step)+p->blue*
  1998. !             fractional_step);
  1999. !           last_pixel=(*p);
  2000. !           p++;
  2001. !           q->red=range_limit[red];
  2002. !           q->green=range_limit[green];
  2003. !           q->blue=range_limit[blue];
  2004. !           q++;
  2005. !         }
  2006. !         /*
  2007. !           Set old row to background color.
  2008. !         */
  2009. !         red=DownShift(last_pixel.red*(UpShift(1)-fractional_step)+
  2010. !           background.red*fractional_step);
  2011. !         green=DownShift(last_pixel.green*(UpShift(1)-fractional_step)+
  2012. !           background.green*fractional_step);
  2013. !         blue=DownShift(last_pixel.blue*(UpShift(1)-fractional_step)+
  2014. !           background.blue*fractional_step);
  2015. X          q->red=range_limit[red];
  2016. X          q->green=range_limit[green];
  2017. X          q->blue=range_limit[blue];
  2018. X          q++;
  2019. +         for (i=0; i < step-1; i++)
  2020. +         {
  2021. +           q->red=background.red;
  2022. +           q->green=background.green;
  2023. +           q->blue=background.blue;
  2024. +           q++;
  2025. +         }
  2026. +         break;
  2027. X        }
  2028. !       case RIGHT:
  2029. X        {
  2030. !         /*
  2031. !           Transfer pixels right-to-left.
  2032. !         */
  2033. !         p=image->pixels+image->columns*y_offset+x_offset+width;
  2034. !         q=p+step;
  2035. !         for (i=0; i < width; i++)
  2036. !         {
  2037. !           p--;
  2038. !           red=DownShift(last_pixel.red*(UpShift(1)-fractional_step)+p->red*
  2039. !             fractional_step);
  2040. !           green=DownShift(last_pixel.green*(UpShift(1)-fractional_step)+
  2041. !             p->green*fractional_step);
  2042. !           blue=DownShift(last_pixel.blue*(UpShift(1)-fractional_step)+p->blue*
  2043. !             fractional_step);
  2044. !           last_pixel=(*p);
  2045. !           q--;
  2046. !           q->red=range_limit[red];
  2047. !           q->green=range_limit[green];
  2048. !           q->blue=range_limit[blue];
  2049. !         }
  2050. !         /*
  2051. !           Set old row to background color.
  2052. !         */
  2053. !         red=DownShift(last_pixel.red*(UpShift(1)-fractional_step)+
  2054. !           background.red*fractional_step);
  2055. !         green=DownShift(last_pixel.green*(UpShift(1)-fractional_step)+
  2056. !           background.green*fractional_step);
  2057. !         blue=DownShift(last_pixel.blue*(UpShift(1)-fractional_step)+
  2058. !           background.blue*fractional_step);
  2059. !         q--;
  2060. !         q->red=range_limit[red];
  2061. !         q->green=range_limit[green];
  2062. !         q->blue=range_limit[blue];
  2063. !         for (i=0; i < step-1; i++)
  2064. !         {
  2065. !           q--;
  2066. !           q->red=background.red;
  2067. !           q->green=background.green;
  2068. !           q->blue=background.blue;
  2069. !         }
  2070. !         break;
  2071. X        }
  2072. X      }
  2073. !   }
  2074. ! }
  2075. ! /*
  2076. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2077. ! %                                                                             %
  2078. ! %                                                                             %
  2079. ! %                                                                             %
  2080. ! %   Y S h e a r I m a g e                                                     %
  2081. ! %                                                                             %
  2082. ! %                                                                             %
  2083. ! %                                                                             %
  2084. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2085. ! %
  2086. ! %  Procedure YShearImage shears the image in the Y direction with a shear
  2087. ! %  angle of 'degrees'.  Positive angles shear counter-clockwise (right-hand
  2088. ! %  rule), and negative angles shear clockwise.  Angles are measured relative
  2089. ! %  to a horizontal X-axis.  Y shears will increase the height of an image
  2090. ! %  creating 'empty' triangles on the top and bottom of the source image.
  2091. ! %
  2092. ! %  The format of the YShearImage routine is:
  2093. ! %
  2094. ! %      YShearImage(image,degrees,width,height,x_offset,y_offset,background,
  2095. ! %        range_limit)
  2096. ! %
  2097. ! %  A description of each parameter follows.
  2098. ! %
  2099. ! %    o image: The address of a structure of type Image.
  2100. ! %
  2101. ! %    o degrees: A double representing the shearing angle along the Y axis.
  2102. ! %
  2103. ! %    o width, height, x_offset, y_offset: Defines a region of the image
  2104. ! %      to shear.
  2105. ! %
  2106. ! %    o background: Specifies a ColorPacket used to fill empty triangles
  2107. ! %      left over from shearing.
  2108. ! %
  2109. ! %
  2110. ! */
  2111. ! static void YShearImage(image,degrees,width,height,x_offset,y_offset,background,
  2112. !   range_limit)
  2113. ! Image
  2114. !   *image;
  2115. ! double
  2116. !   degrees;
  2117. ! unsigned int
  2118. !   width,
  2119. !   height;
  2120. ! int
  2121. !   x_offset,
  2122. !   y_offset;
  2123. ! ColorPacket
  2124. !   background;
  2125. ! register unsigned char
  2126. !   *range_limit;
  2127. ! {
  2128. !   double
  2129. !     displacement;
  2130. !   enum {UP,DOWN}
  2131. !     direction;
  2132. !   int
  2133. !     step,
  2134. !     y;
  2135. !   long int
  2136. !     fractional_step;
  2137. !   register RunlengthPacket
  2138. !     *p,
  2139. !     *q;
  2140. !   register int
  2141. !     blue,
  2142. !     green,
  2143. !     i,
  2144. !     red;
  2145. !   RunlengthPacket
  2146. !     last_pixel;
  2147. !   x_offset--;
  2148. !   for (y=0; y < width; y++)
  2149. !   {
  2150. !     x_offset++;
  2151. !     displacement=degrees*(((double) y)-(width-1)/2.0);
  2152. !     if (displacement == 0.0)
  2153. !       continue;
  2154. !     if (displacement > 0.0)
  2155. !       direction=DOWN;
  2156. !     else
  2157. !       {
  2158. !         displacement*=(-1.0);
  2159. !         direction=UP;
  2160. !       }
  2161. !     step=(int) floor(displacement);
  2162. !     fractional_step=UpShifted(displacement-(double) step);
  2163. !     if (fractional_step == 0)
  2164. !       {
  2165. !         /*
  2166. !           No fractional displacement-- just copy the pixels.
  2167. !         */
  2168. !         switch (direction)
  2169. !         {
  2170. !           case UP:
  2171. !           {
  2172. !             /*
  2173. !               Transfer pixels top-to-bottom.
  2174. !             */
  2175. !             p=image->pixels+image->columns*y_offset+x_offset;
  2176. !             q=p-step*image->columns;
  2177. !             for (i=0; i < height; i++)
  2178. !             {
  2179. !               *q=(*p);
  2180. !               q+=image->columns;
  2181. !               p+=image->columns;
  2182. !             }
  2183. !             /*
  2184. !               Set old column to background color.
  2185. !             */
  2186. !             for (i=0; i < step; i++)
  2187. !             {
  2188. !               q->red=background.red;
  2189. !               q->green=background.green;
  2190. !               q->blue=background.blue;
  2191. !               q+=image->columns;
  2192. !             }
  2193. !             break;
  2194. !           }
  2195. !           case DOWN:
  2196. !           {
  2197. !             /*
  2198. !               Transfer pixels bottom-to-top.
  2199. !             */
  2200. !             p=image->pixels+image->columns*(y_offset+height)+x_offset;
  2201. !             q=p+step*image->columns;
  2202. !             for (i=0; i < height; i++)
  2203. !             {
  2204. !               q-=image->columns;
  2205. !               p-=image->columns;
  2206. !               *q=(*p);
  2207. !             }
  2208. !             /*
  2209. !               Set old column to background color.
  2210. !             */
  2211. !             for (i=0; i < step; i++)
  2212. !             {
  2213. !               q-=image->columns;
  2214. !               q->red=background.red;
  2215. !               q->green=background.green;
  2216. !               q->blue=background.blue;
  2217. !             }
  2218. !             break;
  2219. !           }
  2220. !         }
  2221. !         continue;
  2222. !       }
  2223. !     /*
  2224. !       Fractional displacment.
  2225. !     */
  2226. !     step++;
  2227. !     last_pixel.red=background.red;
  2228. !     last_pixel.green=background.green;
  2229. !     last_pixel.blue=background.blue;
  2230. !     switch (direction)
  2231. X      {
  2232. !       case UP:
  2233. X        {
  2234. !         /*
  2235. !           Transfer pixels top-to-bottom.
  2236. !         */
  2237. !         p=image->pixels+image->columns*y_offset+x_offset;
  2238. !         q=p-step*image->columns;
  2239. !         for (i=0; i < height; i++)
  2240. !         {
  2241. !           red=DownShift(last_pixel.red*(UpShift(1)-fractional_step)+p->red*
  2242. !             fractional_step);
  2243. !           green=DownShift(last_pixel.green*(UpShift(1)-fractional_step)+
  2244. !             p->green*fractional_step);
  2245. !           blue=DownShift(last_pixel.blue*(UpShift(1)-fractional_step)+p->blue*
  2246. !             fractional_step);
  2247. !           last_pixel=(*p);
  2248. !           p+=image->columns;
  2249. !           q->red=range_limit[red];
  2250. !           q->green=range_limit[green];
  2251. !           q->blue=range_limit[blue];
  2252. !           q+=image->columns;
  2253. !         }
  2254. !         /*
  2255. !           Set old column to background color.
  2256. !         */
  2257. !         red=DownShift(last_pixel.red*(UpShift(1)-fractional_step)+
  2258. !           background.red*fractional_step);
  2259. !         green=DownShift(last_pixel.green*(UpShift(1)-fractional_step)+
  2260. !           background.green*fractional_step);
  2261. !         blue=DownShift(last_pixel.blue*(UpShift(1)-fractional_step)+
  2262. !           background.blue*fractional_step);
  2263. X          q->red=range_limit[red];
  2264. X          q->green=range_limit[green];
  2265. X          q->blue=range_limit[blue];
  2266. +         q+=image->columns;
  2267. +         for (i=0; i < step-1; i++)
  2268. +         {
  2269. +           q->red=background.red;
  2270. +           q->green=background.green;
  2271. +           q->blue=background.blue;
  2272. +           q+=image->columns;
  2273. +         }
  2274. +         break;
  2275. X        }
  2276. !       case DOWN:
  2277. X        {
  2278. !         /*
  2279. !           Transfer pixels bottom-to-top.
  2280. !         */
  2281. !         p=image->pixels+image->columns*(y_offset+height)+x_offset;
  2282. !         q=p+step*image->columns;
  2283. !         for (i=0; i < height; i++)
  2284. !         {
  2285. !           p-=image->columns;
  2286. !           red=DownShift(last_pixel.red*(UpShift(1)-fractional_step)+p->red*
  2287. !             fractional_step);
  2288. !           green=DownShift(last_pixel.green*(UpShift(1)-fractional_step)+
  2289. !             p->green*fractional_step);
  2290. !           blue=DownShift(last_pixel.blue*(UpShift(1)-fractional_step)+p->blue*
  2291. !             fractional_step);
  2292. !           last_pixel=(*p);
  2293. !           q-=image->columns;
  2294. !           q->red=range_limit[red];
  2295. !           q->green=range_limit[green];
  2296. !           q->blue=range_limit[blue];
  2297. !         }
  2298. !         /*
  2299. !           Set old column to background color.
  2300. !         */
  2301. !         red=DownShift(last_pixel.red*(UpShift(1)-fractional_step)+
  2302. !           background.red*fractional_step);
  2303. !         green=DownShift(last_pixel.green*(UpShift(1)-fractional_step)+
  2304. !           background.green*fractional_step);
  2305. !         blue=DownShift(last_pixel.blue*(UpShift(1)-fractional_step)+
  2306. !           background.blue*fractional_step);
  2307. !         q-=image->columns;
  2308. !         q->red=range_limit[red];
  2309. !         q->green=range_limit[green];
  2310. !         q->blue=range_limit[blue];
  2311. !         for (i=0; i < step-1; i++)
  2312. !         {
  2313. !           q-=image->columns;
  2314. !           q->red=background.red;
  2315. !           q->green=background.green;
  2316. !           q->blue=background.blue;
  2317. !         }
  2318. !         break;
  2319. X        }
  2320. X      }
  2321. X    }
  2322. X  }
  2323. X  
  2324. X  /*
  2325. ***************
  2326. *** 732,738 ****
  2327. X  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2328. X  %
  2329. X  %  Function RotateImage creates a new image that is a rotated copy of an
  2330. ! %  existing one.  It allocates the memory necessary for the new Image structure %  and returns a pointer to the new image.
  2331. X  %
  2332. X  %  Function RotateImage is based on the paper "A Fast Algorithm for General
  2333. X  %  Raster Rotatation" by Alan W. Paeth.  RotateImage is adapted from a similiar
  2334. --- 901,913 ----
  2335. X  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2336. X  %
  2337. X  %  Function RotateImage creates a new image that is a rotated copy of an
  2338. ! %  existing one.  Positive angles rotate counter-clockwise (right-hand rule),
  2339. ! %  while negative angles rotate clockwise.  Rotated images are usually larger
  2340. ! %  than the originals and have 'empty' triangular corners.  X axis.  Empty
  2341. ! %  triangles left over from shearing the image are filled with the color
  2342. ! %  defined by the pixel at location (0,0).  RotateImage allocates the memory
  2343. ! %  necessary for the new Image structure and returns a pointer to the new
  2344. ! %  image.
  2345. X  %
  2346. X  %  Function RotateImage is based on the paper "A Fast Algorithm for General
  2347. X  %  Raster Rotatation" by Alan W. Paeth.  RotateImage is adapted from a similiar
  2348. ***************
  2349. *** 768,778 ****
  2350. X  int
  2351. X    clip;
  2352. X  {
  2353. - #define DegreesToRadians(x) ((x)*3.14159265358979323846/180.0)
  2354. X    ColorPacket
  2355. !     background,
  2356. !     *rotated_pixels;
  2357. X  
  2358. X    double
  2359. X      x_shear,
  2360. --- 943,950 ----
  2361. X  int
  2362. X    clip;
  2363. X  {
  2364. X    ColorPacket
  2365. !     background;
  2366. X  
  2367. X    double
  2368. X      x_shear,
  2369. ***************
  2370. *** 779,803 ****
  2371. X      y_shear;
  2372. X  
  2373. X    Image
  2374. X      *rotated_image;
  2375. X  
  2376. !   register ColorPacket
  2377. !     *p;
  2378. X  
  2379. X    register int
  2380. !     i,
  2381. !     x,
  2382. !     y;
  2383. X  
  2384. !   register RunlengthPacket
  2385. !     *q;
  2386. X  
  2387. X    unsigned int
  2388. !     number_rows,
  2389. !     number_columns,
  2390. X      rotations,
  2391. !     x_offset,
  2392. !     y_offset,
  2393. X      y_width;
  2394. X  
  2395. X    /*
  2396. --- 951,975 ----
  2397. X      y_shear;
  2398. X  
  2399. X    Image
  2400. +     *clipped_image,
  2401. +     *integral_image,
  2402. X      *rotated_image;
  2403. X  
  2404. !   int
  2405. !     x_offset,
  2406. !     y_offset;
  2407. X  
  2408. X    register int
  2409. !     i;
  2410. X  
  2411. !   unsigned char
  2412. !     *range_limit,
  2413. !     *range_table;
  2414. X  
  2415. X    unsigned int
  2416. !     height,
  2417. X      rotations,
  2418. !     width,
  2419. X      y_width;
  2420. X  
  2421. X    /*
  2422. ***************
  2423. *** 817,1042 ****
  2424. X    */
  2425. X    x_shear=(-tan(DegreesToRadians(degrees)/2.0));
  2426. X    y_shear=sin(DegreesToRadians(degrees));
  2427. X    if ((rotations == 1) || (rotations == 3))
  2428. X      {
  2429. !       /*
  2430. !         Invert image size.
  2431. !       */
  2432. !       y_width=image->rows+
  2433. !         (int) ceil(fabs(x_shear)*(double) (image->columns-1));
  2434. !       number_columns=image->rows+2*
  2435. !         (int) ceil(fabs(x_shear)*(double) (image->columns-1));
  2436. !       number_rows=image->columns+
  2437. !         (int) ceil(fabs(y_shear)*(double) (y_width-1));
  2438. !       rotated_image=CopyImage(image,number_columns,number_rows,False);
  2439. !       if (rotated_image == (Image *) NULL)
  2440. !         {
  2441. !           Warning("unable to rotate image","memory allocation failed");
  2442. SHAR_EOF
  2443. true || echo 'restore of fix-01 failed'
  2444. fi
  2445. echo 'End of ImageMagick/patch01 part 2'
  2446. echo 'File fix-01 is continued in part 3'
  2447. echo 3 > _shar_seq_.tmp
  2448. exit 0
  2449. -- 
  2450. cristy@dupont.com
  2451.