]> granicus.if.org Git - imagemagick/commitdiff
Fixed setting the colorspace and image type of monochrome images.
authorDirk Lemstra <dirk@lemstra.org>
Thu, 13 Jun 2019 07:53:28 +0000 (09:53 +0200)
committerDirk Lemstra <dirk@lemstra.org>
Thu, 13 Jun 2019 07:54:24 +0000 (09:54 +0200)
coders/tga.c

index 87c6f0ac811f4fe8a1e9f303eae96352590cbb38..427f96f4714feee20843f51f055de9e1494b9298 100644 (file)
@@ -239,9 +239,13 @@ static Image *ReadTGAImage(const ImageInfo *image_info,ExceptionInfo *exception)
   */
   image->columns=tga_info.width;
   image->rows=tga_info.height;
-  alpha_bits=(tga_info.attributes & 0x0FU);
-  image->alpha_trait=(alpha_bits > 0) || (tga_info.bits_per_pixel == 32) ||
-    (tga_info.colormap_size == 32) ?  BlendPixelTrait : UndefinedPixelTrait;
+  if ((tga_info.image_type != TGAMonochrome) &&
+      (tga_info.image_type != TGARLEMonochrome))
+    {
+      alpha_bits=(tga_info.attributes & 0x0FU);
+      image->alpha_trait=(alpha_bits > 0) || (tga_info.bits_per_pixel == 32) ||
+        (tga_info.colormap_size == 32) ?  BlendPixelTrait : UndefinedPixelTrait;
+    }
   if ((tga_info.image_type != TGAColormap) &&
       (tga_info.image_type != TGARLEColormap))
     image->depth=(size_t) ((tga_info.bits_per_pixel <= 8) ? 8 :
@@ -250,10 +254,14 @@ static Image *ReadTGAImage(const ImageInfo *image_info,ExceptionInfo *exception)
     image->depth=(size_t) ((tga_info.colormap_size <= 8) ? 8 :
       (tga_info.colormap_size <= 16) ? 5 : 8);
   if ((tga_info.image_type == TGAColormap) ||
-      (tga_info.image_type == TGAMonochrome) ||
-      (tga_info.image_type == TGARLEColormap) ||
-      (tga_info.image_type == TGARLEMonochrome))
+      (tga_info.image_type == TGARLEColormap))
     image->storage_class=PseudoClass;
+  if ((tga_info.image_type == TGAMonochrome) ||
+      (tga_info.image_type == TGARLEMonochrome))
+    {
+      image->type=GrayscaleType;
+      image->colorspace=GRAYColorspace;
+    }
   image->compression=NoCompression;
   if ((tga_info.image_type == TGARLEColormap) ||
       (tga_info.image_type == TGARLEMonochrome) ||