From f2558c842675c0941f8ab3031ae3afad7ec9c277 Mon Sep 17 00:00:00 2001 From: Andrey Kiselev Date: Sat, 22 Jun 2002 10:32:56 +0000 Subject: [PATCH] Added workaround for some software that may crash when last strip of image contains fewer number of scanlines than specified by the `/Height' variable. See http://bugzilla.remotesensing.org/show_bug.cgi?id=164 for explanation. --- tools/tiff2ps.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tools/tiff2ps.c b/tools/tiff2ps.c index 04c9a108..b7170c1e 100644 --- a/tools/tiff2ps.c +++ b/tools/tiff2ps.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/tools/tiff2ps.c,v 1.8 2002-06-21 10:24:40 dron Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/tools/tiff2ps.c,v 1.9 2002-06-22 10:32:56 dron Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -825,7 +825,21 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h) fputs(" <<\n", fd); fputs(" /ImageType 1\n", fd); fprintf(fd, " /Width %lu\n", (unsigned long) tile_width); - fprintf(fd, " /Height %lu\n", (unsigned long) tile_height); + /* + * Workaround for some software that may crash when last strip + * of image contains fewer number of scanlines than specified + * by the `/Height' variable. So for stripped images with multiple + * strips we will set `/Height' as `im_h', because one is + * recalculated for each strip - including the (smaller) final strip. + * For tiled images and images with only one strip `/Height' will + * contain number of scanlines in tile (or image height in case of + * one-stripped image). + */ + if (TIFFIsTiled(tif) || tf_numberstrips == 1) + fprintf(fd, " /Height %lu\n", (unsigned long) tile_height); + else + fprintf(fd, " /Height im_h\n"); + if (planarconfiguration == PLANARCONFIG_SEPARATE && samplesperpixel > 1) fputs(" /MultipleDataSources true\n", fd); fprintf(fd, " /ImageMatrix [ %lu 0 0 %ld %s %s ]\n",