]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/colormap.c
(no commit message)
[imagemagick] / MagickCore / colormap.c
index 36ddf6833e1aec0cef077945426f8bc712c456a2..418ba5e31308f0775f47e7c50682228e07479443 100644 (file)
@@ -136,13 +136,13 @@ MagickExport MagickBooleanType AcquireImageColormap(Image *image,
       image->filename);
   for (i=0; i < (ssize_t) image->colors; i++)
   {
-    size_t
+    double
       pixel;
 
-    pixel=(size_t) (i*(QuantumRange/MagickMax(colors-1,1)));
-    image->colormap[i].red=(Quantum) pixel;
-    image->colormap[i].green=(Quantum) pixel;
-    image->colormap[i].blue=(Quantum) pixel;
+    pixel=(double) (i*(QuantumRange/MagickMax(colors-1,1)));
+    image->colormap[i].red=pixel;
+    image->colormap[i].green=pixel;
+    image->colormap[i].blue=pixel;
     image->colormap[i].alpha=OpaqueAlpha;
   }
   return(SetImageStorageClass(image,PseudoClass,exception));
@@ -163,6 +163,9 @@ MagickExport MagickBooleanType AcquireImageColormap(Image *image,
 %  positions.  If you cycle the colormap a number of times you can produce
 %  a psychodelic effect.
 %
+%  WARNING: this assumes an images colormap is in a well know and defined
+%  order. Currently Imagemagick has no way of setting that order.
+%
 %  The format of the CycleColormapImage method is:
 %
 %      MagickBooleanType CycleColormapImage(Image *image,const ssize_t displace,
@@ -198,7 +201,7 @@ MagickExport MagickBooleanType CycleColormapImage(Image *image,
   status=MagickTrue;
   image_view=AcquireCacheView(image);
 #if defined(MAGICKCORE_OPENMP_SUPPORT) 
-  #pragma omp parallel for schedule(dynamic,4) shared(status)
+  #pragma omp parallel for schedule(static,4) shared(status)
 #endif
   for (y=0; y < (ssize_t) image->rows; y++)
   {
@@ -322,10 +325,10 @@ MagickExport MagickBooleanType SortColormapByIntensity(Image *image,
     Assign index values to colormap entries.
   */
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(status)
+  #pragma omp parallel for schedule(static,4) shared(status)
 #endif
   for (i=0; i < (ssize_t) image->colors; i++)
-    image->colormap[i].alpha=(Quantum) i;
+    image->colormap[i].alpha=(double) i;
   /*
     Sort image colormap by decreasing color popularity.
   */
@@ -335,7 +338,7 @@ MagickExport MagickBooleanType SortColormapByIntensity(Image *image,
     Update image colormap indexes to sorted colormap order.
   */
 #if defined(MAGICKCORE_OPENMP_SUPPORT)
-  #pragma omp parallel for schedule(dynamic,4) shared(status)
+  #pragma omp parallel for schedule(static,4) shared(status)
 #endif
   for (i=0; i < (ssize_t) image->colors; i++)
     pixels[(ssize_t) image->colormap[i].alpha]=(unsigned short) i;
@@ -356,7 +359,7 @@ MagickExport MagickBooleanType SortColormapByIntensity(Image *image,
     if (q == (Quantum *) NULL)
       {
         status=MagickFalse;
-        continue;
+        break;
       }
     for (x=0; x < (ssize_t) image->columns; x++)
     {