]> granicus.if.org Git - imagemagick/commitdiff
Return pixel if black color is the same as white color
authorCristy <urban-warrior@imagemagick.org>
Sun, 10 Jul 2016 15:28:16 +0000 (11:28 -0400)
committerCristy <urban-warrior@imagemagick.org>
Sun, 10 Jul 2016 15:28:16 +0000 (11:28 -0400)
MagickCore/enhance.c

index b8ca74377b4d4e1345431f89f9786086d329ceb7..315cb24e45b05ca83cf3d01634a9721c826a4558 100644 (file)
@@ -2373,7 +2373,9 @@ static inline double LevelPixel(const double black_point,
     level_pixel,
     scale;
 
-  scale=(white_point != black_point) ? 1.0/(white_point-black_point) : 1.0;
+  if (fabs(white_point-black_point) < MagickEpsilon)
+    return(pixel);
+  scale=1.0/(white_point-black_point);
   level_pixel=QuantumRange*gamma_pow(scale*((double) pixel-black_point),
     1.0/gamma);
   return(level_pixel);
@@ -2424,7 +2426,7 @@ MagickExport MagickBooleanType LevelImage(Image *image,const double black_point,
       if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
         image->colormap[i].alpha=(double) ClampToQuantum(LevelPixel(black_point,
           white_point,gamma,image->colormap[i].alpha));
-      }
+    }
   /*
     Level image.
   */