[gimp] plug-ins: fix #1790 Artifacts when opening tif images ...



commit 94de89febf24ae93034e861c1777cc8592b0c4b4
Author: Jacob Boerema <jgboerema gmail com>
Date:   Wed Jun 8 13:22:46 2022 -0400

    plug-ins: fix #1790 Artifacts when opening tif images ...
    
    generated by matlabs blocproc function
    
    Based on the suggested solution by Massimo, we should not compute the
    remaining pixels per line but only at the end of the whole block, be it
    tile or scanline.
    
    I have not been able to find bw or palette examples that use load_separate
    instead of load_contiguous, so that case is not tested. But, it also
    doesn't make much sense to have planar when you have just one plane.

 plug-ins/file-tiff/file-tiff-load.c | 87 +++++++++++++++----------------------
 1 file changed, 36 insertions(+), 51 deletions(-)
---
diff --git a/plug-ins/file-tiff/file-tiff-load.c b/plug-ins/file-tiff/file-tiff-load.c
index 94debd3055..f434c0833c 100644
--- a/plug-ins/file-tiff/file-tiff-load.c
+++ b/plug-ins/file-tiff/file-tiff-load.c
@@ -2518,26 +2518,21 @@ convert_bit2byte (const guchar *src,
                   gint          width,
                   gint          height)
 {
-  gint y;
+  gint64 x = width * height;
 
-  for (y = 0; y < height; y++)
+  while (x >= 8)
     {
-      gint x = width;
-
-      while (x >= 8)
-        {
-          memcpy (dest, bit2byte + *src * 8, 8);
-          dest += 8;
-          x -= 8;
-          src++;
-        }
+      memcpy (dest, bit2byte + *src * 8, 8);
+      dest += 8;
+      x -= 8;
+      src++;
+    }
 
-      if (x > 0)
-        {
-          memcpy (dest, bit2byte + *src * 8, x);
-          dest += x;
-          src++;
-        }
+  if (x > 0)
+    {
+      memcpy (dest, bit2byte + *src * 8, x);
+      dest += x;
+      src++;
     }
 }
 
@@ -2547,26 +2542,21 @@ convert_2bit2byte (const guchar *src,
                    gint          width,
                    gint          height)
 {
-  gint y;
+  gint64 x = width * height;
 
-  for (y = 0; y < height; y++)
+  while (x >= 4)
     {
-      gint x = width;
-
-      while (x >= 4)
-        {
-          memcpy (dest, _2bit2byte + *src * 4, 4);
-          dest += 4;
-          x -= 4;
-          src++;
-        }
+      memcpy (dest, _2bit2byte + *src * 4, 4);
+      dest += 4;
+      x -= 4;
+      src++;
+    }
 
-      if (x > 0)
-        {
-          memcpy (dest, _2bit2byte + *src * 4, x);
-          dest += x;
-          src++;
-        }
+  if (x > 0)
+    {
+      memcpy (dest, _2bit2byte + *src * 4, x);
+      dest += x;
+      src++;
     }
 }
 
@@ -2576,26 +2566,21 @@ convert_4bit2byte (const guchar *src,
                    gint          width,
                    gint          height)
 {
-  gint y;
+  gint64 x = width * height;
 
-  for (y = 0; y < height; y++)
+  while (x >= 2)
     {
-      gint x = width;
-
-      while (x >= 2)
-        {
-          memcpy (dest, _4bit2byte + *src * 2, 2);
-          dest += 2;
-          x -= 2;
-          src++;
-        }
+      memcpy (dest, _4bit2byte + *src * 2, 2);
+      dest += 2;
+      x -= 2;
+      src++;
+    }
 
-      if (x > 0)
-        {
-          memcpy (dest, _4bit2byte + *src * 2, x);
-          dest += x;
-          src++;
-        }
+  if (x > 0)
+    {
+      memcpy (dest, _4bit2byte + *src * 2, x);
+      dest += x;
+      src++;
     }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]