]> granicus.if.org Git - imagemagick/commitdiff
https://github.com/ImageMagick/ImageMagick/issues/1713
authorCristy <urban-warrior@imagemagick.org>
Thu, 3 Oct 2019 22:24:06 +0000 (18:24 -0400)
committerCristy <urban-warrior@imagemagick.org>
Thu, 3 Oct 2019 22:24:06 +0000 (18:24 -0400)
coders/hdr.c

index 6989242194518b014cfd7761fd1f83c15c4965d7..d09f652ba815c90dbce274d8da687fe73bcdb885 100644 (file)
@@ -785,9 +785,13 @@ static MagickBooleanType WriteHDRImage(const ImageInfo *image_info,Image *image,
             exponent;
 
           gamma=frexp(gamma,&exponent)*256.0/gamma;
-          pixel[0]=(unsigned char) (gamma*QuantumScale*GetPixelRed(image,p));
-          pixel[1]=(unsigned char) (gamma*QuantumScale*GetPixelGreen(image,p));
-          pixel[2]=(unsigned char) (gamma*QuantumScale*GetPixelBlue(image,p));
+          if (GetPixelRed(image,p) > 0)
+            pixel[0]=(unsigned char) (gamma*QuantumScale*GetPixelRed(image,p));
+          if (GetPixelGreen(image,p) > 0)
+            pixel[1]=(unsigned char) (gamma*QuantumScale*
+              GetPixelGreen(image,p));
+          if (GetPixelBlue(image,p) > 0)
+            pixel[2]=(unsigned char) (gamma*QuantumScale*GetPixelBlue(image,p));
           pixel[3]=(unsigned char) (exponent+128);
         }
       if ((image->columns >= 8) && (image->columns <= 0x7ffff))