Make WhitePoint tag custom.

This commit is contained in:
Andrey Kiselev 2005-12-23 16:28:15 +00:00
parent ec9a11dfd7
commit 90b21237df
4 changed files with 21 additions and 48 deletions

View File

@ -1,4 +1,4 @@
/* $Id: tif_aux.c,v 1.15 2005-12-21 12:23:13 joris Exp $ */
/* $Id: tif_aux.c,v 1.16 2005-12-23 16:28:15 dron Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@ -145,7 +145,7 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap)
{
TIFFPredictorState* sp = (TIFFPredictorState*) tif->tif_data;
*va_arg(ap, uint16*) = (uint16) sp->predictor;
return (1);
return 1;
}
case TIFFTAG_DOTRANGE:
*va_arg(ap, uint16 *) = 0;
@ -183,8 +183,8 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap)
/* defaults are from CCIR Recommendation 601-1 */
float ycbcrcoeffs[] = { 0.299f, 0.587f, 0.114f };
*va_arg(ap, float **) = ycbcrcoeffs;
return 1;
}
return (1);
case TIFFTAG_YCBCRSUBSAMPLING:
*va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[0];
*va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[1];
@ -193,21 +193,17 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap)
*va_arg(ap, uint16 *) = td->td_ycbcrpositioning;
return (1);
case TIFFTAG_WHITEPOINT:
if (!td->td_whitepoint) {
td->td_whitepoint = (float *)
_TIFFmalloc(2 * sizeof (float));
if (!td->td_whitepoint)
return (0);
/* TIFF 6.0 specification says that it is no default
{
static float whitepoint[2];
/* TIFF 6.0 specification tells that it is no default
value for the WhitePoint, but AdobePhotoshop TIFF
Technical Note tells that it should be CIE D50. */
td->td_whitepoint[0] =
D50_X0 / (D50_X0 + D50_Y0 + D50_Z0);
td->td_whitepoint[1] =
D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0);
whitepoint[0] = D50_X0 / (D50_X0 + D50_Y0 + D50_Z0);
whitepoint[1] = D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0);
*va_arg(ap, float **) = whitepoint;
return 1;
}
*va_arg(ap, float **) = td->td_whitepoint;
return (1);
case TIFFTAG_TRANSFERFUNCTION:
if (!td->td_transferfunction[0] &&
!TIFFDefaultTransferFunction(td)) {
@ -223,9 +219,9 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap)
case TIFFTAG_REFERENCEBLACKWHITE:
{
int i;
float ycbcr_refblackwhite[] =
static float ycbcr_refblackwhite[] =
{ 0.0F, 255.0F, 128.0F, 255.0F, 128.0F, 255.0F };
float rgb_refblackwhite[6];
static float rgb_refblackwhite[6];
for (i = 0; i < 3; i++) {
rgb_refblackwhite[2 * i + 0] = 0.0F;
@ -246,9 +242,8 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap)
*/
*va_arg(ap, float **) = rgb_refblackwhite;
}
return 1;
}
return 1;
}
return 0;
}

View File

@ -1,4 +1,4 @@
/* $Id: tif_dir.c,v 1.64 2005-12-23 01:18:59 joris Exp $ */
/* $Id: tif_dir.c,v 1.65 2005-12-23 16:28:15 dron Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -364,9 +364,6 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
td->td_ycbcrsubsampling[0] = (uint16) va_arg(ap, int);
td->td_ycbcrsubsampling[1] = (uint16) va_arg(ap, int);
break;
case TIFFTAG_WHITEPOINT:
_TIFFsetFloatArray(&td->td_whitepoint, va_arg(ap, float*), 2);
break;
case TIFFTAG_TRANSFERFUNCTION:
v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1;
for (i = 0; i < v; i++)
@ -799,9 +796,6 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
*va_arg(ap, uint16*) = td->td_ycbcrsubsampling[0];
*va_arg(ap, uint16*) = td->td_ycbcrsubsampling[1];
break;
case TIFFTAG_WHITEPOINT:
*va_arg(ap, float**) = td->td_whitepoint;
break;
case TIFFTAG_TRANSFERFUNCTION:
*va_arg(ap, uint16**) = td->td_transferfunction[0];
if (td->td_samplesperpixel - td->td_extrasamples > 1) {
@ -983,7 +977,6 @@ TIFFFreeDirectory(TIFF* tif)
CleanupField(td_sampleinfo);
CleanupField(td_subifd);
CleanupField(td_inknames);
CleanupField(td_whitepoint);
CleanupField(td_transferfunction[0]);
CleanupField(td_transferfunction[1]);
CleanupField(td_transferfunction[2]);

View File

@ -1,4 +1,4 @@
/* $Id: tif_dir.h,v 1.25 2005-12-23 15:10:45 dron Exp $ */
/* $Id: tif_dir.h,v 1.26 2005-12-23 16:28:15 dron Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -73,7 +73,6 @@ typedef struct {
uint16 td_ycbcrsubsampling[2];
uint16 td_ycbcrpositioning;
/* Colorimetry parameters */
float* td_whitepoint;
uint16* td_transferfunction[3];
/* CMYK parameters */
uint16 td_inkset;
@ -114,26 +113,17 @@ typedef struct {
#define FIELD_PHOTOMETRIC 8
#define FIELD_THRESHHOLDING 9
#define FIELD_FILLORDER 10
/* unused - was FIELD_DOCUMENTNAME 11 */
/* unused - was FIELD_IMAGEDESCRIPTION 12 */
/* unused - was FIELD_MAKE 13 */
/* unused - was FIELD_MODEL 14 */
#define FIELD_ORIENTATION 15
#define FIELD_SAMPLESPERPIXEL 16
#define FIELD_ROWSPERSTRIP 17
#define FIELD_MINSAMPLEVALUE 18
#define FIELD_MAXSAMPLEVALUE 19
#define FIELD_PLANARCONFIG 20
/* unused - was FIELD_PAGENAME 21 */
#define FIELD_RESOLUTIONUNIT 22
#define FIELD_PAGENUMBER 23
#define FIELD_STRIPBYTECOUNTS 24
#define FIELD_STRIPOFFSETS 25
#define FIELD_COLORMAP 26
/* unused - was FIELD_ARTIST 27 */
/* unused - was FIELD_DATETIME 28 */
/* unused - was FIELD_HOSTCOMPUTER 29 */
/* unused - was FIELD_SOFTWARE 30 */
#define FIELD_EXTRASAMPLES 31
#define FIELD_SAMPLEFORMAT 32
#define FIELD_SMINSAMPLEVALUE 33
@ -141,17 +131,12 @@ typedef struct {
#define FIELD_IMAGEDEPTH 35
#define FIELD_TILEDEPTH 36
#define FIELD_HALFTONEHINTS 37
/* unused - was FIELD_YCBCRCOEFFICIENTS 38 */
#define FIELD_YCBCRSUBSAMPLING 39
#define FIELD_YCBCRPOSITIONING 40
/* unused - was FIELD_REFBLACKWHITE 41 */
#define FIELD_WHITEPOINT 42
/* unused - was FIELD_PRIMARYCHROMAS 43 */
#define FIELD_TRANSFERFUNCTION 44
#define FIELD_INKSET 45
#define FIELD_INKNAMES 46
#define FIELD_DOTRANGE 47
/* unused - was FIELD_TARGETPRINTER 48 */
#define FIELD_SUBIFD 49
#define FIELD_NUMBEROFINKS 50
#define FIELD_STONITS 54
@ -288,7 +273,7 @@ static const TIFFFieldInfo tiffFieldInfo[] = {
1, 0, "Artist" },
{ TIFFTAG_HOSTCOMPUTER, -1,-1, TIFF_ASCII, FIELD_CUSTOM,
1, 0, "HostComputer" },
{ TIFFTAG_WHITEPOINT, 2, 2, TIFF_RATIONAL, FIELD_WHITEPOINT,
{ TIFFTAG_WHITEPOINT, 2, 2, TIFF_RATIONAL, FIELD_CUSTOM,
1, 0, "WhitePoint" },
{ TIFFTAG_PRIMARYCHROMATICITIES,6,6,TIFF_RATIONAL, FIELD_CUSTOM,
1, 0, "PrimaryChromaticities" },

View File

@ -1,4 +1,4 @@
/* $Id: tif_print.c,v 1.31 2005-12-21 14:24:41 dron Exp $ */
/* $Id: tif_print.c,v 1.32 2005-12-23 16:28:15 dron Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -119,6 +119,9 @@ _TIFFPrettyPrintField(TIFF* tif, FILE* fd, ttag_t tag,
switch (tag)
{
case TIFFTAG_WHITEPOINT:
fprintf(fd, " White Point: %g-%g\n",
((float *)raw_data)[0], ((float *)raw_data)[1]); return 1;
case TIFFTAG_REFERENCEBLACKWHITE:
{
uint16 i;
@ -471,9 +474,6 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
} else
fprintf(fd, "(present)\n");
}
if (TIFFFieldSet(tif,FIELD_WHITEPOINT))
fprintf(fd, " White Point: %g-%g\n",
td->td_whitepoint[0], td->td_whitepoint[1]);
if (TIFFFieldSet(tif,FIELD_TRANSFERFUNCTION)) {
fprintf(fd, " Transfer Function: ");
if (flags & TIFFPRINT_CURVES) {