From bd0025579f671a5b50b73cc8d60396b47bf72515 Mon Sep 17 00:00:00 2001 From: James Zern Date: Sat, 15 Dec 2012 18:43:36 -0800 Subject: [PATCH] cwebp/tiff: use the first image directory tiffdec does not support and warns about multi-directory images. previously, the code would read all the directories and thus attempt to use the last rather than the first as the message suggests. Change-Id: I3a10c778e6e924a3df75b41c26a9c03afb761044 --- examples/tiffdec.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/tiffdec.c b/examples/tiffdec.c index c93be49a..2d2e0c20 100644 --- a/examples/tiffdec.c +++ b/examples/tiffdec.c @@ -26,18 +26,17 @@ int ReadTIFF(const char* const filename, uint32 width, height; uint32* raster; int ok = 0; - int dircount = 1; + tdir_t dircount; if (tif == NULL) { fprintf(stderr, "Error! Cannot open TIFF file '%s'\n", filename); return 0; } - while (TIFFReadDirectory(tif)) ++dircount; - + dircount = TIFFNumberOfDirectories(tif); if (dircount > 1) { fprintf(stderr, "Warning: multi-directory TIFF files are not supported.\n" - "Only the first will be used, %d will be ignored.\n", + "Only the first will be used, %hu will be ignored.\n", dircount - 1); }