]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sun, 20 Oct 2013 18:54:02 +0000 (18:54 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sun, 20 Oct 2013 18:54:02 +0000 (18:54 +0000)
MagickCore/attribute.c

index af0eecad30c1c92f468c2417e42ab50d00c05a5f..7d06448ad8ea94c9584a47bb3e2d9a1e9d29d2d8 100644 (file)
@@ -271,6 +271,9 @@ MagickExport RectangleInfo GetImageBoundingBox(const Image *image,
 */
 MagickExport size_t GetImageDepth(const Image *image,ExceptionInfo *exception)
 {
+#define IsPixelAtDepth(pixel,range) ((ClampToQuantum(pixel) == \
+  ScaleAnyToQuantum(ScaleQuantumToAny(pixel,range),range)) ? MagickTrue : MagickFalse)
+
   CacheView
     *image_view;
 
@@ -317,28 +320,19 @@ MagickExport size_t GetImageDepth(const Image *image,ExceptionInfo *exception)
 
         while (current_depth[id] < MAGICKCORE_QUANTUM_DEPTH)
         {
-          MagickStatusType
-            state;
-
           QuantumAny
             range;
 
-          state=0;
           range=GetQuantumRange(current_depth[id]);
           if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
-            state!=ClampToQuantum(image->colormap[i].red) !=
-              ScaleAnyToQuantum(ScaleQuantumToAny(ClampToQuantum(
-              image->colormap[i].red),range),range);
+            if (IsPixelAtDepth(image->colormap[i].red,range) != MagickFalse)
+              break;
           if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
-            state!=ClampToQuantum(image->colormap[i].green) !=
-              ScaleAnyToQuantum(ScaleQuantumToAny(ClampToQuantum(
-              image->colormap[i].green),range),range);
+            if (IsPixelAtDepth(image->colormap[i].green,range) != MagickFalse)
+              break;
           if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
-            state!=ClampToQuantum(image->colormap[i].blue) !=
-              ScaleAnyToQuantum(ScaleQuantumToAny(ClampToQuantum(
-              image->colormap[i].blue),range),range);
-          if (state == 0)
-            break;
+            if (IsPixelAtDepth(image->colormap[i].blue,range) != MagickFalse)
+              break;
           current_depth[id]++;
         }
       }