libtiff: * libtiff/tif_dirread.c: tolerate some cases where

https://github.com/libsdl-org/libtiff/commit/241c634c80f600b50f497448bb5801748751a2a0

From 241c634c80f600b50f497448bb5801748751a2a0 Mon Sep 17 00:00:00 2001
From: Lee Howard <[EMAIL REDACTED]>
Date: Wed, 15 Dec 2010 01:04:34 +0000
Subject: [PATCH]         * libtiff/tif_dirread.c: tolerate some cases where   
      FIELD_COLORMAP is missing        
 http://bugzilla.maptools.org/show_bug.cgi?id=2189

---
 ChangeLog             |  6 ++++++
 libtiff/tif_dirread.c | 12 +++++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d415da7f..3f443998 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-12-14  Lee Howard <faxguy@howardsilvan.com>
+
+	* libtiff/tif_dirread.c: tolerate some cases where
+	FIELD_COLORMAP is missing
+	http://bugzilla.maptools.org/show_bug.cgi?id=2189
+
 2010-12-14  Lee Howard <faxguy@howardsilvan.com>
 
 	* libtiff/tif_strip.c: use TIFFGetFieldDefaulted instead
diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c
index 32976dce..9e8b9c5c 100644
--- a/libtiff/tif_dirread.c
+++ b/libtiff/tif_dirread.c
@@ -1,4 +1,4 @@
-/* $Id: tif_dirread.c,v 1.92.2.13 2010-12-14 02:40:31 faxguy Exp $ */
+/* $Id: tif_dirread.c,v 1.92.2.14 2010-12-15 01:04:34 faxguy Exp $ */
 
 /*
  * Copyright (c) 1988-1997 Sam Leffler
@@ -643,8 +643,14 @@ TIFFReadDirectory(TIFF* tif)
 	 */
 	if (td->td_photometric == PHOTOMETRIC_PALETTE &&
 	    !TIFFFieldSet(tif, FIELD_COLORMAP)) {
-		MissingRequired(tif, "Colormap");
-		goto bad;
+		if ( tif->tif_dir.td_bitspersample>=8 && tif->tif_dir.td_samplesperpixel==3)
+			tif->tif_dir.td_photometric = PHOTOMETRIC_RGB;
+		else if (tif->tif_dir.td_bitspersample>=8)
+			tif->tif_dir.td_photometric = PHOTOMETRIC_MINISBLACK;
+		else {
+			MissingRequired(tif, "Colormap");
+			goto bad;
+		}
 	}
 	/*
 	 * OJPEG hack: