From: Arnar Mar Hrafnkelsson <addi@cpan.org>
Date: Tue, 9 Jul 2002 14:52:30 +0000 (+0000)
Subject: Fixed tiff handling of images all contained in a single strip
X-Git-Tag: Imager-0.48^2~360
X-Git-Url: http://git.imager.perl.org/imager.git/commitdiff_plain/1b0554d1cd190162f1d3c0733110b8ab68c95d12

Fixed tiff handling of images all contained in a single strip
(rowsperstrip = -1) and added a hack for images missing the rowsperstrip
tag.
---

diff --git a/Changes b/Changes
index 2da9fc99..5bf32334 100644
--- a/Changes
+++ b/Changes
@@ -672,7 +672,10 @@ Revision history for Perl extension Imager.
         - mc_web_map was storing colors with an alpha of 0
         - update the URLs for libpng and zlib
 				- Fixed empty string handling for tt font driver.
-
+				- Fixed tiff handling of images all contained in a 
+					single strip (rowsperstrip = -1) and added a hack
+					for images missing the rowsperstrip tag.
+					
 =================================================================
 
         For latest versions check the Imager-devel pages:
diff --git a/tiff.c b/tiff.c
index 317c599e..27334378 100644
--- a/tiff.c
+++ b/tiff.c
@@ -260,9 +260,13 @@ static i_img *read_one_tiff(TIFF *tif) {
       }
     } else {
       uint32 rowsperstrip, row;
-      TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
-      mm_log((1, "i_readtiff_wiol: rowsperstrip=%d\n", rowsperstrip));
-      
+      int rc = TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
+      mm_log((1, "i_readtiff_wiol: rowsperstrip=%d rc = %d\n", rowsperstrip, rc));
+  
+			if (rc != 1 || rowsperstrip==-1) {
+				rowsperstrip = height;
+			}
+    
       raster = (uint32*)_TIFFmalloc(width * rowsperstrip * sizeof (uint32));
       if (!raster) {
         i_img_destroy(im);