GraphicsMagick: coders/tga.c Block alpha channel depending on va...

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.3266.1665614755.1567.graphicsmagick-commit@lists.sourceforge.net>
changeset 0b468264d2e6 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=0b468264d2e6
summary: coders/tga.c Block alpha channel depending on value "AttributesType".

diffstat:

 ChangeLog    |   5 +++++
 coders/tga.c |  20 ++++++++++++++------
 2 files changed, 19 insertions(+), 6 deletions(-)

diffs (48 lines):

diff -r f398d85d6c1a -r 0b468264d2e6 ChangeLog
--- a/ChangeLog	Wed Oct 12 11:02:52 2022 +0200
+++ b/ChangeLog	Thu Oct 13 00:45:23 2022 +0200
@@ -1,3 +1,8 @@
+2022-10-13    Fojtik Jaroslav  <[email protected]>
+
+        * coders/tga.c Block alpha channel depending on value "AttributesType".
+
+
 2022-10-12    Fojtik Jaroslav  <[email protected]>
 
         * coders/tga.c New attributes "comment", "creator", "software", "TGA:file.JobName" 
diff -r f398d85d6c1a -r 0b468264d2e6 coders/tga.c
--- a/coders/tga.c	Wed Oct 12 11:02:52 2022 +0200
+++ b/coders/tga.c	Thu Oct 13 00:45:23 2022 +0200
@@ -1,6 +1,6 @@
 /*
 % Copyright (C) 2003 - 2022 GraphicsMagick Group
-% Copyright (C) 2002 ImageMagick Studio
+% Copyright (C) 2002 - 2022 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
 % This program is covered by multiple licenses, which are described in
@@ -515,11 +515,19 @@
       /*
         Initialize image structure.
       */
-      alpha_bits=(tga_info.attributes & 0x0FU);
-      image->matte=((alpha_bits > 0) || (tga_info.bits_per_pixel == 32));
-      image->columns=tga_info.width;
-      image->rows=tga_info.height;
-      if ((tga_info.image_type != TGAColormap) && (tga_info.image_type != TGARLEColormap))
+      alpha_bits = (tga_info.attributes & 0x0FU);
+      image->matte = ((alpha_bits > 0) || (tga_info.bits_per_pixel == 32));
+      if(image->matte)
+      {
+        if(tga_footer.ExtensionOffset>3 && tga_devel.ExtensionSize >= 495) /* Valid footer and extended area. */
+        {					/* Please note that alpha channel could contain a garbage. */
+          if(tga_devel.AttributesType<3 || tga_devel.AttributesType>4)
+              image->matte = MagickFalse;	/* The attribute instruct NOT to use alpha channel. */
+        }
+      }
+      image->columns = tga_info.width;
+      image->rows = tga_info.height;
+      if((tga_info.image_type != TGAColormap) && (tga_info.image_type != TGARLEColormap))
         {
           /*
             TrueColor Quantum Depth
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.