summaryrefslogtreecommitdiff
path: root/libtiff/tif_aux.c
diff options
context:
space:
mode:
authorAndrey Kiselev <dron@ak4719.spb.edu>2004-11-10 21:08:11 +0000
committerAndrey Kiselev <dron@ak4719.spb.edu>2004-11-10 21:08:11 +0000
commit89cf48606e002b5be8454438ce4439e2897e2ff7 (patch)
tree09a6f4a12f6f04286add3a2cb1f962e0f1b351cb /libtiff/tif_aux.c
parent361d0c4e33ce7b0658c2af502f78e83570dcc23c (diff)
downloadlibtiff-git-89cf48606e002b5be8454438ce4439e2897e2ff7.tar.gz
Set the appropriate ReferenceBlackWhite array for YCbCr image which lacks that
tag (noted by Hans Petter Selasky).
Diffstat (limited to 'libtiff/tif_aux.c')
-rw-r--r--libtiff/tif_aux.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/libtiff/tif_aux.c b/libtiff/tif_aux.c
index ffc7946c..1260edff 100644
--- a/libtiff/tif_aux.c
+++ b/libtiff/tif_aux.c
@@ -1,4 +1,4 @@
-/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_aux.c,v 1.7 2004-10-02 13:29:41 dron Exp $ */
+/* $Id: tif_aux.c,v 1.8 2004-11-10 21:08:11 dron Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@@ -81,9 +81,24 @@ TIFFDefaultRefBlackWhite(TIFFDirectory* td)
if (!(td->td_refblackwhite = (float *)_TIFFmalloc(6*sizeof (float))))
return 0;
- for (i = 0; i < 3; i++) {
- td->td_refblackwhite[2*i+0] = 0;
- td->td_refblackwhite[2*i+1] = (float)((1L<<td->td_bitspersample)-1L);
+ if (td->td_photometric == PHOTOMETRIC_YCBCR) {
+ /*
+ * YCbCr (Class Y) images must have the ReferenceBlackWhite
+ * tag set. Fix the broken images, which lacks that tag.
+ */
+ td->td_refblackwhite[0] = 0.0F;
+ td->td_refblackwhite[1] = td->td_refblackwhite[3] =
+ td->td_refblackwhite[5] = 255.0F;
+ td->td_refblackwhite[2] = td->td_refblackwhite[4] = 128.0F;
+ } else {
+ /*
+ * Assume RGB (Class R)
+ */
+ for (i = 0; i < 3; i++) {
+ td->td_refblackwhite[2*i+0] = 0;
+ td->td_refblackwhite[2*i+1] =
+ (float)((1L<<td->td_bitspersample)-1L);
+ }
}
return 1;
}
@@ -246,3 +261,5 @@ TIFFGetFieldDefaulted(TIFF* tif, ttag_t tag, ...)
va_end(ap);
return (ok);
}
+
+/* vim: set ts=8 sts=8 sw=8 noet: */