home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sources / misc / 4228 < prev    next >
Encoding:
Text File  |  1992-12-27  |  75.6 KB  |  2,492 lines

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