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

  1. Newsgroups: comp.sources.misc
  2. Path: sparky!kent
  3. From: cristy@eplrx7.es.duPont.com (John Cristy)
  4. Subject: v34i088: imagemagick - X11 image processing and display v2.2, Patch02
  5. Message-ID: <1992Dec27.232211.1662@sparky.imd.sterling.com>
  6. Followup-To: comp.sources.d
  7. Summary: X11 image processing and display utilities
  8. X-Md4-Signature: 302b92355d1dae52f6f0df17254be26e
  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 23:22:11 GMT
  14. Approved: kent@sparky.imd.sterling.com
  15.  
  16. Submitted-by: cristy@eplrx7.es.duPont.com (John Cristy)
  17. Posting-number: Volume 34, Issue 88
  18. Archive-name: imagemagick/patch02
  19. Environment: UNIX, VMS, X11, SGI, DEC, Cray, Sun, Vax
  20. Patch-To: imagemagick: Volume 34, Issue 28-54
  21.  
  22.                     ImageMagick 2.2 Patch #2
  23.  
  24. To apply this patch:
  25.  
  26. cd to the top of the source tree (to the directory containing the
  27. "ImageMagick" subdirectories) and do:
  28.  
  29.   patch -p < ThisFile
  30.  
  31. Prereq: ImageMagick 2.2.1 (posted from comp.sources.misc, Volume 34,
  32. Issue 28 + Patch 1).
  33.  
  34. Alternatively get the entire distribution as contrib/ImageMagick.tar.Z
  35. on export.lcs.mit.edu.  I will post this patch to comp.sources.misc in
  36. a few days.
  37. ------------------
  38. #! /bin/sh
  39. # This is a shell archive.  Remove anything before this line, then feed it
  40. # into a shell via "sh file" or similar.  To overwrite existing files,
  41. # type "sh file -c".
  42. # Contents:  fix-02
  43. # Wrapped by kent@sparky on Sun Dec 27 17:17:45 1992
  44. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  45. echo If this archive is complete, you will see the following message:
  46. echo '          "shar: End of archive."'
  47. if test -f 'fix-02' -a "${1}" != "-c" ; then 
  48.   echo shar: Will not clobber existing file \"'fix-02'\"
  49. else
  50.   echo shar: Extracting \"'fix-02'\" \(11479 characters\)
  51.   sed "s/^X//" >'fix-02' <<'END_OF_FILE'
  52. Xdiff -r -c ImageMagick/ChangeLog ImageMagick2.2.2/ChangeLog
  53. X*** ImageMagick/ChangeLog    Mon Dec 21 14:12:35 1992
  54. X--- ImageMagick2.2.2/ChangeLog    Tue Dec 22 16:07:20 1992
  55. X***************
  56. X*** 1,3 ****
  57. X--- 1,14 ----
  58. X+ ImageMagick 2.2.2
  59. X+ 
  60. X+   o Dithering did not work properly on the Cray (due to right shift problem).
  61. X+ 
  62. X+   o In most cases dithering requires 1/2 as much memory as previously.
  63. X+ 
  64. X+   o Dithering was sped up by ~15%.
  65. X+ 
  66. X+   o Occasionally the quantization error was reported incorrectly.
  67. X+ 
  68. X+ 
  69. X  ImageMagick 2.2.1
  70. X  
  71. X    o The number of colors reported with the -verbose option was on
  72. Xdiff -r -c ImageMagick/X.c ImageMagick2.2.2/X.c
  73. X*** ImageMagick/X.c    Mon Dec 21 14:12:34 1992
  74. X--- ImageMagick2.2.2/X.c    Tue Dec 22 16:06:18 1992
  75. X***************
  76. X*** 1283,1291 ****
  77. X    /*
  78. X      Initialize annotated image.
  79. X    */
  80. X!   if (image->packets != (image->columns*image->rows))
  81. X!     if (!UncompressImage(image))
  82. X!       return(False);
  83. X    /*
  84. X      Initialize annotated pixmap.
  85. X    */
  86. X--- 1283,1290 ----
  87. X    /*
  88. X      Initialize annotated image.
  89. X    */
  90. X!   if (!UncompressImage(image))
  91. X!     return(False);
  92. X    /*
  93. X      Initialize annotated pixmap.
  94. X    */
  95. Xdiff -r -c ImageMagick/display.h ImageMagick2.2.2/display.h
  96. X*** ImageMagick/display.h    Tue Dec 22 16:23:13 1992
  97. X--- ImageMagick2.2.2/display.h    Tue Dec 22 16:23:32 1992
  98. X***************
  99. X*** 51,55 ****
  100. X  */
  101. X  #ifndef lint
  102. X  static char 
  103. X!   Version[]="@(#)ImageMagick 2.2.1 92/12/10 cristy@dupont.com";
  104. X  #endif
  105. X--- 51,55 ----
  106. X  */
  107. X  #ifndef lint
  108. X  static char 
  109. X!   Version[]="@(#)ImageMagick 2.2.2 92/12/22 cristy@dupont.com";
  110. X  #endif
  111. Xdiff -r -c ImageMagick/image.c ImageMagick2.2.2/image.c
  112. X*** ImageMagick/image.c    Fri Dec 18 17:07:28 1992
  113. X--- ImageMagick2.2.2/image.c    Tue Dec 22 16:06:19 1992
  114. X***************
  115. X*** 731,739 ****
  116. X    /*
  117. X      Image must be uncompressed.
  118. X    */
  119. X!   if (image->packets != (image->columns*image->rows))
  120. X!     if (!UncompressImage(image))
  121. X!       return;
  122. X    if (!image->alpha)
  123. X      {
  124. X        /*
  125. X--- 731,738 ----
  126. X    /*
  127. X      Image must be uncompressed.
  128. X    */
  129. X!   if (!UncompressImage(image))
  130. X!     return;
  131. X    if (!image->alpha)
  132. X      {
  133. X        /*
  134. X***************
  135. X*** 5190,5195 ****
  136. X--- 5189,5196 ----
  137. X    RunlengthPacket
  138. X      *uncompressed_pixels;
  139. X  
  140. X+   if (image->packets == (image->columns*image->rows))
  141. X+     return(True);
  142. X    /*
  143. X      Uncompress runlength-encoded packets.
  144. X    */
  145. XCommon subdirectories: ImageMagick/images and ImageMagick2.2.2/images
  146. Xdiff -r -c ImageMagick/quantize.c ImageMagick2.2.2/quantize.c
  147. X*** ImageMagick/quantize.c    Mon Dec 21 11:12:00 1992
  148. X--- ImageMagick2.2.2/quantize.c    Tue Dec 22 16:06:18 1992
  149. X***************
  150. X*** 745,753 ****
  151. X        blue;
  152. X    } ScaledColorPacket;
  153. X  
  154. X-   Image
  155. X-     *dithered_image;
  156. X- 
  157. X    int
  158. X      *cache,
  159. X      odd_scanline;
  160. X--- 745,750 ----
  161. X***************
  162. X*** 769,786 ****
  163. X      *cs,
  164. X      *ns;
  165. X  
  166. X    register unsigned int
  167. X      id;
  168. X  
  169. X-   register unsigned short
  170. X-     index;
  171. X- 
  172. X    ScaledColorPacket
  173. X      *scanline;
  174. X  
  175. X    unsigned char
  176. X!     *range_limit,
  177. X!     *range_table;
  178. X  
  179. X    unsigned int
  180. X      i,
  181. X--- 766,785 ----
  182. X      *cs,
  183. X      *ns;
  184. X  
  185. X+   register unsigned char
  186. X+     *range_limit;
  187. X+ 
  188. X    register unsigned int
  189. X      id;
  190. X  
  191. X    ScaledColorPacket
  192. X      *scanline;
  193. X  
  194. X    unsigned char
  195. X!     blue,
  196. X!     green,
  197. X!     *range_table,
  198. X!     red;
  199. X  
  200. X    unsigned int
  201. X      i,
  202. X***************
  203. X*** 787,803 ****
  204. X      x,
  205. X      y;
  206. X  
  207. X    /*
  208. X!     Initialize dithered image attributes.
  209. X    */
  210. X!   image->orphan=True;
  211. X!   dithered_image=CopyImage(image,image->columns,image->rows,False);
  212. X!   image->orphan=False;
  213. X!   if (dithered_image == (Image *) NULL)
  214. X!     {
  215. X!       Warning("unable to dither image","memory allocation failed");
  216. X!       return(True);
  217. X!     }
  218. X    /*
  219. X      Allocate the cache & scanline buffers to keep track of quantization error.
  220. X    */
  221. X--- 786,800 ----
  222. X      x,
  223. X      y;
  224. X  
  225. X+   unsigned short
  226. X+     index;
  227. X+ 
  228. X    /*
  229. X!     Image must be uncompressed.
  230. X    */
  231. X!   if (!UncompressImage(image))
  232. X!     return(True);
  233. X!   image->compression=NoCompression;
  234. X    /*
  235. X      Allocate the cache & scanline buffers to keep track of quantization error.
  236. X    */
  237. X***************
  238. X*** 827,846 ****
  239. X      Preload first scanline.
  240. X    */
  241. X    p=image->pixels;
  242. X-   image->runlength=p->length+1;
  243. X    cs=scanline+1;
  244. X    for (i=0; i < image->columns; i++)
  245. X    {
  246. X-     if (image->runlength > 0)
  247. X-       image->runlength--;
  248. X-     else
  249. X-       {
  250. X-         p++;
  251. X-         image->runlength=p->length;
  252. X-       }
  253. X      cs->red=p->red;
  254. X      cs->green=p->green;
  255. X      cs->blue=p->blue;
  256. X      cs++;
  257. X    }
  258. X    odd_scanline=False;
  259. X--- 824,836 ----
  260. X      Preload first scanline.
  261. X    */
  262. X    p=image->pixels;
  263. X    cs=scanline+1;
  264. X    for (i=0; i < image->columns; i++)
  265. X    {
  266. X      cs->red=p->red;
  267. X      cs->green=p->green;
  268. X      cs->blue=p->blue;
  269. X+     p++;
  270. X      cs++;
  271. X    }
  272. X    odd_scanline=False;
  273. X***************
  274. X*** 856,871 ****
  275. X            ns+=(image->columns+2);
  276. X          for (i=0; i < image->columns; i++)
  277. X          {
  278. X-           if (image->runlength > 0)
  279. X-             image->runlength--;
  280. X-           else
  281. X-             {
  282. X-               p++;
  283. X-               image->runlength=p->length;
  284. X-             }
  285. X            ns->red=p->red;
  286. X            ns->green=p->green;
  287. X            ns->blue=p->blue;
  288. X            ns++;
  289. X          }
  290. X        }
  291. X--- 846,855 ----
  292. X            ns+=(image->columns+2);
  293. X          for (i=0; i < image->columns; i++)
  294. X          {
  295. X            ns->red=p->red;
  296. X            ns->green=p->green;
  297. X            ns->blue=p->blue;
  298. X+           p++;
  299. X            ns++;
  300. X          }
  301. X        }
  302. X***************
  303. X*** 874,880 ****
  304. X          /*
  305. X            Distribute error left-to-right for even scanlines.
  306. X          */
  307. X!         q=dithered_image->pixels+image->columns*y;
  308. X          cs=scanline+1;
  309. X          ns=scanline+(image->columns+2)+1;
  310. X          step=1;
  311. X--- 858,864 ----
  312. X          /*
  313. X            Distribute error left-to-right for even scanlines.
  314. X          */
  315. X!         q=image->pixels+image->columns*y;
  316. X          cs=scanline+1;
  317. X          ns=scanline+(image->columns+2)+1;
  318. X          step=1;
  319. X***************
  320. X*** 884,890 ****
  321. X          /*
  322. X            Distribute error right-to-left for odd scanlines.
  323. X          */
  324. X!         q=dithered_image->pixels+image->columns*y+(image->columns-1);
  325. X          cs=scanline+(image->columns+2)+(image->columns-1)+1;
  326. X          ns=scanline+(image->columns-1)+1;
  327. X          step=(-1);
  328. X--- 868,874 ----
  329. X          /*
  330. X            Distribute error right-to-left for odd scanlines.
  331. X          */
  332. X!         q=image->pixels+image->columns*y+(image->columns-1);
  333. X          cs=scanline+(image->columns+2)+(image->columns-1)+1;
  334. X          ns=scanline+(image->columns-1)+1;
  335. X          step=(-1);
  336. X***************
  337. X*** 891,900 ****
  338. X        }
  339. X      for (x=0; x < image->columns; x++)
  340. X      {
  341. X!       q->red=range_limit[cs->red];
  342. X!       q->green=range_limit[cs->green];
  343. X!       q->blue=range_limit[cs->blue];
  344. X!       i=(q->red >> 2) << 12 | (q->green >> 2) << 6 | q->blue >> 2;
  345. X        if (cache[i] < 0)
  346. X          {
  347. X            /*
  348. X--- 875,884 ----
  349. X        }
  350. X      for (x=0; x < image->columns; x++)
  351. X      {
  352. X!       red=range_limit[cs->red];
  353. X!       green=range_limit[cs->green];
  354. X!       blue=range_limit[cs->blue];
  355. X!       i=(red >> 2) << 12 | (green >> 2) << 6 | blue >> 2;
  356. X        if (cache[i] < 0)
  357. X          {
  358. X            /*
  359. X***************
  360. X*** 903,911 ****
  361. X            node=cube.root;
  362. X            for ( ; ; )
  363. X            {
  364. X!             id=(q->red > node->mid_red ? 1 : 0) |
  365. X!               (q->green > node->mid_green ? 1 : 0) << 1 |
  366. X!               (q->blue > node->mid_blue ? 1 : 0) << 2;
  367. X              if ((node->children & (1 << id)) == 0)
  368. X                break;
  369. X              node=node->child[id];
  370. X--- 887,895 ----
  371. X            node=cube.root;
  372. X            for ( ; ; )
  373. X            {
  374. X!             id=(red > node->mid_red ? 1 : 0) |
  375. X!               (green > node->mid_green ? 1 : 0) << 1 |
  376. X!               (blue > node->mid_blue ? 1 : 0) << 2;
  377. X              if ((node->children & (1 << id)) == 0)
  378. X                break;
  379. X              node=node->child[id];
  380. X***************
  381. X*** 913,931 ****
  382. X            /*
  383. X              Find closest color among siblings and their children.
  384. X            */
  385. X!           cube.color.red=q->red;
  386. X!           cube.color.green=q->green;
  387. X!           cube.color.blue=q->blue;
  388. X            cube.distance=(~0);
  389. X            ClosestColor(node->parent);
  390. X            cache[i]=cube.color_number;
  391. X          }
  392. X        index=(unsigned short) cache[i];
  393. X!       red_error=(int) q->red-(int) cube.colormap[index].red;
  394. X!       green_error=(int) q->green-(int) cube.colormap[index].green;
  395. X!       blue_error=(int) q->blue-(int) cube.colormap[index].blue;
  396. X        q->index=index;
  397. X-       q->length=0;
  398. X        q+=step;
  399. X        /*
  400. X          Propagate the error in these proportions:
  401. X--- 897,914 ----
  402. X            /*
  403. X              Find closest color among siblings and their children.
  404. X            */
  405. X!           cube.color.red=red;
  406. X!           cube.color.green=green;
  407. X!           cube.color.blue=blue;
  408. X            cube.distance=(~0);
  409. X            ClosestColor(node->parent);
  410. X            cache[i]=cube.color_number;
  411. X          }
  412. X        index=(unsigned short) cache[i];
  413. X!       red_error=(int) red-(int) cube.colormap[index].red;
  414. X!       green_error=(int) green-(int) cube.colormap[index].green;
  415. X!       blue_error=(int) blue-(int) cube.colormap[index].blue;
  416. X        q->index=index;
  417. X        q+=step;
  418. X        /*
  419. X          Propagate the error in these proportions:
  420. X***************
  421. X*** 933,953 ****
  422. X            3/16  5/16  1/16
  423. X        */
  424. X        cs+=step;
  425. X!       cs->red+=red_error-((red_error*9+8) >> 4);
  426. X!       cs->green+=green_error-((green_error*9+8) >> 4);
  427. X!       cs->blue+=blue_error-((blue_error*9+8) >> 4);
  428. X        ns-=step;
  429. X!       ns->red+=(red_error*3+8) >> 4;
  430. X!       ns->green+=(green_error*3+8) >> 4;
  431. X!       ns->blue+=(blue_error*3+8) >> 4;
  432. X        ns+=step;
  433. X!       ns->red+=(red_error*5+8) >> 4;
  434. X!       ns->green+=(green_error*5+8) >> 4;
  435. X!       ns->blue+=(blue_error*5+8) >> 4;
  436. X        ns+=step;
  437. X!       ns->red+=(red_error+8) >> 4;
  438. X!       ns->green+=(green_error+8) >> 4;
  439. X!       ns->blue+=(blue_error+8) >> 4;
  440. X      }
  441. X      odd_scanline=!odd_scanline;
  442. X    }
  443. X--- 916,936 ----
  444. X            3/16  5/16  1/16
  445. X        */
  446. X        cs+=step;
  447. X!       cs->red+=(red_error-((red_error*9+8)/16));
  448. X!       cs->green+=(green_error-((green_error*9+8)/16));
  449. X!       cs->blue+=(blue_error-((blue_error*9+8)/16));
  450. X        ns-=step;
  451. X!       ns->red+=(red_error*3+8)/16;
  452. X!       ns->green+=(green_error*3+8)/16;
  453. X!       ns->blue+=(blue_error*3+8)/16;
  454. X        ns+=step;
  455. X!       ns->red+=(red_error*5+8)/16;
  456. X!       ns->green+=(green_error*5+8)/16;
  457. X!       ns->blue+=(blue_error*5+8)/16;
  458. X        ns+=step;
  459. X!       ns->red+=(red_error+8)/16;
  460. X!       ns->green+=(green_error+8)/16;
  461. X!       ns->blue+=(blue_error+8)/16;
  462. X      }
  463. X      odd_scanline=!odd_scanline;
  464. X    }
  465. X***************
  466. X*** 957,968 ****
  467. X    (void) free((char *) scanline);
  468. X    (void) free((char *) range_table);
  469. X    (void) free((char *) cache);
  470. X-   (void) free((char *) image->pixels);
  471. X-   image->packets=dithered_image->packets;
  472. X-   image->pixels=dithered_image->pixels;
  473. X-   dithered_image->file=(FILE *) NULL;
  474. X-   dithered_image->pixels=(RunlengthPacket *) NULL;
  475. X-   DestroyImage(dithered_image);
  476. X    return(False);
  477. X  }
  478. X  
  479. X--- 940,945 ----
  480. XCommon subdirectories: ImageMagick/scenes and ImageMagick2.2.2/scenes
  481. XCommon subdirectories: ImageMagick/utilities and ImageMagick2.2.2/utilities
  482. XCommon subdirectories: ImageMagick/xtp and ImageMagick2.2.2/xtp
  483. X-- 
  484. Xcristy@dupont.com
  485. X
  486. END_OF_FILE
  487.   if test 11479 -ne `wc -c <'fix-02'`; then
  488.     echo shar: \"'fix-02'\" unpacked with wrong size!
  489.   fi
  490.   # end of 'fix-02'
  491. fi
  492. echo shar: End of archive.
  493. exit 0
  494. exit 0 # Just in case...
  495.