]> granicus.if.org Git - imagemagick/commitdiff
...
authorCristy <urban-warrior@imagemagick.org>
Tue, 1 May 2018 00:20:46 +0000 (20:20 -0400)
committerCristy <urban-warrior@imagemagick.org>
Tue, 1 May 2018 00:20:46 +0000 (20:20 -0400)
coders/pcx.c

index b29b0e8dc2cc2b1e8aa3fc5770f3d6ceebc3719d..80008e691ff0ba232c296832e60a5658fe764aca 100644 (file)
@@ -371,28 +371,22 @@ static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception)
     if ((pcx_info.bits_per_pixel*pcx_info.planes) >= 64)
       ThrowPCXException(CorruptImageError,"ImproperImageHeader");
     one=1;
-    if ((pcx_info.bits_per_pixel >= 8) || (pcx_info.planes != 1))
+    if ((pcx_info.bits_per_pixel != 8) || (pcx_info.planes == 1))
+      if ((pcx_info.version == 3) || (pcx_info.version == 5) ||
+          ((pcx_info.bits_per_pixel*pcx_info.planes) == 1))
+        image->colors=(size_t) MagickMin(one << (1UL*
+          (pcx_info.bits_per_pixel*pcx_info.planes)),256UL);
+    if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)
+      ThrowPCXException(ResourceLimitError,"MemoryAllocationFailed");
+    if ((pcx_info.bits_per_pixel >= 8) && (pcx_info.planes != 1))
       image->storage_class=DirectClass;
-    else
-      {
-        if ((pcx_info.bits_per_pixel != 8) || (pcx_info.planes == 1))
-          if ((pcx_info.version == 3) || (pcx_info.version == 5) ||
-              ((pcx_info.bits_per_pixel*pcx_info.planes) == 1))
-            image->colors=(size_t) MagickMin(one << (1UL*
-              (pcx_info.bits_per_pixel*pcx_info.planes)),256UL);
-        if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)
-          ThrowPCXException(ResourceLimitError,"MemoryAllocationFailed");
-      }
-    if (image->colors <= 16)
-      {
-        p=pcx_colormap;
-        for (i=0; i < (ssize_t) image->colors; i++)
-        {
-          image->colormap[i].red=ScaleCharToQuantum(*p++);
-          image->colormap[i].green=ScaleCharToQuantum(*p++);
-          image->colormap[i].blue=ScaleCharToQuantum(*p++);
-        }
-      }
+    p=pcx_colormap;
+    for (i=0; i < (ssize_t) image->colors; i++)
+    {
+      image->colormap[i].red=ScaleCharToQuantum(*p++);
+      image->colormap[i].green=ScaleCharToQuantum(*p++);
+      image->colormap[i].blue=ScaleCharToQuantum(*p++);
+    }
     pcx_info.bytes_per_line=ReadBlobLSBShort(image);
     pcx_info.palette_info=ReadBlobLSBShort(image);
     pcx_info.horizontal_screensize=ReadBlobLSBShort(image);