home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / sources / patches / 45 < prev    next >
Encoding:
Text File  |  1992-11-17  |  11.1 KB  |  341 lines

  1. Newsgroups: alt.sources.patches
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!darwin.sura.net!udel!louie!eplrx7!eplrx7.es.dupont.com!cristy
  3. From: cristy@eplrx7.es.duPont.com (Cristy)
  4. Subject: ImageMagick 2.1 - patch 04
  5. Message-ID: <cristy.722025924@eplrx7.es.dupont.com>
  6. Summary: X11 image processing and display utilities
  7. Keywords: X11 image display image-processing JPEG TIFF GIF
  8. Organization: DuPont Engineering Physics Laboratory
  9. Date: Tue, 17 Nov 1992 18:45:24 GMT
  10. Lines: 329
  11.  
  12. To apply this patch:
  13.  
  14. cd to the top of the source tree (to the directory containing the
  15. "ImageMagick" directory) and do:
  16.  
  17.       patch -p -s < ThisFile
  18.  
  19. Patch will work silently unless an error occurs.  If you want to watch
  20. patch do its thing, leave out the "-s" argument to patch.
  21.  
  22. Finally, to rebuild after applying this patch, cd to the "ImageMagick"
  23. directory and type:
  24.  
  25.       make
  26.  
  27. The entire distribution is available as contrib/ImageMagick.tar.Z on
  28. export.lcs.mit.edu.
  29.  
  30. Brief notes on what this patch fixes:
  31.  
  32. o Using `-colorspace gray' with 'convert' correctly produces grayscale
  33.   images.
  34. o Images are sorted by intensity for shared colormapped visuals.  Some
  35.   intensity intervals are made "more popular".  This gives better
  36.   image results when sharing colors with other applications.
  37.  
  38. diff -c -r ImageMagick/README ImageMagick2.1.4/README
  39. *** ImageMagick/README    Sun Nov 15 20:40:54 1992
  40. --- ImageMagick2.1.4/README    Fri Nov 13 11:09:37 1992
  41. ***************
  42. *** 69,75 ****
  43.     mtv:image.mtv).
  44.   
  45.     ImageMagick requires GNU's Ghostscript software available via FTP as
  46. !   ftp.uu.net:packages/gnu/ghostscript-2.5.2.tar.Z to read the
  47.     Postscript format.  For ImageMagick to read Postscript files, `gs'
  48.     must be in your execution path and the `ppmraw' device must be
  49.     recognized.  Add it to your 'DEVICE_DEVS' define in your `Makefile'
  50. --- 69,75 ----
  51.     mtv:image.mtv).
  52.   
  53.     ImageMagick requires GNU's Ghostscript software available via FTP as
  54. !   ftp.uu.net:systems/gnu/ghostscript-2.5.2.tar.Z to read the
  55.     Postscript format.  For ImageMagick to read Postscript files, `gs'
  56.     must be in your execution path and the `ppmraw' device must be
  57.     recognized.  Add it to your 'DEVICE_DEVS' define in your `Makefile'
  58. diff -c -r ImageMagick/X.c ImageMagick2.1.4/X.c
  59. *** ImageMagick/X.c    Sun Nov 15 20:40:57 1992
  60. --- ImageMagick2.1.4/X.c    Tue Nov 17 10:20:04 1992
  61. ***************
  62. *** 3833,3849 ****
  63.   %
  64.   %
  65.   */
  66.   static int PopularityCompare(x,y)
  67.   const void
  68.     *x,
  69.     *y;
  70.   {
  71. !   PopularityPacket
  72.       *color_1,
  73.       *color_2;
  74.   
  75. !   color_1=(PopularityPacket *) x;
  76. !   color_2=(PopularityPacket *) y;
  77.     return((int) color_2->count-(int) color_1->count);
  78.   }
  79.   
  80. --- 3833,3863 ----
  81.   %
  82.   %
  83.   */
  84. + static int IntensityCompare(x,y)
  85. + const void
  86. +   *x,
  87. +   *y;
  88. + {
  89. +   DiversityPacket
  90. +     *color_1,
  91. +     *color_2;
  92. +  
  93. +   color_1=(DiversityPacket *) x;
  94. +   color_2=(DiversityPacket *) y;
  95. +   return((int) Intensity(*color_2)-(int) Intensity(*color_1));
  96. + }
  97.   static int PopularityCompare(x,y)
  98.   const void
  99.     *x,
  100.     *y;
  101.   {
  102. !   DiversityPacket
  103.       *color_1,
  104.       *color_2;
  105.   
  106. !   color_1=(DiversityPacket *) x;
  107. !   color_2=(DiversityPacket *) y;
  108.     return((int) color_2->count-(int) color_1->count);
  109.   }
  110.   
  111. ***************
  112. *** 4023,4030 ****
  113.           colormap_type=PrivateColormap;
  114.         if (colormap_type == SharedColormap)
  115.           {
  116. !           PopularityPacket
  117. !             *popularity;
  118.   
  119.             register RunlengthPacket
  120.               *q;
  121. --- 4037,4044 ----
  122.           colormap_type=PrivateColormap;
  123.         if (colormap_type == SharedColormap)
  124.           {
  125. !           DiversityPacket
  126. !             *diversity;
  127.   
  128.             register RunlengthPacket
  129.               *q;
  130. ***************
  131. *** 4033,4066 ****
  132.               index;
  133.   
  134.             /*
  135. !             Define Standard colormap for shared GrayScale or PseudoColor visual.
  136.             */
  137. !           popularity=(PopularityPacket *)
  138. !             malloc(image->colors*sizeof(PopularityPacket));
  139. !           if (popularity == (PopularityPacket *) NULL)
  140.               Error("unable to create colormap","memory allocation failed");
  141.             for (i=0; i < image->colors; i++)
  142.             {
  143. !             popularity[i].count=0;
  144. !             popularity[i].index=(unsigned short) i;
  145.             }
  146.             q=image->pixels;
  147.             for (i=0; i < image->packets; i++)
  148.             {
  149. !             popularity[q->index].count+=(q->length+1);
  150.               q++;
  151.             }
  152. -           (void) qsort((void *) popularity,(int) image->colors,
  153. -             sizeof(PopularityPacket),PopularityCompare);
  154.             /*
  155. !             Allocate colors in order of decreasing popularity.
  156.             */
  157.             p=colors;
  158.             color.flags=DoRed | DoGreen | DoBlue;
  159.             if (visual_info->class == PseudoColor)
  160.               for (i=0; i < image->colors; i++)
  161.               {
  162. !               index=popularity[i].index;
  163.                 color.red=(unsigned short) (image->colormap[index].red << 8);
  164.                 color.green=(unsigned short) (image->colormap[index].green << 8);
  165.                 color.blue=(unsigned short) (image->colormap[index].blue << 8);
  166. --- 4047,4091 ----
  167.               index;
  168.   
  169.             /*
  170. !             Define Standard colormap for shared GrayScale or PseudoColor visual:
  171.             */
  172. !           diversity=(DiversityPacket *)
  173. !             malloc(image->colors*sizeof(DiversityPacket));
  174. !           if (diversity == (DiversityPacket *) NULL)
  175.               Error("unable to create colormap","memory allocation failed");
  176.             for (i=0; i < image->colors; i++)
  177.             {
  178. !             diversity[i].red=image->colormap[i].red;
  179. !             diversity[i].green=image->colormap[i].green;
  180. !             diversity[i].blue=image->colormap[i].blue;
  181. !             diversity[i].index=(unsigned short) i;
  182. !             diversity[i].count=0;
  183.             }
  184.             q=image->pixels;
  185.             for (i=0; i < image->packets; i++)
  186.             {
  187. !             diversity[q->index].count+=(q->length+1);
  188.               q++;
  189.             }
  190.             /*
  191. !             Sort colors by decreasing intensity.
  192.             */
  193. +           (void) qsort((void *) diversity,(int) image->colors,
  194. +             sizeof(DiversityPacket),IntensityCompare);
  195. +           for (i=0; i < image->colors; i+=Max(image->colors >> 4,2))
  196. +             diversity[i].count<<=4;  /* increase this colors popularity */
  197. +           diversity[image->colors-1].count<<=4;
  198. +           (void) qsort((void *) diversity,(int) image->colors,
  199. +             sizeof(DiversityPacket),PopularityCompare);
  200. +           /*
  201. +             Allocate colors.
  202. +           */
  203.             p=colors;
  204.             color.flags=DoRed | DoGreen | DoBlue;
  205.             if (visual_info->class == PseudoColor)
  206.               for (i=0; i < image->colors; i++)
  207.               {
  208. !               index=diversity[i].index;
  209.                 color.red=(unsigned short) (image->colormap[index].red << 8);
  210.                 color.green=(unsigned short) (image->colormap[index].green << 8);
  211.                 color.blue=(unsigned short) (image->colormap[index].blue << 8);
  212. ***************
  213. *** 4073,4079 ****
  214.             else
  215.               for (i=0; i < image->colors; i++)
  216.               {
  217. !               index=popularity[i].index;
  218.                 gray_value=Intensity(image->colormap[index]);
  219.                 color.red=(unsigned short) (gray_value << 8);
  220.                 color.green=(unsigned short) (gray_value << 8);
  221. --- 4098,4104 ----
  222.             else
  223.               for (i=0; i < image->colors; i++)
  224.               {
  225. !               index=diversity[i].index;
  226.                 gray_value=Intensity(image->colormap[index]);
  227.                 color.red=(unsigned short) (gray_value << 8);
  228.                 color.green=(unsigned short) (gray_value << 8);
  229. ***************
  230. *** 4109,4115 ****
  231.                 if (visual_info->class == PseudoColor)
  232.                   for (; i < image->colors; i++)
  233.                   {
  234. !                   index=popularity[i].index;
  235.                     color.red=(unsigned short) (image->colormap[index].red << 8);
  236.                     color.green=(unsigned short)
  237.                       (image->colormap[index].green << 8);
  238. --- 4134,4140 ----
  239.                 if (visual_info->class == PseudoColor)
  240.                   for (; i < image->colors; i++)
  241.                   {
  242. !                   index=diversity[i].index;
  243.                     color.red=(unsigned short) (image->colormap[index].red << 8);
  244.                     color.green=(unsigned short)
  245.                       (image->colormap[index].green << 8);
  246. ***************
  247. *** 4124,4130 ****
  248.                 else
  249.                   for (; i < image->colors; i++)
  250.                   {
  251. !                   index=popularity[i].index;
  252.                     gray_value=Intensity(image->colormap[index]);
  253.                     color.red=(unsigned short) (gray_value << 8);
  254.                     color.green=(unsigned short) (gray_value << 8);
  255. --- 4149,4155 ----
  256.                 else
  257.                   for (; i < image->colors; i++)
  258.                   {
  259. !                   index=diversity[i].index;
  260.                     gray_value=Intensity(image->colormap[index]);
  261.                     color.red=(unsigned short) (gray_value << 8);
  262.                     color.green=(unsigned short) (gray_value << 8);
  263. ***************
  264. *** 4148,4154 ****
  265.                   }
  266.                 (void) free((void *) server_colors);
  267.               }
  268. !           (void) free((void *) popularity);
  269.             break;
  270.           }
  271.         /*
  272. --- 4173,4179 ----
  273.                   }
  274.                 (void) free((void *) server_colors);
  275.               }
  276. !           (void) free((void *) diversity);
  277.             break;
  278.           }
  279.         /*
  280. diff -c -r ImageMagick/X.h ImageMagick2.1.4/X.h
  281. *** ImageMagick/X.h    Sun Nov 15 20:40:57 1992
  282. --- ImageMagick2.1.4/X.h    Mon Nov 16 17:09:39 1992
  283. ***************
  284. *** 33,46 ****
  285.   /*
  286.     Typedef declarations.
  287.   */
  288. ! typedef struct _PopularityPacket
  289.   {
  290. !   unsigned long
  291. !     count;
  292.   
  293.     unsigned short
  294.       index;
  295. ! } PopularityPacket;
  296.   
  297.   typedef struct _XAnnotateInfo
  298.   {
  299. --- 33,51 ----
  300.   /*
  301.     Typedef declarations.
  302.   */
  303. ! typedef struct _DiversityPacket
  304.   {
  305. !   unsigned char
  306. !     red,
  307. !     green,
  308. !     blue;
  309.   
  310.     unsigned short
  311.       index;
  312. !   unsigned long
  313. !     count;
  314. ! } DiversityPacket;
  315.   
  316.   typedef struct _XAnnotateInfo
  317.   {
  318. Only in ImageMagick: display.c.orig
  319. Common subdirectories: ImageMagick/images and ImageMagick2.1.4/images
  320. Common subdirectories: ImageMagick/scenes and ImageMagick2.1.4/scenes
  321. Common subdirectories: ImageMagick/utilities and ImageMagick2.1.4/utilities
  322. Common subdirectories: ImageMagick/xtp and ImageMagick2.1.4/xtp
  323. diff -c -r ImageMagick/utilities/convert.c ImageMagick2.1.4/utilities/convert.c
  324. *** ImageMagick/utilities/convert.c    Sun Nov 15 20:41:23 1992
  325. --- ImageMagick2.1.4/utilities/convert.c    Mon Nov 16 17:57:34 1992
  326. ***************
  327. *** 477,482 ****
  328. --- 477,484 ----
  329.             image->colors=NumberColors(image);
  330.           total_colors=image->colors;
  331.         }
  332. +     if (colorspace == GRAYColorspace)
  333. +       QuantizeImage(image,256,8,dither,GRAYColorspace,True);
  334.       if (number_colors > 0)
  335.         if ((image->class == DirectClass) || (image->colors > number_colors))
  336.           QuantizeImage(image,number_colors,tree_depth,dither,colorspace,True);
  337. -- 
  338. cristy@dupont.com
  339.