From 321103e327369fcf0ac5d6617e771989a695c516 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Sun, 25 Sep 2016 15:34:18 +0800 Subject: tiff: Estimate uncompressed strip sizes if missing. --- source/fitz/load-tiff.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source/fitz') diff --git a/source/fitz/load-tiff.c b/source/fitz/load-tiff.c index 2ead2e28..2f90aa5e 100644 --- a/source/fitz/load-tiff.c +++ b/source/fitz/load-tiff.c @@ -862,6 +862,18 @@ fz_decode_tiff_samples(fz_context *ctx, struct tiff *tiff) if (tiff->rowsperstrip > tiff->imagelength) tiff->rowsperstrip = tiff->imagelength; + /* some creators don't write byte counts for uncompressed images */ + if (tiff->compression == 1) + { + if (!tiff->stripbytecounts) + { + tiff->stripbytecountslen = (tiff->imagelength + tiff->rowsperstrip - 1) / tiff->rowsperstrip; + tiff->stripbytecounts = fz_malloc_array(ctx, tiff->stripbytecountslen, sizeof(unsigned)); + for (i = 0; i < tiff->stripbytecountslen; i++) + tiff->stripbytecounts[i] = tiff->rowsperstrip * tiff->stride; + } + } + if (tiff->rowsperstrip && tiff->stripoffsets && tiff->stripbytecounts) fz_decode_tiff_strips(ctx, tiff); else -- cgit v1.2.3