From 42ffebf834fc4360b0d0f0dd7a4afb9228b28ac9 Mon Sep 17 00:00:00 2001 From: Andrey Kiselev Date: Thu, 21 Jul 2005 13:57:00 +0000 Subject: [PATCH] Do not check the PlanarConfiguration field in the TIFFWriteCheck() function in case of single band images (as per TIFF spec). --- libtiff/tif_write.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/libtiff/tif_write.c b/libtiff/tif_write.c index 6e06acb4..0dfe9d21 100644 --- a/libtiff/tif_write.c +++ b/libtiff/tif_write.c @@ -1,4 +1,4 @@ -/* $Id: tif_write.c,v 1.17 2004-11-05 11:37:29 dron Exp $ */ +/* $Id: tif_write.c,v 1.18 2005-07-21 13:57:00 dron Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -516,11 +516,21 @@ TIFFWriteCheck(TIFF* tif, int tiles, const char* module) tif->tif_name); return (0); } - if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) { - TIFFError(module, - "%s: Must set \"PlanarConfiguration\" before writing data", - tif->tif_name); - return (0); + if (tif->tif_dir.td_samplesperpixel == 1) { + /* + * Planarconfiguration is irrelevant in case of single band + * images and need not be included. We will set it anyway, + * because this field is used in other parts of library even + * in the single band case. + */ + tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG; + } else { + if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) { + TIFFError(module, + "%s: Must set \"PlanarConfiguration\" before writing data", + tif->tif_name); + return (0); + } } if (tif->tif_dir.td_stripoffset == NULL && !TIFFSetupStrips(tif)) { tif->tif_dir.td_nstrips = 0;