]> granicus.if.org Git - imagemagick/commitdiff
...
authorCristy <urban-warrior@imagemagick.org>
Thu, 4 Apr 2019 12:06:56 +0000 (08:06 -0400)
committerCristy <urban-warrior@imagemagick.org>
Thu, 4 Apr 2019 12:06:56 +0000 (08:06 -0400)
coders/xwd.c

index 4e8a0bc41447240f5cf2012b395a4cb9f11bc1c2..1605c145f6a50437739a7dc9a592aa7e5e34a143 100644 (file)
@@ -289,9 +289,9 @@ static Image *ReadXWDImage(const ImageInfo *image_info,ExceptionInfo *exception)
   ximage->red_mask=header.red_mask;
   ximage->green_mask=header.green_mask;
   ximage->blue_mask=header.blue_mask;
-  if ((ximage->width < 0) || (ximage->height < 0) || (ximage->depth < 0) ||    
-      (ximage->format < 0) || (ximage->byte_order < 0) || 
-      (ximage->bitmap_bit_order < 0) || (ximage->bitmap_pad < 0) || 
+  if ((ximage->width < 0) || (ximage->height < 0) || (ximage->depth < 0) ||
+      (ximage->format < 0) || (ximage->byte_order < 0) ||
+      (ximage->bitmap_bit_order < 0) || (ximage->bitmap_pad < 0) ||
       (ximage->bytes_per_line < 0))
     {
       ximage=(XImage *) RelinquishMagickMemory(ximage);
@@ -479,18 +479,18 @@ static Image *ReadXWDImage(const ImageInfo *image_info,ExceptionInfo *exception)
             for (x=0; x < (ssize_t) image->columns; x++)
             {
               pixel=XGetPixel(ximage,(int) x,(int) y);
-              index=(Quantum) ((pixel >> red_shift) & red_mask);
-              if (index < header.ncolors)
-                SetPixelRed(image,ScaleShortToQuantum(
-                  colors[(ssize_t) index].red),q);
-              index=(Quantum) ((pixel >> green_shift) & green_mask);
-              if (index < header.ncolors)
-                SetPixelGreen(image,ScaleShortToQuantum(
-                  colors[(ssize_t) index].green),q);
-              index=(Quantum) ((pixel >> blue_shift) & blue_mask);
-              if (index < header.ncolors)
-                SetPixelBlue(image,ScaleShortToQuantum(
-                  colors[(ssize_t) index].blue),q);
+              index=ConstrainColormapIndex(image,(pixel >> red_shift) &
+                red_mask,exception);
+              SetPixelRed(image,ScaleShortToQuantum(
+                colors[(ssize_t) index].red),q);
+              index=ConstrainColormapIndex(image,(pixel >> green_shift) &
+                green_mask,exception);
+              SetPixelGreen(image,ScaleShortToQuantum(
+                colors[(ssize_t) index].green),q);
+              index=ConstrainColormapIndex(image,(pixel >> blue_shift) &
+                blue_mask,exception);
+              SetPixelBlue(image,ScaleShortToQuantum(
+                colors[(ssize_t) index].blue),q);
               q+=GetPixelChannels(image);
             }
             if (SyncAuthenticPixels(image,exception) == MagickFalse)