]> granicus.if.org Git - imagemagick/commitdiff
If image does not have an alpha channel, set the total error to opaque
authorCristy <urban-warrior@imagemagick.org>
Tue, 24 Nov 2015 02:13:27 +0000 (21:13 -0500)
committerCristy <urban-warrior@imagemagick.org>
Tue, 24 Nov 2015 02:13:27 +0000 (21:13 -0500)
MagickCore/quantize.c

index a7a99cd43c19ad72d7cd6eac8f5f11acb16b0db5..8da62f8cffc44088762c0ff2c21b5c24519756a6 100644 (file)
@@ -890,8 +890,11 @@ static MagickBooleanType ClassifyImageColors(CubeInfo *cube_info,
       node_info->total_color.green+=count*QuantumScale*ClampPixel(pixel.green);
       node_info->total_color.blue+=count*QuantumScale*ClampPixel(pixel.blue);
       if (cube_info->associate_alpha != MagickFalse)
-        node_info->total_color.alpha+=count*QuantumScale*ClampPixel(
-          pixel.alpha);
+        node_info->total_color.alpha+=count*QuantumScale*
+          ClampPixel(pixel.alpha);
+      else
+        node_info->total_color.alpha+=count*QuantumScale*
+          ClampPixel(OpaqueAlpha);
       p+=count*GetPixelChannels(image);
     }
     if (cube_info->colors > cube_info->maximum_colors)
@@ -994,8 +997,11 @@ static MagickBooleanType ClassifyImageColors(CubeInfo *cube_info,
       node_info->total_color.green+=count*QuantumScale*ClampPixel(pixel.green);
       node_info->total_color.blue+=count*QuantumScale*ClampPixel(pixel.blue);
       if (cube_info->associate_alpha != MagickFalse)
-        node_info->total_color.alpha+=count*QuantumScale*ClampPixel(
-          pixel.alpha);
+        node_info->total_color.alpha+=count*QuantumScale*
+          ClampPixel(pixel.alpha);
+      else
+        node_info->total_color.alpha+=count*QuantumScale*
+          ClampPixel(OpaqueAlpha);
       p+=count*GetPixelChannels(image);
     }
     proceed=SetImageProgress(image,ClassifyImageTag,(MagickOffsetType) y,