GraphicsMagick: coders/tga.c Interleaving support was implemente...

GraphicsMagick Commits <[email protected]> Sun, 25 Feb 2024 06:32:26 -0600
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.13995.1708864388.16032.graphicsmagick-commit@lists.sourceforge.net>
changeset d90d7ea8174d in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=d90d7ea8174d
summary: coders/tga.c Interleaving support was implemented completely wrongly. Fixed.

diffstat:

 ChangeLog    |   3 +++
 coders/tga.c |  22 +++++++---------------
 2 files changed, 10 insertions(+), 15 deletions(-)

diffs (45 lines):

diff -r b3bedefac39e -r d90d7ea8174d ChangeLog
--- a/ChangeLog	Sun Feb 25 09:35:22 2024 +0100
+++ b/ChangeLog	Sun Feb 25 13:31:09 2024 +0100
@@ -5,6 +5,9 @@
 
 	* coders/tga.c: Emit warning to logs when orientation is 
 	not supported.
+	FIED: Need to research what case was expected to be
+	tested here. This test case can never be true and so it
+	is commented out for the moment.
 
 2024-02-24  Bob Friesenhahn  <[email protected]>
 
diff -r b3bedefac39e -r d90d7ea8174d coders/tga.c
--- a/coders/tga.c	Sun Feb 25 09:35:22 2024 +0100
+++ b/coders/tga.c	Sun Feb 25 13:31:09 2024 +0100
@@ -835,21 +835,13 @@
                 ThrowReaderException(CorruptImageError,UnableToReadImageData,image);
               *q++=pixel;
             }
-          /*
-            FIXME: Need to research what case was expected to be
-            tested here.  This test case can never be true and so it
-            is commented out for the moment.
-            J.Fojtik - Looks like some form of interlacing, untested.
-            this testcase could be true based on image data.
-
-            if (((unsigned char) (tga_info.attributes & 0xc0) >> 6) == 4)
-            offset+=4;
-            else
-          */
-          if (((unsigned char) (tga_info.attributes & 0xc0) >> 6) == 2)
-            offset+=2;		/* J.Fojtik - please note that this also never triggers! */
-          else
-            offset++;
+          switch((unsigned char) (tga_info.attributes & 0xc0) >> 6)
+            {				/* http://www.paulbourke.net/dataformats/tga/ */
+            case 3:			/* 11 = reserved. - process without interleaving. */
+            case 0: offset++; break;	/* 00 = non-interleaved. */
+            case 1: offset+=2;break;	/* 01 = two-way (even/odd) interleaving. */
+            case 2: offset+=4;break;	/* 10 = four way interleaving. */
+            }
           if (offset >= image->rows)
             {
               base++;