Updated libtiff to release version 3.6.1
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5882 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -4,6 +4,7 @@ Translator TIFFTranslator :
|
||||
tif_aux.c
|
||||
tif_close.c
|
||||
tif_codec.c
|
||||
tif_color.c
|
||||
tif_compress.c
|
||||
tif_dir.c
|
||||
tif_dirinfo.c
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_aux.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_aux.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991-1997 Sam Leffler
|
||||
@@ -31,8 +31,6 @@
|
||||
*/
|
||||
#include "tiffiop.h"
|
||||
#include "tif_predict.h"
|
||||
|
||||
#ifdef COLORIMETRY_SUPPORT
|
||||
#include <math.h>
|
||||
|
||||
static void
|
||||
@@ -66,7 +64,6 @@ TIFFDefaultRefBlackWhite(TIFFDirectory* td)
|
||||
td->td_refblackwhite[2*i+1] = (float)((1L<<td->td_bitspersample)-1L);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Like TIFFGetField, but return any default
|
||||
@@ -120,10 +117,9 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap)
|
||||
case TIFFTAG_PREDICTOR:
|
||||
{
|
||||
TIFFPredictorState* sp = (TIFFPredictorState*) tif->tif_data;
|
||||
*va_arg(ap, uint16*) = sp->predictor;
|
||||
*va_arg(ap, uint16*) = (uint16) sp->predictor;
|
||||
return (1);
|
||||
}
|
||||
#ifdef CMYK_SUPPORT
|
||||
case TIFFTAG_DOTRANGE:
|
||||
*va_arg(ap, uint16 *) = 0;
|
||||
*va_arg(ap, uint16 *) = (1<<td->td_bitspersample)-1;
|
||||
@@ -134,7 +130,6 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap)
|
||||
case TIFFTAG_NUMBEROFINKS:
|
||||
*va_arg(ap, uint16 *) = td->td_ninks;
|
||||
return (1);
|
||||
#endif
|
||||
case TIFFTAG_EXTRASAMPLES:
|
||||
*va_arg(ap, uint16 *) = td->td_extrasamples;
|
||||
*va_arg(ap, uint16 **) = td->td_sampleinfo;
|
||||
@@ -156,7 +151,6 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap)
|
||||
case TIFFTAG_IMAGEDEPTH:
|
||||
*va_arg(ap, uint32 *) = td->td_imagedepth;
|
||||
return (1);
|
||||
#ifdef YCBCR_SUPPORT
|
||||
case TIFFTAG_YCBCRCOEFFICIENTS:
|
||||
if (!td->td_ycbcrcoeffs) {
|
||||
td->td_ycbcrcoeffs = (float *)
|
||||
@@ -175,8 +169,20 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap)
|
||||
case TIFFTAG_YCBCRPOSITIONING:
|
||||
*va_arg(ap, uint16 *) = td->td_ycbcrpositioning;
|
||||
return (1);
|
||||
#endif
|
||||
#ifdef COLORIMETRY_SUPPORT
|
||||
case TIFFTAG_WHITEPOINT:
|
||||
if (!td->td_whitepoint) {
|
||||
td->td_whitepoint = (float *)
|
||||
_TIFFmalloc(2 * sizeof (float));
|
||||
/* TIFF 6.0 specification says 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);
|
||||
}
|
||||
*va_arg(ap, float **) = td->td_whitepoint;
|
||||
return (1);
|
||||
case TIFFTAG_TRANSFERFUNCTION:
|
||||
if (!td->td_transferfunction[0])
|
||||
TIFFDefaultTransferFunction(td);
|
||||
@@ -191,7 +197,6 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap)
|
||||
TIFFDefaultRefBlackWhite(td);
|
||||
*va_arg(ap, float **) = td->td_refblackwhite;
|
||||
return (1);
|
||||
#endif
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_close.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_close.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -39,6 +39,9 @@ TIFFClose(TIFF* tif)
|
||||
TIFFFlush(tif);
|
||||
(*tif->tif_cleanup)(tif);
|
||||
TIFFFreeDirectory(tif);
|
||||
|
||||
if (tif->tif_dirlist)
|
||||
_TIFFfree(tif->tif_dirlist);
|
||||
|
||||
/* Clean up client info links */
|
||||
while( tif->tif_clientinfo )
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_codec.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_codec.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -111,9 +111,40 @@ _notConfigured(TIFF* tif)
|
||||
static int
|
||||
NotConfigured(TIFF* tif, int scheme)
|
||||
{
|
||||
tif->tif_decodestatus = FALSE;
|
||||
tif->tif_setupdecode = _notConfigured;
|
||||
tif->tif_encodestatus = FALSE;
|
||||
tif->tif_setupencode = _notConfigured;
|
||||
return (1);
|
||||
(void) scheme;
|
||||
|
||||
tif->tif_decodestatus = FALSE;
|
||||
tif->tif_setupdecode = _notConfigured;
|
||||
tif->tif_encodestatus = FALSE;
|
||||
tif->tif_setupencode = _notConfigured;
|
||||
return (1);
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/* TIFFIsCODECConfigured() */
|
||||
/************************************************************************/
|
||||
|
||||
/**
|
||||
* Check whether we have working codec for the specific coding scheme.
|
||||
*
|
||||
* @return returns 1 if the codec is configured and working. Otherwise
|
||||
* 0 will be returned.
|
||||
*/
|
||||
|
||||
int
|
||||
TIFFIsCODECConfigured(uint16 scheme)
|
||||
{
|
||||
const TIFFCodec* codec = TIFFFindCODEC(scheme);
|
||||
|
||||
if(codec == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if(codec->init == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if(codec->init != NotConfigured){
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,268 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_color.c,v 1.1 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* CIE L*a*b* to CIE XYZ and CIE XYZ to RGB conversion routines are taken
|
||||
* from the VIPS library (http://www.vips.ecs.soton.ac.uk) with
|
||||
* the permission of John Cupitt, the VIPS author.
|
||||
*/
|
||||
|
||||
/*
|
||||
* TIFF Library.
|
||||
*
|
||||
* Color space conversion routines.
|
||||
*/
|
||||
|
||||
#include "tiffiop.h"
|
||||
#include <math.h>
|
||||
|
||||
/*
|
||||
* Convert color value from the CIE L*a*b* 1976 space to CIE XYZ.
|
||||
*/
|
||||
void
|
||||
TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32 l, int32 a, int32 b,
|
||||
float *X, float *Y, float *Z)
|
||||
{
|
||||
float L = (float)l * 100.0F / 255.0F;
|
||||
float cby, tmp;
|
||||
|
||||
if( L < 8.856F ) {
|
||||
*Y = (L * cielab->Y0) / 903.292F;
|
||||
cby = 7.787F * (*Y / cielab->Y0) + 16.0F / 116.0F;
|
||||
} else {
|
||||
cby = (L + 16.0F) / 116.0F;
|
||||
*Y = cielab->Y0 * cby * cby * cby;
|
||||
}
|
||||
|
||||
tmp = (float)a / 500.0F + cby;
|
||||
if( tmp < 0.2069F )
|
||||
*X = cielab->X0 * (tmp - 0.13793F) / 7.787F;
|
||||
else
|
||||
*X = cielab->X0 * tmp * tmp * tmp;
|
||||
|
||||
tmp = cby - (float)b / 200.0F;
|
||||
if( tmp < 0.2069F )
|
||||
*Z = cielab->Z0 * (tmp - 0.13793F) / 7.787F;
|
||||
else
|
||||
*Z = cielab->Z0 * tmp * tmp * tmp;
|
||||
}
|
||||
|
||||
#define RINT(R) ((uint32)((R)>0?((R)+0.5):((R)-0.5)))
|
||||
/*
|
||||
* Convert color value from the XYZ space to RGB.
|
||||
*/
|
||||
void
|
||||
TIFFXYZToRGB(TIFFCIELabToRGB *cielab, float X, float Y, float Z,
|
||||
uint32 *r, uint32 *g, uint32 *b)
|
||||
{
|
||||
int i;
|
||||
float Yr, Yg, Yb;
|
||||
float *matrix = &cielab->display.d_mat[0][0];
|
||||
|
||||
/* Multiply through the matrix to get luminosity values. */
|
||||
Yr = matrix[0] * X + matrix[1] * Y + matrix[2] * Z;
|
||||
Yg = matrix[3] * X + matrix[4] * Y + matrix[5] * Z;
|
||||
Yb = matrix[6] * X + matrix[7] * Y + matrix[8] * Z;
|
||||
|
||||
/* Clip input */
|
||||
Yr = TIFFmax( Yr, cielab->display.d_Y0R );
|
||||
Yg = TIFFmax( Yg, cielab->display.d_Y0G );
|
||||
Yb = TIFFmax( Yb, cielab->display.d_Y0B );
|
||||
|
||||
/* Turn luminosity to colour value. */
|
||||
i = TIFFmin(cielab->range,
|
||||
(int)((Yr - cielab->display.d_Y0R) / cielab->rstep));
|
||||
*r = RINT(cielab->Yr2r[i]);
|
||||
|
||||
i = TIFFmin(cielab->range,
|
||||
(int)((Yg - cielab->display.d_Y0G) / cielab->gstep));
|
||||
*g = RINT(cielab->Yg2g[i]);
|
||||
|
||||
i = TIFFmin(cielab->range,
|
||||
(int)((Yb - cielab->display.d_Y0B) / cielab->bstep));
|
||||
*b = RINT(cielab->Yb2b[i]);
|
||||
|
||||
/* Clip output. */
|
||||
*r = TIFFmin( *r, cielab->display.d_Vrwr );
|
||||
*g = TIFFmin( *g, cielab->display.d_Vrwg );
|
||||
*b = TIFFmin( *b, cielab->display.d_Vrwb );
|
||||
}
|
||||
#undef RINT
|
||||
|
||||
/*
|
||||
* Allocate conversion state structures and make look_up tables for
|
||||
* the Yr,Yb,Yg <=> r,g,b conversions.
|
||||
*/
|
||||
int
|
||||
TIFFCIELabToRGBInit(TIFFCIELabToRGB* cielab,
|
||||
TIFFDisplay *display, float *refWhite)
|
||||
{
|
||||
int i;
|
||||
float gamma;
|
||||
|
||||
cielab->range = CIELABTORGB_TABLE_RANGE;
|
||||
|
||||
_TIFFmemcpy(&cielab->display, display, sizeof(TIFFDisplay));
|
||||
|
||||
/* Red */
|
||||
gamma = 1.0F / cielab->display.d_gammaR ;
|
||||
cielab->rstep =
|
||||
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
|
||||
for(i = 0; i <= cielab->range; i++) {
|
||||
cielab->Yr2r[i] = cielab->display.d_Vrwr
|
||||
* ((float)pow((double)i / cielab->range, gamma));
|
||||
}
|
||||
|
||||
/* Green */
|
||||
gamma = 1.0F / cielab->display.d_gammaG ;
|
||||
cielab->gstep =
|
||||
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
|
||||
for(i = 0; i <= cielab->range; i++) {
|
||||
cielab->Yg2g[i] = cielab->display.d_Vrwg
|
||||
* ((float)pow((double)i / cielab->range, gamma));
|
||||
}
|
||||
|
||||
/* Blue */
|
||||
gamma = 1.0F / cielab->display.d_gammaB ;
|
||||
cielab->bstep =
|
||||
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
|
||||
for(i = 0; i <= cielab->range; i++) {
|
||||
cielab->Yb2b[i] = cielab->display.d_Vrwb
|
||||
* ((float)pow((double)i / cielab->range, gamma));
|
||||
}
|
||||
|
||||
/* Init reference white point */
|
||||
cielab->X0 = refWhite[0];
|
||||
cielab->Y0 = refWhite[1];
|
||||
cielab->Z0 = refWhite[2];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert color value from the YCbCr space to CIE XYZ.
|
||||
* The colorspace conversion algorithm comes from the IJG v5a code;
|
||||
* see below for more information on how it works.
|
||||
*/
|
||||
#define SHIFT 16
|
||||
#define FIX(x) ((int32)((x) * (1L<<SHIFT) + 0.5))
|
||||
#define ONE_HALF ((int32)(1<<(SHIFT-1)))
|
||||
#define Code2V(c, RB, RW, CR) ((((c)-(int32)(RB))*(float)(CR))/(float)((RW)-(RB)))
|
||||
#define CLAMP(f,min,max) ((f)<(min)?(min):(f)>(max)?(max):(f))
|
||||
|
||||
void
|
||||
TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32 Y, int32 Cb, int32 Cr,
|
||||
uint32 *r, uint32 *g, uint32 *b)
|
||||
{
|
||||
/* XXX: Only 8-bit YCbCr input supported for now */
|
||||
Y = CLAMP(Y, 0, 255), Cb = CLAMP(Cb, 0, 255), Cr = CLAMP(Cr, 0, 255);
|
||||
|
||||
*r = ycbcr->clamptab[ycbcr->Y_tab[Y] + ycbcr->Cr_r_tab[Cr]];
|
||||
*g = ycbcr->clamptab[ycbcr->Y_tab[Y]
|
||||
+ (int)((ycbcr->Cb_g_tab[Cb] + ycbcr->Cr_g_tab[Cr]) >> SHIFT)];
|
||||
*b = ycbcr->clamptab[ycbcr->Y_tab[Y] + ycbcr->Cb_b_tab[Cb]];
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the YCbCr->RGB conversion tables. The conversion
|
||||
* is done according to the 6.0 spec:
|
||||
*
|
||||
* R = Y + Cr*(2 - 2*LumaRed)
|
||||
* B = Y + Cb*(2 - 2*LumaBlue)
|
||||
* G = Y
|
||||
* - LumaBlue*Cb*(2-2*LumaBlue)/LumaGreen
|
||||
* - LumaRed*Cr*(2-2*LumaRed)/LumaGreen
|
||||
*
|
||||
* To avoid floating point arithmetic the fractional constants that
|
||||
* come out of the equations are represented as fixed point values
|
||||
* in the range 0...2^16. We also eliminate multiplications by
|
||||
* pre-calculating possible values indexed by Cb and Cr (this code
|
||||
* assumes conversion is being done for 8-bit samples).
|
||||
*/
|
||||
int
|
||||
TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite)
|
||||
{
|
||||
TIFFRGBValue* clamptab;
|
||||
int i;
|
||||
|
||||
#define LumaRed luma[0]
|
||||
#define LumaGreen luma[1]
|
||||
#define LumaBlue luma[2]
|
||||
|
||||
clamptab = (TIFFRGBValue*)(
|
||||
(tidata_t) ycbcr+TIFFroundup(sizeof (TIFFYCbCrToRGB), sizeof (long)));
|
||||
_TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */
|
||||
ycbcr->clamptab = (clamptab += 256);
|
||||
for (i = 0; i < 256; i++)
|
||||
clamptab[i] = (TIFFRGBValue) i;
|
||||
_TIFFmemset(clamptab+256, 255, 2*256); /* v > 255 => 255 */
|
||||
ycbcr->Cr_r_tab = (int*) (clamptab + 3*256);
|
||||
ycbcr->Cb_b_tab = ycbcr->Cr_r_tab + 256;
|
||||
ycbcr->Cr_g_tab = (int32*) (ycbcr->Cb_b_tab + 256);
|
||||
ycbcr->Cb_g_tab = ycbcr->Cr_g_tab + 256;
|
||||
ycbcr->Y_tab = ycbcr->Cb_g_tab + 256;
|
||||
|
||||
{ float f1 = 2-2*LumaRed; int32 D1 = FIX(f1);
|
||||
float f2 = LumaRed*f1/LumaGreen; int32 D2 = -FIX(f2);
|
||||
float f3 = 2-2*LumaBlue; int32 D3 = FIX(f3);
|
||||
float f4 = LumaBlue*f3/LumaGreen; int32 D4 = -FIX(f4);
|
||||
int x;
|
||||
|
||||
#undef LumaBlue
|
||||
#undef LumaGreen
|
||||
#undef LumaRed
|
||||
|
||||
/*
|
||||
* i is the actual input pixel value in the range 0..255
|
||||
* Cb and Cr values are in the range -128..127 (actually
|
||||
* they are in a range defined by the ReferenceBlackWhite
|
||||
* tag) so there is some range shifting to do here when
|
||||
* constructing tables indexed by the raw pixel data.
|
||||
*/
|
||||
for (i = 0, x = -128; i < 256; i++, x++) {
|
||||
int32 Cr = (int32)Code2V(x, refBlackWhite[4] - 128.0F,
|
||||
refBlackWhite[5] - 128.0F, 127);
|
||||
int32 Cb = (int32)Code2V(x, refBlackWhite[2] - 128.0F,
|
||||
refBlackWhite[3] - 128.0F, 127);
|
||||
|
||||
ycbcr->Cr_r_tab[i] = (int32)((D1*Cr + ONE_HALF)>>SHIFT);
|
||||
ycbcr->Cb_b_tab[i] = (int32)((D3*Cb + ONE_HALF)>>SHIFT);
|
||||
ycbcr->Cr_g_tab[i] = D2*Cr;
|
||||
ycbcr->Cb_g_tab[i] = D4*Cb + ONE_HALF;
|
||||
ycbcr->Y_tab[i] =
|
||||
(int32)Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#undef CLAMP
|
||||
#undef Code2V
|
||||
#undef SHIFT
|
||||
#undef ONE_HALF
|
||||
#undef FIX
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_dir.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_dir.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -84,7 +84,6 @@ setExtraSamples(TIFFDirectory* td, va_list ap, int* v)
|
||||
return (1);
|
||||
}
|
||||
|
||||
#ifdef CMYK_SUPPORT
|
||||
static int
|
||||
checkInkNamesString(TIFF* tif, int slen, const char* s)
|
||||
{
|
||||
@@ -110,11 +109,12 @@ bad:
|
||||
td->td_samplesperpixel-i);
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
_TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
{
|
||||
static const char module[] = "_TIFFVSetField";
|
||||
|
||||
TIFFDirectory* td = &tif->tif_dir;
|
||||
int status = 1;
|
||||
uint32 v32;
|
||||
@@ -168,7 +168,7 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
* Setup new compression routine state.
|
||||
*/
|
||||
if( (status = TIFFSetCompressionScheme(tif, v)) != 0 )
|
||||
td->td_compression = v;
|
||||
td->td_compression = (uint16) v;
|
||||
else
|
||||
status = 0;
|
||||
break;
|
||||
@@ -393,19 +393,17 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
break;
|
||||
/* End Pixar Tags */
|
||||
|
||||
#if SUBIFD_SUPPORT
|
||||
case TIFFTAG_SUBIFD:
|
||||
if ((tif->tif_flags & TIFF_INSUBIFD) == 0) {
|
||||
td->td_nsubifd = (uint16) va_arg(ap, int);
|
||||
_TIFFsetLongArray(&td->td_subifd, va_arg(ap, uint32*),
|
||||
(long) td->td_nsubifd);
|
||||
} else {
|
||||
TIFFError(tif->tif_name, "Sorry, cannot nest SubIFDs");
|
||||
TIFFError(module, "%s: Sorry, cannot nest SubIFDs",
|
||||
tif->tif_name);
|
||||
status = 0;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#ifdef YCBCR_SUPPORT
|
||||
case TIFFTAG_YCBCRCOEFFICIENTS:
|
||||
_TIFFsetFloatArray(&td->td_ycbcrcoeffs, va_arg(ap, float*), 3);
|
||||
break;
|
||||
@@ -416,8 +414,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;
|
||||
#endif
|
||||
#ifdef COLORIMETRY_SUPPORT
|
||||
case TIFFTAG_WHITEPOINT:
|
||||
_TIFFsetFloatArray(&td->td_whitepoint, va_arg(ap, float*), 2);
|
||||
break;
|
||||
@@ -434,8 +430,6 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
/* XXX should check for null range */
|
||||
_TIFFsetFloatArray(&td->td_refblackwhite, va_arg(ap, float*), 6);
|
||||
break;
|
||||
#endif
|
||||
#ifdef CMYK_SUPPORT
|
||||
case TIFFTAG_INKSET:
|
||||
td->td_inkset = (uint16) va_arg(ap, int);
|
||||
break;
|
||||
@@ -460,33 +454,22 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
case TIFFTAG_TARGETPRINTER:
|
||||
_TIFFsetString(&td->td_targetprinter, va_arg(ap, char*));
|
||||
break;
|
||||
#endif
|
||||
#ifdef ICC_SUPPORT
|
||||
case TIFFTAG_ICCPROFILE:
|
||||
td->td_profileLength = (uint32) va_arg(ap, uint32);
|
||||
_TIFFsetByteArray(&td->td_profileData, va_arg(ap, void*),
|
||||
td->td_profileLength);
|
||||
break;
|
||||
#endif
|
||||
#ifdef PHOTOSHOP_SUPPORT
|
||||
case TIFFTAG_PHOTOSHOP:
|
||||
td->td_photoshopLength = (uint32) va_arg(ap, uint32);
|
||||
_TIFFsetByteArray (&td->td_photoshopData, va_arg(ap, void*),
|
||||
td->td_photoshopLength);
|
||||
break;
|
||||
#endif
|
||||
#ifdef IPTC_SUPPORT
|
||||
case TIFFTAG_RICHTIFFIPTC:
|
||||
case TIFFTAG_RICHTIFFIPTC:
|
||||
td->td_richtiffiptcLength = (uint32) va_arg(ap, uint32);
|
||||
#ifdef PHOTOSHOP_SUPPORT
|
||||
_TIFFsetLongArray ((uint32**)&td->td_richtiffiptcData, va_arg(ap, uint32*),
|
||||
td->td_richtiffiptcLength);
|
||||
#else
|
||||
_TIFFsetByteArray (&td->td_photoshopData, va_arg(ap, void*),
|
||||
td->td_photoshopLength);
|
||||
#endif
|
||||
_TIFFsetLongArray ((uint32**)&td->td_richtiffiptcData,
|
||||
va_arg(ap, uint32*),
|
||||
td->td_richtiffiptcLength);
|
||||
break;
|
||||
#endif
|
||||
case TIFFTAG_XMLPACKET:
|
||||
td->td_xmlpacketLength = (uint32) va_arg(ap, uint32);
|
||||
_TIFFsetByteArray(&td->td_xmlpacketData, va_arg(ap, void*),
|
||||
@@ -510,7 +493,7 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
*/
|
||||
if( fip == NULL || fip->field_bit != FIELD_CUSTOM )
|
||||
{
|
||||
TIFFError("TIFFSetField",
|
||||
TIFFError(module,
|
||||
"%s: Invalid %stag \"%s\" (not supported by codec)",
|
||||
tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
|
||||
_TIFFFieldWithTag(tif, tag)->field_name);
|
||||
@@ -564,6 +547,10 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
if( fip->field_passcount )
|
||||
{
|
||||
tv->value = _TIFFmalloc(tv_size * tv->count);
|
||||
if ( !tv->value ) {
|
||||
va_end(ap);
|
||||
return 0;
|
||||
}
|
||||
_TIFFmemcpy( tv->value, (void *) va_arg(ap,void*),
|
||||
tv->count * tv_size );
|
||||
}
|
||||
@@ -572,15 +559,22 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
const char *value = (const char *) va_arg(ap,const char *);
|
||||
tv->count = strlen(value)+1;
|
||||
tv->value = _TIFFmalloc(tv->count);
|
||||
if ( !tv->value ) {
|
||||
va_end(ap);
|
||||
return 0;
|
||||
}
|
||||
strcpy( tv->value, value );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* not supporting "pass by value" types yet */
|
||||
|
||||
printf( "TIFFVSetField ... pass by value not imp.\n" );
|
||||
TIFFWarning(module, " ... pass by value not implemented.");
|
||||
|
||||
tv->value = _TIFFmalloc(tv_size * tv->count);
|
||||
if ( !tv->value ) {
|
||||
va_end(ap);
|
||||
return 0;
|
||||
}
|
||||
_TIFFmemset( tv->value, 0, tv->count * tv_size );
|
||||
status = 0;
|
||||
}
|
||||
@@ -593,18 +587,18 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
va_end(ap);
|
||||
return (status);
|
||||
badvalue:
|
||||
TIFFError(tif->tif_name, "%d: Bad value for \"%s\"", v,
|
||||
_TIFFFieldWithTag(tif, tag)->field_name);
|
||||
TIFFError(module, "%.1000s: Bad value %d for \"%s\"",
|
||||
tif->tif_name, v, _TIFFFieldWithTag(tif, tag)->field_name);
|
||||
va_end(ap);
|
||||
return (0);
|
||||
badvalue32:
|
||||
TIFFError(tif->tif_name, "%ld: Bad value for \"%s\"", v32,
|
||||
_TIFFFieldWithTag(tif, tag)->field_name);
|
||||
TIFFError(module, "%.1000s: Bad value %ld for \"%s\"",
|
||||
tif->tif_name, v32, _TIFFFieldWithTag(tif, tag)->field_name);
|
||||
va_end(ap);
|
||||
return (0);
|
||||
badvaluedbl:
|
||||
TIFFError(tif->tif_name, "%f: Bad value for \"%s\"", d,
|
||||
_TIFFFieldWithTag(tif, tag)->field_name);
|
||||
TIFFError(module, "%.1000s: Bad value %f for \"%s\"",
|
||||
tif->tif_name, d, _TIFFFieldWithTag(tif, tag)->field_name);
|
||||
va_end(ap);
|
||||
return (0);
|
||||
}
|
||||
@@ -836,13 +830,10 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
case TIFFTAG_STONITS:
|
||||
*va_arg(ap, double*) = td->td_stonits;
|
||||
break;
|
||||
#if SUBIFD_SUPPORT
|
||||
case TIFFTAG_SUBIFD:
|
||||
*va_arg(ap, uint16*) = td->td_nsubifd;
|
||||
*va_arg(ap, uint32**) = td->td_subifd;
|
||||
break;
|
||||
#endif
|
||||
#ifdef YCBCR_SUPPORT
|
||||
case TIFFTAG_YCBCRCOEFFICIENTS:
|
||||
*va_arg(ap, float**) = td->td_ycbcrcoeffs;
|
||||
break;
|
||||
@@ -853,8 +844,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;
|
||||
#endif
|
||||
#ifdef COLORIMETRY_SUPPORT
|
||||
case TIFFTAG_WHITEPOINT:
|
||||
*va_arg(ap, float**) = td->td_whitepoint;
|
||||
break;
|
||||
@@ -871,8 +860,6 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
case TIFFTAG_REFERENCEBLACKWHITE:
|
||||
*va_arg(ap, float**) = td->td_refblackwhite;
|
||||
break;
|
||||
#endif
|
||||
#ifdef CMYK_SUPPORT
|
||||
case TIFFTAG_INKSET:
|
||||
*va_arg(ap, uint16*) = td->td_inkset;
|
||||
break;
|
||||
@@ -889,25 +876,18 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
case TIFFTAG_TARGETPRINTER:
|
||||
*va_arg(ap, char**) = td->td_targetprinter;
|
||||
break;
|
||||
#endif
|
||||
#ifdef ICC_SUPPORT
|
||||
case TIFFTAG_ICCPROFILE:
|
||||
*va_arg(ap, uint32*) = td->td_profileLength;
|
||||
*va_arg(ap, void**) = td->td_profileData;
|
||||
break;
|
||||
#endif
|
||||
#ifdef PHOTOSHOP_SUPPORT
|
||||
case TIFFTAG_PHOTOSHOP:
|
||||
*va_arg(ap, uint32*) = td->td_photoshopLength;
|
||||
*va_arg(ap, void**) = td->td_photoshopData;
|
||||
break;
|
||||
#endif
|
||||
#ifdef IPTC_SUPPORT
|
||||
case TIFFTAG_RICHTIFFIPTC:
|
||||
*va_arg(ap, uint32*) = td->td_richtiffiptcLength;
|
||||
*va_arg(ap, void**) = td->td_richtiffiptcData;
|
||||
break;
|
||||
#endif
|
||||
case TIFFTAG_XMLPACKET:
|
||||
*va_arg(ap, uint32*) = td->td_xmlpacketLength;
|
||||
*va_arg(ap, void**) = td->td_xmlpacketData;
|
||||
@@ -951,7 +931,7 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
*/
|
||||
if( fip == NULL || fip->field_bit != FIELD_CUSTOM )
|
||||
{
|
||||
TIFFError("TIFFGetField",
|
||||
TIFFError("_TIFFVGetField",
|
||||
"%s: Invalid %stag \"%s\" (not supported by codec)",
|
||||
tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
|
||||
_TIFFFieldWithTag(tif, tag)->field_name);
|
||||
@@ -972,7 +952,7 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
|
||||
if( fip->field_passcount )
|
||||
{
|
||||
*va_arg(ap, u_short *) = tv->count;
|
||||
*va_arg(ap, u_short *) = (u_short) tv->count;
|
||||
*va_arg(ap, void **) = tv->value;
|
||||
ret_val = 1;
|
||||
break;
|
||||
@@ -1053,33 +1033,19 @@ TIFFFreeDirectory(TIFF* tif)
|
||||
CleanupField(td_copyright);
|
||||
CleanupField(td_pagename);
|
||||
CleanupField(td_sampleinfo);
|
||||
#if SUBIFD_SUPPORT
|
||||
CleanupField(td_subifd);
|
||||
#endif
|
||||
#ifdef YCBCR_SUPPORT
|
||||
CleanupField(td_ycbcrcoeffs);
|
||||
#endif
|
||||
#ifdef CMYK_SUPPORT
|
||||
CleanupField(td_inknames);
|
||||
CleanupField(td_targetprinter);
|
||||
#endif
|
||||
#ifdef COLORIMETRY_SUPPORT
|
||||
CleanupField(td_whitepoint);
|
||||
CleanupField(td_primarychromas);
|
||||
CleanupField(td_refblackwhite);
|
||||
CleanupField(td_transferfunction[0]);
|
||||
CleanupField(td_transferfunction[1]);
|
||||
CleanupField(td_transferfunction[2]);
|
||||
#endif
|
||||
#ifdef ICC_SUPPORT
|
||||
CleanupField(td_profileData);
|
||||
#endif
|
||||
#ifdef PHOTOSHOP_SUPPORT
|
||||
CleanupField(td_photoshopData);
|
||||
#endif
|
||||
#ifdef IPTC_SUPPORT
|
||||
CleanupField(td_richtiffiptcData);
|
||||
#endif
|
||||
CleanupField(td_xmlpacketData);
|
||||
CleanupField(td_stripoffset);
|
||||
CleanupField(td_stripbytecount);
|
||||
@@ -1155,15 +1121,11 @@ TIFFDefaultDirectory(TIFF* tif)
|
||||
td->td_resolutionunit = RESUNIT_INCH;
|
||||
td->td_sampleformat = SAMPLEFORMAT_UINT;
|
||||
td->td_imagedepth = 1;
|
||||
#ifdef YCBCR_SUPPORT
|
||||
td->td_ycbcrsubsampling[0] = 2;
|
||||
td->td_ycbcrsubsampling[1] = 2;
|
||||
td->td_ycbcrpositioning = YCBCRPOSITION_CENTERED;
|
||||
#endif
|
||||
#ifdef CMYK_SUPPORT
|
||||
td->td_inkset = INKSET_CMYK;
|
||||
td->td_ninks = 4;
|
||||
#endif
|
||||
tif->tif_postdecode = _TIFFNoPostDecode;
|
||||
tif->tif_tagmethods.vsetfield = _TIFFVSetField;
|
||||
tif->tif_tagmethods.vgetfield = _TIFFVGetField;
|
||||
@@ -1288,6 +1250,11 @@ TIFFSetDirectory(TIFF* tif, tdir_t dirn)
|
||||
* tif_curdir after successfully reading the directory.
|
||||
*/
|
||||
tif->tif_curdir = (dirn - n) - 1;
|
||||
/*
|
||||
* Reset tif_dirnumber counter nad start new list of seen directories.
|
||||
* We need this in order to prevent IFD loops.
|
||||
*/
|
||||
tif->tif_dirnumber = 0;
|
||||
return (TIFFReadDirectory(tif));
|
||||
}
|
||||
|
||||
@@ -1301,6 +1268,11 @@ int
|
||||
TIFFSetSubDirectory(TIFF* tif, uint32 diroff)
|
||||
{
|
||||
tif->tif_nextdiroff = diroff;
|
||||
/*
|
||||
* Reset tif_dirnumber counter nad start new list of seen directories.
|
||||
* We need this in order to prevent IFD loops.
|
||||
*/
|
||||
tif->tif_dirnumber = 0;
|
||||
return (TIFFReadDirectory(tif));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_dir.h,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_dir.h,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -251,8 +251,9 @@ extern "C" {
|
||||
extern void _TIFFSetupFieldInfo(TIFF*);
|
||||
extern void _TIFFPrintFieldInfo(TIFF*, FILE*);
|
||||
extern TIFFDataType _TIFFSampleToTagType(TIFF*);
|
||||
extern const TIFFFieldInfo* _TIFFFindOrRegisterInfo( TIFF *tif, ttag_t tag,
|
||||
TIFFDataType dt );
|
||||
extern const TIFFFieldInfo* _TIFFFindOrRegisterFieldInfo( TIFF *tif,
|
||||
ttag_t tag,
|
||||
TIFFDataType dt );
|
||||
extern TIFFFieldInfo* _TIFFCreateAnonFieldInfo( TIFF *tif, ttag_t tag,
|
||||
TIFFDataType dt );
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_dirinfo.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_dirinfo.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -140,10 +140,8 @@ const TIFFFieldInfo tiffFieldInfo[] = {
|
||||
TRUE, FALSE, "PageNumber" },
|
||||
{ TIFFTAG_COLORRESPONSEUNIT, 1, 1, TIFF_SHORT, FIELD_IGNORE,
|
||||
TRUE, FALSE, "ColorResponseUnit" },
|
||||
#ifdef COLORIMETRY_SUPPORT
|
||||
{ TIFFTAG_TRANSFERFUNCTION, -1,-1, TIFF_SHORT, FIELD_TRANSFERFUNCTION,
|
||||
TRUE, FALSE, "TransferFunction" },
|
||||
#endif
|
||||
{ TIFFTAG_SOFTWARE, -1,-1, TIFF_ASCII, FIELD_CUSTOM,
|
||||
TRUE, FALSE, "Software" },
|
||||
{ TIFFTAG_DATETIME, 20,20, TIFF_ASCII, FIELD_DATETIME,
|
||||
@@ -152,12 +150,10 @@ const TIFFFieldInfo tiffFieldInfo[] = {
|
||||
TRUE, FALSE, "Artist" },
|
||||
{ TIFFTAG_HOSTCOMPUTER, -1,-1, TIFF_ASCII, FIELD_HOSTCOMPUTER,
|
||||
TRUE, FALSE, "HostComputer" },
|
||||
#ifdef COLORIMETRY_SUPPORT
|
||||
{ TIFFTAG_WHITEPOINT, 2, 2, TIFF_RATIONAL,FIELD_WHITEPOINT,
|
||||
TRUE, FALSE, "WhitePoint" },
|
||||
{ TIFFTAG_PRIMARYCHROMATICITIES,6,6,TIFF_RATIONAL,FIELD_PRIMARYCHROMAS,
|
||||
TRUE, FALSE, "PrimaryChromaticities" },
|
||||
#endif
|
||||
{ TIFFTAG_COLORMAP, -1,-1, TIFF_SHORT, FIELD_COLORMAP,
|
||||
TRUE, FALSE, "ColorMap" },
|
||||
{ TIFFTAG_HALFTONEHINTS, 2, 2, TIFF_SHORT, FIELD_HALFTONEHINTS,
|
||||
@@ -176,11 +172,8 @@ const TIFFFieldInfo tiffFieldInfo[] = {
|
||||
FALSE, FALSE, "TileByteCounts" },
|
||||
{ TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_SHORT, FIELD_STRIPBYTECOUNTS,
|
||||
FALSE, FALSE, "TileByteCounts" },
|
||||
#ifdef TIFFTAG_SUBIFD
|
||||
{ TIFFTAG_SUBIFD, -1,-1, TIFF_LONG, FIELD_SUBIFD,
|
||||
TRUE, TRUE, "SubIFD" },
|
||||
#endif
|
||||
#ifdef CMYK_SUPPORT /* 6.0 CMYK tags */
|
||||
{ TIFFTAG_INKSET, 1, 1, TIFF_SHORT, FIELD_INKSET,
|
||||
FALSE, FALSE, "InkSet" },
|
||||
{ TIFFTAG_INKNAMES, -1,-1, TIFF_ASCII, FIELD_INKNAMES,
|
||||
@@ -193,7 +186,6 @@ const TIFFFieldInfo tiffFieldInfo[] = {
|
||||
FALSE, FALSE, "DotRange" },
|
||||
{ TIFFTAG_TARGETPRINTER, -1,-1, TIFF_ASCII, FIELD_TARGETPRINTER,
|
||||
TRUE, FALSE, "TargetPrinter" },
|
||||
#endif
|
||||
{ TIFFTAG_EXTRASAMPLES, -1,-1, TIFF_SHORT, FIELD_EXTRASAMPLES,
|
||||
FALSE, FALSE, "ExtraSamples" },
|
||||
/* XXX for bogus Adobe Photoshop v2.5 files */
|
||||
@@ -205,21 +197,17 @@ const TIFFFieldInfo tiffFieldInfo[] = {
|
||||
TRUE, FALSE, "SMinSampleValue" },
|
||||
{ TIFFTAG_SMAXSAMPLEVALUE, -2,-1, TIFF_ANY, FIELD_SMAXSAMPLEVALUE,
|
||||
TRUE, FALSE, "SMaxSampleValue" },
|
||||
#ifdef YCBCR_SUPPORT /* 6.0 YCbCr tags */
|
||||
{ TIFFTAG_YCBCRCOEFFICIENTS, 3, 3, TIFF_RATIONAL, FIELD_YCBCRCOEFFICIENTS,
|
||||
FALSE, FALSE, "YCbCrCoefficients" },
|
||||
{ TIFFTAG_YCBCRSUBSAMPLING, 2, 2, TIFF_SHORT, FIELD_YCBCRSUBSAMPLING,
|
||||
FALSE, FALSE, "YCbCrSubsampling" },
|
||||
{ TIFFTAG_YCBCRPOSITIONING, 1, 1, TIFF_SHORT, FIELD_YCBCRPOSITIONING,
|
||||
FALSE, FALSE, "YCbCrPositioning" },
|
||||
#endif
|
||||
#ifdef COLORIMETRY_SUPPORT
|
||||
{ TIFFTAG_REFERENCEBLACKWHITE,6,6,TIFF_RATIONAL, FIELD_REFBLACKWHITE,
|
||||
TRUE, FALSE, "ReferenceBlackWhite" },
|
||||
/* XXX temporarily accept LONG for backwards compatibility */
|
||||
{ TIFFTAG_REFERENCEBLACKWHITE,6,6,TIFF_LONG, FIELD_REFBLACKWHITE,
|
||||
TRUE, FALSE, "ReferenceBlackWhite" },
|
||||
#endif
|
||||
{ TIFFTAG_XMLPACKET, -1,-3, TIFF_UNDEFINED, FIELD_XMLPACKET,
|
||||
FALSE, TRUE, "XMLPacket" },
|
||||
/* begin SGI tags */
|
||||
@@ -263,14 +251,10 @@ const TIFFFieldInfo tiffFieldInfo[] = {
|
||||
FALSE, TRUE, "RichTIFFIPTC" },
|
||||
#endif
|
||||
#endif
|
||||
#ifdef PHOTOSHOP_SUPPORT
|
||||
{ TIFFTAG_PHOTOSHOP, -1,-3, TIFF_BYTE, FIELD_PHOTOSHOP,
|
||||
FALSE, TRUE, "Photoshop" },
|
||||
#endif
|
||||
#ifdef ICC_SUPPORT
|
||||
{ TIFFTAG_ICCPROFILE, -1,-3, TIFF_UNDEFINED, FIELD_ICCPROFILE,
|
||||
FALSE, TRUE, "ICC Profile" },
|
||||
#endif
|
||||
{ TIFFTAG_STONITS, 1, 1, TIFF_DOUBLE, FIELD_STONITS,
|
||||
FALSE, FALSE, "StoNits" },
|
||||
};
|
||||
@@ -280,18 +264,18 @@ void
|
||||
_TIFFSetupFieldInfo(TIFF* tif)
|
||||
{
|
||||
if (tif->tif_fieldinfo) {
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < tif->tif_nfields; i++)
|
||||
for (i = 0; i < tif->tif_nfields; i++)
|
||||
{
|
||||
TIFFFieldInfo *fld = tif->tif_fieldinfo[i];
|
||||
if (fld->field_bit == FIELD_CUSTOM &&
|
||||
TIFFFieldInfo *fld = tif->tif_fieldinfo[i];
|
||||
if (fld->field_bit == FIELD_CUSTOM &&
|
||||
strncmp("Tag ", fld->field_name, 4) == 0)
|
||||
{
|
||||
{
|
||||
_TIFFfree(fld->field_name);
|
||||
_TIFFfree(fld);
|
||||
}
|
||||
}
|
||||
_TIFFfree(fld);
|
||||
}
|
||||
}
|
||||
|
||||
_TIFFfree(tif->tif_fieldinfo);
|
||||
tif->tif_nfields = 0;
|
||||
@@ -308,7 +292,7 @@ tagCompare(const void* a, const void* b)
|
||||
if (ta->field_tag != tb->field_tag)
|
||||
return (ta->field_tag < tb->field_tag ? -1 : 1);
|
||||
else
|
||||
return (tb->field_type < ta->field_type ? -1 : 1);
|
||||
return ((int)tb->field_type - (int)ta->field_type);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -375,13 +359,14 @@ TIFFDataWidth(TIFFDataType type)
|
||||
case 4: /* TIFF_LONG */
|
||||
case 9: /* TIFF_SLONG */
|
||||
case 11: /* TIFF_FLOAT */
|
||||
case 13: /* TIFF_IFD */
|
||||
return 4;
|
||||
case 5: /* TIFF_RATIONAL */
|
||||
case 10: /* TIFF_SRATIONAL */
|
||||
case 12: /* TIFF_DOUBLE */
|
||||
return 8;
|
||||
default:
|
||||
return 1; /* will return safe value for unknown types */
|
||||
return 0; /* will return 0 for unknown types */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,7 +404,16 @@ _TIFFFindFieldInfo(TIFF* tif, ttag_t tag, TIFFDataType dt)
|
||||
(dt == TIFF_ANY || dt == last->field_type))
|
||||
return (last);
|
||||
/* NB: if table gets big, use sorted search (e.g. binary search) */
|
||||
for (i = 0, n = tif->tif_nfields; i < n; i++) {
|
||||
if(dt != TIFF_ANY) {
|
||||
TIFFFieldInfo key = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
key.field_tag = tag;
|
||||
key.field_type = dt;
|
||||
return((const TIFFFieldInfo *) bsearch(&key,
|
||||
tif->tif_fieldinfo,
|
||||
tif->tif_nfields,
|
||||
sizeof(TIFFFieldInfo),
|
||||
tagCompare));
|
||||
} else for (i = 0, n = tif->tif_nfields; i < n; i++) {
|
||||
const TIFFFieldInfo* fip = tif->tif_fieldinfo[i];
|
||||
if (fip->field_tag == tag &&
|
||||
(dt == TIFF_ANY || fip->field_type == dt))
|
||||
@@ -465,7 +459,7 @@ _TIFFCreateAnonFieldInfo(TIFF *tif, ttag_t tag, TIFFDataType field_type)
|
||||
{
|
||||
TIFFFieldInfo *fld;
|
||||
|
||||
fld = _TIFFmalloc(sizeof (TIFFFieldInfo));
|
||||
fld = (TIFFFieldInfo *) _TIFFmalloc(sizeof (TIFFFieldInfo));
|
||||
_TIFFmemset( fld, 0, sizeof(TIFFFieldInfo) );
|
||||
|
||||
fld->field_tag = tag;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_dirread.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_dirread.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -97,6 +97,27 @@ TIFFReadDirectory(TIFF* tif)
|
||||
tif->tif_diroff = tif->tif_nextdiroff;
|
||||
if (tif->tif_diroff == 0) /* no more directories */
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* XXX: Trick to prevent IFD looping. The one can create TIFF file
|
||||
* with looped directory pointers. We will maintain a list of already
|
||||
* seen directories and check every IFD offset against this list.
|
||||
*/
|
||||
for (n = 0; n < tif->tif_dirnumber; n++) {
|
||||
if (tif->tif_dirlist[n] == tif->tif_diroff)
|
||||
return (0);
|
||||
}
|
||||
tif->tif_dirnumber++;
|
||||
tif->tif_dirlist = _TIFFrealloc(tif->tif_dirlist,
|
||||
tif->tif_dirnumber * sizeof(toff_t));
|
||||
if (!tif->tif_dirlist) {
|
||||
TIFFError(module,
|
||||
"%.1000s: Failed to allocate space for IFD list",
|
||||
tif->tif_name);
|
||||
return (0);
|
||||
}
|
||||
tif->tif_dirlist[tif->tif_dirnumber - 1] = tif->tif_diroff;
|
||||
|
||||
/*
|
||||
* Cleanup any previous compression state.
|
||||
*/
|
||||
@@ -227,9 +248,9 @@ TIFFReadDirectory(TIFF* tif)
|
||||
if( TIFFReassignTagToIgnore(TIS_EXTRACT, dp->tdir_tag) )
|
||||
dp->tdir_tag = IGNORE;
|
||||
|
||||
if (dp->tdir_tag == IGNORE)
|
||||
continue;
|
||||
|
||||
if (fix >= tif->tif_nfields || dp->tdir_tag == IGNORE)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Silicon Beach (at least) writes unordered
|
||||
* directory tags (violating the spec). Handle
|
||||
@@ -238,32 +259,31 @@ TIFFReadDirectory(TIFF* tif)
|
||||
if (dp->tdir_tag < tif->tif_fieldinfo[fix]->field_tag) {
|
||||
if (!diroutoforderwarning) {
|
||||
TIFFWarning(module,
|
||||
"%.1000s: invalid TIFF directory; "
|
||||
"tags are not sorted in ascending order",
|
||||
"%.1000s: invalid TIFF directory; tags are not sorted in ascending order",
|
||||
tif->tif_name);
|
||||
diroutoforderwarning = 1;
|
||||
}
|
||||
fix = 0; /* O(n^2) */
|
||||
}
|
||||
while (fix < tif->tif_nfields &&
|
||||
tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag)
|
||||
tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag)
|
||||
fix++;
|
||||
if (fix == tif->tif_nfields ||
|
||||
if (fix >= tif->tif_nfields ||
|
||||
tif->tif_fieldinfo[fix]->field_tag != dp->tdir_tag) {
|
||||
|
||||
TIFFWarning(module,
|
||||
"%.1000s: unknown field with tag %d (0x%x) encountered",
|
||||
"%.1000s: unknown field with tag %d (0x%x) encountered",
|
||||
tif->tif_name, dp->tdir_tag, dp->tdir_tag);
|
||||
|
||||
TIFFMergeFieldInfo( tif,
|
||||
_TIFFCreateAnonFieldInfo( tif,
|
||||
dp->tdir_tag, dp->tdir_type ),
|
||||
dp->tdir_tag,
|
||||
(TIFFDataType) dp->tdir_type ),
|
||||
1 );
|
||||
fix = 0;
|
||||
while (fix < tif->tif_nfields &&
|
||||
tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag)
|
||||
fix++;
|
||||
dp->tdir_tag = IGNORE;
|
||||
}
|
||||
/*
|
||||
* Null out old tags that we ignore.
|
||||
@@ -284,8 +304,9 @@ TIFFReadDirectory(TIFF* tif)
|
||||
if (fix == tif->tif_nfields ||
|
||||
fip->field_tag != dp->tdir_tag) {
|
||||
TIFFWarning(module,
|
||||
"%.1000s: wrong data type %d for \"%s\"; tag ignored",
|
||||
tif->tif_name, dp->tdir_type, fip[-1].field_name);
|
||||
"%.1000s: wrong data type %d for \"%s\"; tag ignored",
|
||||
tif->tif_name, dp->tdir_type,
|
||||
fip[-1].field_name);
|
||||
goto ignore;
|
||||
}
|
||||
}
|
||||
@@ -521,10 +542,10 @@ TIFFReadDirectory(TIFF* tif)
|
||||
goto bad;
|
||||
}
|
||||
TIFFWarning(module,
|
||||
"%.1000s: TIFF directory is missing required "
|
||||
"\"%s\" field, calculating from imagelength",
|
||||
tif->tif_name,
|
||||
_TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name);
|
||||
"%.1000s: TIFF directory is missing required "
|
||||
"\"%s\" field, calculating from imagelength",
|
||||
tif->tif_name,
|
||||
_TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name);
|
||||
if (EstimateStripByteCounts(tif, dir, dircount) < 0)
|
||||
goto bad;
|
||||
/*
|
||||
@@ -546,8 +567,7 @@ TIFFReadDirectory(TIFF* tif)
|
||||
* strip image.
|
||||
*/
|
||||
TIFFWarning(module,
|
||||
"%.1000s: Bogus \"%s\" field, ignoring "
|
||||
"and calculating from imagelength",
|
||||
"%.1000s: Bogus \"%s\" field, ignoring and calculating from imagelength",
|
||||
tif->tif_name,
|
||||
_TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name);
|
||||
if(EstimateStripByteCounts(tif, dir, dircount) < 0)
|
||||
@@ -593,6 +613,8 @@ bad:
|
||||
static int
|
||||
EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount)
|
||||
{
|
||||
static const char module[] = "EstimateStripByteCounts";
|
||||
|
||||
register TIFFDirEntry *dp;
|
||||
register TIFFDirectory *td = &tif->tif_dir;
|
||||
uint16 i;
|
||||
@@ -613,16 +635,16 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount)
|
||||
/* calculate amount of space used by indirect values */
|
||||
for (dp = dir, n = dircount; n > 0; n--, dp++)
|
||||
{
|
||||
uint32 cc;
|
||||
if(dp->tdir_tag == IGNORE)
|
||||
{
|
||||
TIFFError(tif->tif_name,
|
||||
"Cannot determine StripByteCounts values, because of tags with unknown sizes");
|
||||
return -1;
|
||||
}
|
||||
cc = dp->tdir_count*TIFFDataWidth(dp->tdir_type);
|
||||
if (cc > sizeof (uint32))
|
||||
space += cc;
|
||||
uint32 cc = TIFFDataWidth((TIFFDataType) dp->tdir_type);
|
||||
if (cc == 0) {
|
||||
TIFFError(module,
|
||||
"%.1000s: Cannot determine size of unknown tag type %d",
|
||||
tif->tif_name, dp->tdir_type);
|
||||
return -1;
|
||||
}
|
||||
cc = cc * dp->tdir_count;
|
||||
if (cc > sizeof (uint32))
|
||||
space += cc;
|
||||
}
|
||||
space = filesize - space;
|
||||
if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
|
||||
@@ -656,8 +678,11 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount)
|
||||
static void
|
||||
MissingRequired(TIFF* tif, const char* tagname)
|
||||
{
|
||||
TIFFError(tif->tif_name,
|
||||
"TIFF directory is missing required \"%s\" field", tagname);
|
||||
static const char module[] = "MissingRequired";
|
||||
|
||||
TIFFError(module,
|
||||
"%.1000s: TIFF directory is missing required \"%s\" field",
|
||||
tif->tif_name, tagname);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -685,7 +710,7 @@ CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32 count)
|
||||
static tsize_t
|
||||
TIFFFetchData(TIFF* tif, TIFFDirEntry* dir, char* cp)
|
||||
{
|
||||
int w = TIFFDataWidth(dir->tdir_type);
|
||||
int w = TIFFDataWidth((TIFFDataType) dir->tdir_type);
|
||||
tsize_t cc = dir->tdir_count * w;
|
||||
|
||||
if (!isMapped(tif)) {
|
||||
@@ -906,7 +931,7 @@ TIFFFetchRationalArray(TIFF* tif, TIFFDirEntry* dir, float* v)
|
||||
uint32* l;
|
||||
|
||||
l = (uint32*)CheckMalloc(tif,
|
||||
dir->tdir_count*TIFFDataWidth(dir->tdir_type),
|
||||
dir->tdir_count*TIFFDataWidth((TIFFDataType) dir->tdir_type),
|
||||
"to fetch array of rationals");
|
||||
if (l) {
|
||||
if (TIFFFetchData(tif, dir, (char *)l)) {
|
||||
@@ -1292,14 +1317,14 @@ TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, long nstrips, uint32** lpp)
|
||||
if( (status = TIFFFetchShortArray(tif, dir, dp)) != 0 ) {
|
||||
int i;
|
||||
|
||||
for( i = 0; i < nstrips && i < dir->tdir_count; i++ )
|
||||
for( i = 0; i < nstrips && i < (int) dir->tdir_count; i++ )
|
||||
{
|
||||
lp[i] = dp[i];
|
||||
}
|
||||
}
|
||||
_TIFFfree((char*) dp);
|
||||
|
||||
} else if( nstrips != dir->tdir_count ) {
|
||||
} else if( nstrips != (int) dir->tdir_count ) {
|
||||
/* Special case to correct length */
|
||||
|
||||
uint32* dp = (uint32*) CheckMalloc(tif,
|
||||
@@ -1311,7 +1336,7 @@ TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, long nstrips, uint32** lpp)
|
||||
if( status != 0 ) {
|
||||
int i;
|
||||
|
||||
for( i = 0; i < nstrips && i < dir->tdir_count; i++ )
|
||||
for( i = 0; i < nstrips && i < (int) dir->tdir_count; i++ )
|
||||
{
|
||||
lp[i] = dp[i];
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_dirwrite.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_dirwrite.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -451,81 +451,123 @@ TIFFWriteNormalTag(TIFF* tif, TIFFDirEntry* dir, const TIFFFieldInfo* fip)
|
||||
case TIFF_SSHORT:
|
||||
if (wc > 1) {
|
||||
uint16* wp;
|
||||
if (wc == (u_short) TIFF_VARIABLE)
|
||||
if (wc == (u_short) TIFF_VARIABLE
|
||||
|| fip->field_passcount)
|
||||
TIFFGetField(tif, fip->field_tag, &wc, &wp);
|
||||
else
|
||||
TIFFGetField(tif, fip->field_tag, &wp);
|
||||
if (!WRITEF(TIFFWriteShortArray, wp))
|
||||
return (0);
|
||||
} else {
|
||||
uint16 sv;
|
||||
TIFFGetField(tif, fip->field_tag, &sv);
|
||||
dir->tdir_offset =
|
||||
TIFFInsertData(tif, dir->tdir_type, sv);
|
||||
if (fip->field_passcount) {
|
||||
uint16* wp;
|
||||
TIFFGetField(tif, fip->field_tag, &wc, &wp);
|
||||
if (!WRITEF(TIFFWriteShortArray, wp))
|
||||
return 0;
|
||||
} else {
|
||||
uint16 sv;
|
||||
TIFFGetField(tif, fip->field_tag, &sv);
|
||||
dir->tdir_offset =
|
||||
TIFFInsertData(tif, dir->tdir_type, sv);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TIFF_LONG:
|
||||
case TIFF_SLONG:
|
||||
case TIFF_IFD:
|
||||
if (wc > 1) {
|
||||
uint32* lp;
|
||||
if (wc == (u_short) TIFF_VARIABLE)
|
||||
if (wc == (u_short) TIFF_VARIABLE
|
||||
|| fip->field_passcount)
|
||||
TIFFGetField(tif, fip->field_tag, &wc, &lp);
|
||||
else
|
||||
TIFFGetField(tif, fip->field_tag, &lp);
|
||||
if (!WRITEF(TIFFWriteLongArray, lp))
|
||||
return (0);
|
||||
} else {
|
||||
/* XXX handle LONG->SHORT conversion */
|
||||
TIFFGetField(tif, fip->field_tag, &dir->tdir_offset);
|
||||
if (fip->field_passcount) {
|
||||
uint32* lp;
|
||||
TIFFGetField(tif, fip->field_tag, &wc, &lp);
|
||||
if (!WRITEF(TIFFWriteLongArray, lp))
|
||||
return 0;
|
||||
} else {
|
||||
/* XXX handle LONG->SHORT conversion */
|
||||
TIFFGetField(tif, fip->field_tag,
|
||||
&dir->tdir_offset);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TIFF_RATIONAL:
|
||||
case TIFF_SRATIONAL:
|
||||
if (wc > 1) {
|
||||
float* fp;
|
||||
if (wc == (u_short) TIFF_VARIABLE)
|
||||
if (wc == (u_short) TIFF_VARIABLE
|
||||
|| fip->field_passcount)
|
||||
TIFFGetField(tif, fip->field_tag, &wc, &fp);
|
||||
else
|
||||
TIFFGetField(tif, fip->field_tag, &fp);
|
||||
if (!WRITEF(TIFFWriteRationalArray, fp))
|
||||
return (0);
|
||||
} else {
|
||||
float fv;
|
||||
TIFFGetField(tif, fip->field_tag, &fv);
|
||||
if (!WRITEF(TIFFWriteRationalArray, &fv))
|
||||
return (0);
|
||||
if (fip->field_passcount) {
|
||||
float* fp;
|
||||
TIFFGetField(tif, fip->field_tag, &wc, &fp);
|
||||
if (!WRITEF(TIFFWriteRationalArray, fp))
|
||||
return 0;
|
||||
} else {
|
||||
float fv;
|
||||
TIFFGetField(tif, fip->field_tag, &fv);
|
||||
if (!WRITEF(TIFFWriteRationalArray, &fv))
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TIFF_FLOAT:
|
||||
if (wc > 1) {
|
||||
float* fp;
|
||||
if (wc == (u_short) TIFF_VARIABLE)
|
||||
if (wc == (u_short) TIFF_VARIABLE
|
||||
|| fip->field_passcount)
|
||||
TIFFGetField(tif, fip->field_tag, &wc, &fp);
|
||||
else
|
||||
TIFFGetField(tif, fip->field_tag, &fp);
|
||||
if (!WRITEF(TIFFWriteFloatArray, fp))
|
||||
return (0);
|
||||
} else {
|
||||
float fv;
|
||||
TIFFGetField(tif, fip->field_tag, &fv);
|
||||
if (!WRITEF(TIFFWriteFloatArray, &fv))
|
||||
return (0);
|
||||
if (fip->field_passcount) {
|
||||
float* fp;
|
||||
TIFFGetField(tif, fip->field_tag, &wc, &fp);
|
||||
if (!WRITEF(TIFFWriteFloatArray, fp))
|
||||
return 0;
|
||||
} else {
|
||||
float fv;
|
||||
TIFFGetField(tif, fip->field_tag, &fv);
|
||||
if (!WRITEF(TIFFWriteFloatArray, &fv))
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TIFF_DOUBLE:
|
||||
if (wc > 1) {
|
||||
double* dp;
|
||||
if (wc == (u_short) TIFF_VARIABLE)
|
||||
if (wc == (u_short) TIFF_VARIABLE
|
||||
|| fip->field_passcount)
|
||||
TIFFGetField(tif, fip->field_tag, &wc, &dp);
|
||||
else
|
||||
TIFFGetField(tif, fip->field_tag, &dp);
|
||||
if (!WRITEF(TIFFWriteDoubleArray, dp))
|
||||
return (0);
|
||||
} else {
|
||||
double dv;
|
||||
TIFFGetField(tif, fip->field_tag, &dv);
|
||||
if (!WRITEF(TIFFWriteDoubleArray, &dv))
|
||||
return (0);
|
||||
if (fip->field_passcount) {
|
||||
double* dp;
|
||||
TIFFGetField(tif, fip->field_tag, &wc, &dp);
|
||||
if (!WRITEF(TIFFWriteDoubleArray, dp))
|
||||
return 0;
|
||||
} else {
|
||||
double dv;
|
||||
TIFFGetField(tif, fip->field_tag, &dv);
|
||||
if (!WRITEF(TIFFWriteDoubleArray, &dv))
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TIFF_ASCII:
|
||||
@@ -541,23 +583,32 @@ TIFFWriteNormalTag(TIFF* tif, TIFFDirEntry* dir, const TIFFFieldInfo* fip)
|
||||
correctness not verified (FW, 99/08) */
|
||||
case TIFF_BYTE:
|
||||
case TIFF_SBYTE:
|
||||
if (wc > 1) {
|
||||
char* cp;
|
||||
if (wc == (u_short) TIFF_VARIABLE) {
|
||||
TIFFGetField(tif, fip->field_tag, &wc, &cp);
|
||||
dir->tdir_count = wc;
|
||||
} else if (wc == (u_short) TIFF_VARIABLE2) {
|
||||
TIFFGetField(tif, fip->field_tag, &wc2, &cp);
|
||||
dir->tdir_count = wc2;
|
||||
} else
|
||||
TIFFGetField(tif, fip->field_tag, &cp);
|
||||
if (!TIFFWriteByteArray(tif, dir, cp))
|
||||
return (0);
|
||||
if (wc > 1) {
|
||||
char* cp;
|
||||
if (wc == (u_short) TIFF_VARIABLE
|
||||
|| fip->field_passcount) {
|
||||
TIFFGetField(tif, fip->field_tag, &wc, &cp);
|
||||
dir->tdir_count = wc;
|
||||
} else if (wc == (u_short) TIFF_VARIABLE2) {
|
||||
TIFFGetField(tif, fip->field_tag, &wc2, &cp);
|
||||
dir->tdir_count = wc2;
|
||||
} else
|
||||
TIFFGetField(tif, fip->field_tag, &cp);
|
||||
if (!TIFFWriteByteArray(tif, dir, cp))
|
||||
return (0);
|
||||
} else {
|
||||
char cv;
|
||||
TIFFGetField(tif, fip->field_tag, &cv);
|
||||
if (!TIFFWriteByteArray(tif, dir, &cv))
|
||||
return (0);
|
||||
if (fip->field_passcount) {
|
||||
char* cp;
|
||||
TIFFGetField(tif, fip->field_tag, &wc, &cp);
|
||||
dir->tdir_count = wc;
|
||||
if (!TIFFWriteByteArray(tif, dir, cp))
|
||||
return 0;
|
||||
} else {
|
||||
char cv;
|
||||
TIFFGetField(tif, fip->field_tag, &cv);
|
||||
if (!TIFFWriteByteArray(tif, dir, &cv))
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1008,7 +1059,7 @@ TIFFWriteData(TIFF* tif, TIFFDirEntry* dir, char* cp)
|
||||
}
|
||||
}
|
||||
dir->tdir_offset = tif->tif_dataoff;
|
||||
cc = dir->tdir_count * TIFFDataWidth(dir->tdir_type);
|
||||
cc = dir->tdir_count * TIFFDataWidth((TIFFDataType) dir->tdir_type);
|
||||
if (SeekOK(tif, dir->tdir_offset) &&
|
||||
WriteOK(tif, cp, cc)) {
|
||||
tif->tif_dataoff += (cc + 1) & ~1;
|
||||
@@ -1046,7 +1097,11 @@ TIFFRewriteDirectory( TIFF *tif )
|
||||
tif->tif_header.tiff_diroff = 0;
|
||||
tif->tif_diroff = 0;
|
||||
|
||||
#if defined(__hpux) && defined(__LP64__)
|
||||
#define HDROFF(f) ((toff_t)(unsigned long) &(((TIFFHeader*) 0)->f))
|
||||
#else
|
||||
#define HDROFF(f) ((toff_t) &(((TIFFHeader*) 0)->f))
|
||||
#endif
|
||||
TIFFSeekFile(tif, HDROFF(tiff_diroff), SEEK_SET);
|
||||
if (!WriteOK(tif, &(tif->tif_header.tiff_diroff),
|
||||
sizeof (tif->tif_diroff)))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_extension.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_extension.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -47,7 +47,7 @@ ttag_t TIFFGetTagListEntry( TIFF *tif, int tag_index )
|
||||
TIFFDirectory* td = &tif->tif_dir;
|
||||
|
||||
if( tag_index < 0 || tag_index >= td->td_customValueCount )
|
||||
return -1;
|
||||
return (ttag_t) -1;
|
||||
else
|
||||
return td->td_customValues[tag_index].info->field_tag;
|
||||
}
|
||||
@@ -99,10 +99,10 @@ void TIFFSetClientInfo( TIFF *tif, void *data, const char *name )
|
||||
** Create a new link.
|
||||
*/
|
||||
|
||||
link = _TIFFmalloc(sizeof(TIFFClientInfoLink));
|
||||
link = (TIFFClientInfoLink *) _TIFFmalloc(sizeof(TIFFClientInfoLink));
|
||||
link->next = tif->tif_clientinfo;
|
||||
link->name = _TIFFmalloc(strlen(name)+1);
|
||||
strcpy( link->name, name );
|
||||
link->name = (char *) _TIFFmalloc(strlen(name)+1);
|
||||
strcpy(link->name, name);
|
||||
link->data = data;
|
||||
|
||||
tif->tif_clientinfo = link;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_fax3.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_fax3.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990-1997 Sam Leffler
|
||||
@@ -66,8 +66,11 @@ typedef struct {
|
||||
} Fax3BaseState;
|
||||
#define Fax3State(tif) ((Fax3BaseState*) (tif)->tif_data)
|
||||
|
||||
typedef enum { G3_1D, G3_2D } Ttag;
|
||||
typedef struct {
|
||||
Fax3BaseState b;
|
||||
|
||||
/* Decoder state info */
|
||||
const u_char* bitmap; /* bit reversal table */
|
||||
uint32 data; /* current i/o byte/word */
|
||||
int bit; /* current i/o bit in byte */
|
||||
@@ -76,20 +79,15 @@ typedef struct {
|
||||
uint32* runs; /* b&w runs for current/previous row */
|
||||
uint32* refruns; /* runs for reference line */
|
||||
uint32* curruns; /* runs for current line */
|
||||
} Fax3DecodeState;
|
||||
#define DecoderState(tif) ((Fax3DecodeState*) Fax3State(tif))
|
||||
|
||||
typedef enum { G3_1D, G3_2D } Ttag;
|
||||
typedef struct {
|
||||
Fax3BaseState b;
|
||||
int data; /* current i/o byte */
|
||||
int bit; /* current i/o bit in byte */
|
||||
/* Encoder state info */
|
||||
Ttag tag; /* encoding state */
|
||||
u_char* refline; /* reference line for 2d decoding */
|
||||
int k; /* #rows left that can be 2d encoded */
|
||||
int maxk; /* max #rows that can be 2d encoded */
|
||||
} Fax3EncodeState;
|
||||
#define EncoderState(tif) ((Fax3EncodeState*) Fax3State(tif))
|
||||
} Fax3CodecState;
|
||||
#define DecoderState(tif) ((Fax3CodecState*) Fax3State(tif))
|
||||
#define EncoderState(tif) ((Fax3CodecState*) Fax3State(tif))
|
||||
|
||||
#define is2DEncoding(sp) \
|
||||
(sp->b.groupoptions & GROUP3OPT_2DENCODING)
|
||||
@@ -105,7 +103,7 @@ typedef struct {
|
||||
*/
|
||||
#define DECLARE_STATE(tif, sp, mod) \
|
||||
static const char module[] = mod; \
|
||||
Fax3DecodeState* sp = DecoderState(tif); \
|
||||
Fax3CodecState* sp = DecoderState(tif); \
|
||||
int a0; /* reference element */ \
|
||||
int lastx = sp->b.rowpixels; /* last element in row */ \
|
||||
uint32 BitAcc; /* bit accumulator */ \
|
||||
@@ -149,7 +147,7 @@ typedef struct {
|
||||
static int
|
||||
Fax3PreDecode(TIFF* tif, tsample_t s)
|
||||
{
|
||||
Fax3DecodeState* sp = DecoderState(tif);
|
||||
Fax3CodecState* sp = DecoderState(tif);
|
||||
|
||||
(void) s;
|
||||
assert(sp != NULL);
|
||||
@@ -240,8 +238,6 @@ Fax3Decode1D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
|
||||
(*sp->fill)(buf, thisrun, pa, lastx);
|
||||
buf += sp->b.rowbytes;
|
||||
occ -= sp->b.rowbytes;
|
||||
if (occ != 0)
|
||||
tif->tif_row++;
|
||||
continue;
|
||||
EOF1D: /* premature EOF */
|
||||
CLEANUP_RUNS();
|
||||
@@ -294,8 +290,6 @@ Fax3Decode2D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
|
||||
SWAP(uint32*, sp->curruns, sp->refruns);
|
||||
buf += sp->b.rowbytes;
|
||||
occ -= sp->b.rowbytes;
|
||||
if (occ != 0)
|
||||
tif->tif_row++;
|
||||
continue;
|
||||
EOF2D: /* premature EOF */
|
||||
CLEANUP_RUNS();
|
||||
@@ -457,6 +451,8 @@ Fax3SetupState(TIFF* tif)
|
||||
Fax3BaseState* sp = Fax3State(tif);
|
||||
long rowbytes, rowpixels;
|
||||
int needsRefLine;
|
||||
Fax3CodecState* dsp = DecoderState(tif);
|
||||
uint32 nruns;
|
||||
|
||||
if (td->td_bitspersample != 1) {
|
||||
TIFFError(tif->tif_name,
|
||||
@@ -482,30 +478,29 @@ Fax3SetupState(TIFF* tif)
|
||||
(sp->groupoptions & GROUP3OPT_2DENCODING) ||
|
||||
td->td_compression == COMPRESSION_CCITTFAX4
|
||||
);
|
||||
if (sp->rw_mode == O_RDONLY) { /* 1d/2d decoding */
|
||||
Fax3DecodeState* dsp = DecoderState(tif);
|
||||
uint32 nruns = needsRefLine ?
|
||||
2*TIFFroundup(rowpixels,32) : rowpixels;
|
||||
|
||||
dsp->runs = (uint32*) _TIFFmalloc((2*nruns+3)*sizeof (uint32));
|
||||
if (dsp->runs == NULL) {
|
||||
TIFFError("Fax3SetupState",
|
||||
"%s: No space for Group 3/4 run arrays",
|
||||
tif->tif_name);
|
||||
return (0);
|
||||
}
|
||||
dsp->curruns = dsp->runs;
|
||||
if (needsRefLine)
|
||||
dsp->refruns = dsp->runs + (nruns>>1);
|
||||
else
|
||||
dsp->refruns = NULL;
|
||||
if (is2DEncoding(dsp)) { /* NB: default is 1D routine */
|
||||
tif->tif_decoderow = Fax3Decode2D;
|
||||
tif->tif_decodestrip = Fax3Decode2D;
|
||||
tif->tif_decodetile = Fax3Decode2D;
|
||||
}
|
||||
} else if (needsRefLine) { /* 2d encoding */
|
||||
Fax3EncodeState* esp = EncoderState(tif);
|
||||
nruns = needsRefLine ? 2*TIFFroundup(rowpixels,32) : rowpixels;
|
||||
|
||||
dsp->runs = (uint32*) _TIFFmalloc((2*nruns+3)*sizeof (uint32));
|
||||
if (dsp->runs == NULL) {
|
||||
TIFFError("Fax3SetupState",
|
||||
"%s: No space for Group 3/4 run arrays",
|
||||
tif->tif_name);
|
||||
return (0);
|
||||
}
|
||||
dsp->curruns = dsp->runs;
|
||||
if (needsRefLine)
|
||||
dsp->refruns = dsp->runs + (nruns>>1);
|
||||
else
|
||||
dsp->refruns = NULL;
|
||||
if (is2DEncoding(dsp)) { /* NB: default is 1D routine */
|
||||
tif->tif_decoderow = Fax3Decode2D;
|
||||
tif->tif_decodestrip = Fax3Decode2D;
|
||||
tif->tif_decodetile = Fax3Decode2D;
|
||||
}
|
||||
|
||||
if (needsRefLine) { /* 2d encoding */
|
||||
Fax3CodecState* esp = EncoderState(tif);
|
||||
/*
|
||||
* 2d encoding requires a scanline
|
||||
* buffer for the ``reference line''; the
|
||||
@@ -532,14 +527,14 @@ Fax3SetupState(TIFF* tif)
|
||||
#define Fax3FlushBits(tif, sp) { \
|
||||
if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \
|
||||
(void) TIFFFlushData1(tif); \
|
||||
*(tif)->tif_rawcp++ = (sp)->data; \
|
||||
*(tif)->tif_rawcp++ = (tidataval_t) (sp)->data; \
|
||||
(tif)->tif_rawcc++; \
|
||||
(sp)->data = 0, (sp)->bit = 8; \
|
||||
}
|
||||
#define _FlushBits(tif) { \
|
||||
if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \
|
||||
(void) TIFFFlushData1(tif); \
|
||||
*(tif)->tif_rawcp++ = data; \
|
||||
*(tif)->tif_rawcp++ = (tidataval_t) data; \
|
||||
(tif)->tif_rawcc++; \
|
||||
data = 0, bit = 8; \
|
||||
}
|
||||
@@ -565,7 +560,7 @@ static const int _msbmask[9] =
|
||||
static void
|
||||
Fax3PutBits(TIFF* tif, u_int bits, u_int length)
|
||||
{
|
||||
Fax3EncodeState* sp = EncoderState(tif);
|
||||
Fax3CodecState* sp = EncoderState(tif);
|
||||
u_int bit = sp->bit;
|
||||
int data = sp->data;
|
||||
|
||||
@@ -600,7 +595,7 @@ Fax3PutBits(TIFF* tif, u_int bits, u_int length)
|
||||
static void
|
||||
putspan(TIFF* tif, int32 span, const tableentry* tab)
|
||||
{
|
||||
Fax3EncodeState* sp = EncoderState(tif);
|
||||
Fax3CodecState* sp = EncoderState(tif);
|
||||
u_int bit = sp->bit;
|
||||
int data = sp->data;
|
||||
u_int code, length;
|
||||
@@ -643,7 +638,7 @@ putspan(TIFF* tif, int32 span, const tableentry* tab)
|
||||
static void
|
||||
Fax3PutEOL(TIFF* tif)
|
||||
{
|
||||
Fax3EncodeState* sp = EncoderState(tif);
|
||||
Fax3CodecState* sp = EncoderState(tif);
|
||||
u_int bit = sp->bit;
|
||||
int data = sp->data;
|
||||
u_int code, length, tparm;
|
||||
@@ -680,7 +675,7 @@ Fax3PutEOL(TIFF* tif)
|
||||
static int
|
||||
Fax3PreEncode(TIFF* tif, tsample_t s)
|
||||
{
|
||||
Fax3EncodeState* sp = EncoderState(tif);
|
||||
Fax3CodecState* sp = EncoderState(tif);
|
||||
|
||||
(void) s;
|
||||
assert(sp != NULL);
|
||||
@@ -908,7 +903,7 @@ find1span(u_char* bp, int32 bs, int32 be)
|
||||
static int
|
||||
Fax3Encode1DRow(TIFF* tif, u_char* bp, uint32 bits)
|
||||
{
|
||||
Fax3EncodeState* sp = EncoderState(tif);
|
||||
Fax3CodecState* sp = EncoderState(tif);
|
||||
int32 span;
|
||||
uint32 bs = 0;
|
||||
|
||||
@@ -1000,7 +995,7 @@ Fax3Encode2DRow(TIFF* tif, u_char* bp, u_char* rp, uint32 bits)
|
||||
static int
|
||||
Fax3Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
|
||||
{
|
||||
Fax3EncodeState* sp = EncoderState(tif);
|
||||
Fax3CodecState* sp = EncoderState(tif);
|
||||
|
||||
(void) s;
|
||||
while ((long)cc > 0) {
|
||||
@@ -1027,8 +1022,6 @@ Fax3Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
|
||||
}
|
||||
bp += sp->b.rowbytes;
|
||||
cc -= sp->b.rowbytes;
|
||||
if (cc != 0)
|
||||
tif->tif_row++;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
@@ -1036,7 +1029,7 @@ Fax3Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
|
||||
static int
|
||||
Fax3PostEncode(TIFF* tif)
|
||||
{
|
||||
Fax3EncodeState* sp = EncoderState(tif);
|
||||
Fax3CodecState* sp = EncoderState(tif);
|
||||
|
||||
if (sp->bit != 8)
|
||||
Fax3FlushBits(tif, sp);
|
||||
@@ -1047,7 +1040,7 @@ static void
|
||||
Fax3Close(TIFF* tif)
|
||||
{
|
||||
if ((Fax3State(tif)->mode & FAXMODE_NORTC) == 0) {
|
||||
Fax3EncodeState* sp = EncoderState(tif);
|
||||
Fax3CodecState* sp = EncoderState(tif);
|
||||
u_int code = EOL;
|
||||
u_int length = 12;
|
||||
int i;
|
||||
@@ -1064,15 +1057,13 @@ static void
|
||||
Fax3Cleanup(TIFF* tif)
|
||||
{
|
||||
if (tif->tif_data) {
|
||||
if (Fax3State(tif)->rw_mode == O_RDONLY) {
|
||||
Fax3DecodeState* sp = DecoderState(tif);
|
||||
if (sp->runs)
|
||||
_TIFFfree(sp->runs);
|
||||
} else {
|
||||
Fax3EncodeState* sp = EncoderState(tif);
|
||||
if (sp->refline)
|
||||
_TIFFfree(sp->refline);
|
||||
}
|
||||
Fax3CodecState* sp = DecoderState(tif);
|
||||
|
||||
if (sp->runs)
|
||||
_TIFFfree(sp->runs);
|
||||
if (sp->refline)
|
||||
_TIFFfree(sp->refline);
|
||||
|
||||
if (Fax3State(tif)->subaddress)
|
||||
_TIFFfree(Fax3State(tif)->subaddress);
|
||||
_TIFFfree(tif->tif_data);
|
||||
@@ -1131,8 +1122,7 @@ Fax3VSetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
sp->mode = va_arg(ap, int);
|
||||
return (1); /* NB: pseudo tag */
|
||||
case TIFFTAG_FAXFILLFUNC:
|
||||
if (sp->rw_mode == O_RDONLY)
|
||||
DecoderState(tif)->fill = va_arg(ap, TIFFFaxFillFunc);
|
||||
DecoderState(tif)->fill = va_arg(ap, TIFFFaxFillFunc);
|
||||
return (1); /* NB: pseudo tag */
|
||||
case TIFFTAG_GROUP3OPTIONS:
|
||||
case TIFFTAG_GROUP4OPTIONS:
|
||||
@@ -1174,8 +1164,7 @@ Fax3VGetField(TIFF* tif, ttag_t tag, va_list ap)
|
||||
*va_arg(ap, int*) = sp->mode;
|
||||
break;
|
||||
case TIFFTAG_FAXFILLFUNC:
|
||||
if (sp->rw_mode == O_RDONLY)
|
||||
*va_arg(ap, TIFFFaxFillFunc*) = DecoderState(tif)->fill;
|
||||
*va_arg(ap, TIFFFaxFillFunc*) = DecoderState(tif)->fill;
|
||||
break;
|
||||
case TIFFTAG_GROUP3OPTIONS:
|
||||
case TIFFTAG_GROUP4OPTIONS:
|
||||
@@ -1269,12 +1258,8 @@ InitCCITTFax3(TIFF* tif)
|
||||
/*
|
||||
* Allocate state block so tag methods have storage to record values.
|
||||
*/
|
||||
if (tif->tif_mode == O_RDONLY)
|
||||
tif->tif_data = (tidata_t)
|
||||
_TIFFmalloc(sizeof (Fax3DecodeState));
|
||||
else
|
||||
tif->tif_data = (tidata_t)
|
||||
_TIFFmalloc(sizeof (Fax3EncodeState));
|
||||
tif->tif_data = (tidata_t)
|
||||
_TIFFmalloc(sizeof (Fax3CodecState));
|
||||
|
||||
if (tif->tif_data == NULL) {
|
||||
TIFFError("TIFFInitCCITTFax3",
|
||||
@@ -1299,12 +1284,10 @@ InitCCITTFax3(TIFF* tif)
|
||||
sp->recvparams = 0;
|
||||
sp->subaddress = NULL;
|
||||
|
||||
if (sp->rw_mode == O_RDONLY) {
|
||||
tif->tif_flags |= TIFF_NOBITREV;/* decoder does bit reversal */
|
||||
DecoderState(tif)->runs = NULL;
|
||||
TIFFSetField(tif, TIFFTAG_FAXFILLFUNC, _TIFFFax3fillruns);
|
||||
} else
|
||||
EncoderState(tif)->refline = NULL;
|
||||
tif->tif_flags |= TIFF_NOBITREV; /* decoder does bit reversal */
|
||||
DecoderState(tif)->runs = NULL;
|
||||
TIFFSetField(tif, TIFFTAG_FAXFILLFUNC, _TIFFFax3fillruns);
|
||||
EncoderState(tif)->refline = NULL;
|
||||
|
||||
/*
|
||||
* Install codec methods.
|
||||
@@ -1375,8 +1358,6 @@ Fax4Decode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
|
||||
SWAP(uint32*, sp->curruns, sp->refruns);
|
||||
buf += sp->b.rowbytes;
|
||||
occ -= sp->b.rowbytes;
|
||||
if (occ != 0)
|
||||
tif->tif_row++;
|
||||
continue;
|
||||
EOFG4:
|
||||
NeedBits16( 13, BADG4 );
|
||||
@@ -1401,7 +1382,7 @@ Fax4Decode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
|
||||
static int
|
||||
Fax4Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
|
||||
{
|
||||
Fax3EncodeState *sp = EncoderState(tif);
|
||||
Fax3CodecState *sp = EncoderState(tif);
|
||||
|
||||
(void) s;
|
||||
while ((long)cc > 0) {
|
||||
@@ -1410,8 +1391,6 @@ Fax4Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
|
||||
_TIFFmemcpy(sp->refline, bp, sp->b.rowbytes);
|
||||
bp += sp->b.rowbytes;
|
||||
cc -= sp->b.rowbytes;
|
||||
if (cc != 0)
|
||||
tif->tif_row++;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
@@ -1419,7 +1398,7 @@ Fax4Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
|
||||
static int
|
||||
Fax4PostEncode(TIFF* tif)
|
||||
{
|
||||
Fax3EncodeState *sp = EncoderState(tif);
|
||||
Fax3CodecState *sp = EncoderState(tif);
|
||||
|
||||
/* terminate strip w/ EOFB */
|
||||
Fax3PutBits(tif, EOL, 12);
|
||||
@@ -1492,8 +1471,6 @@ Fax3DecodeRLE(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
|
||||
}
|
||||
buf += sp->b.rowbytes;
|
||||
occ -= sp->b.rowbytes;
|
||||
if (occ != 0)
|
||||
tif->tif_row++;
|
||||
continue;
|
||||
EOFRLE: /* premature EOF */
|
||||
(*sp->fill)(buf, thisrun, pa, lastx);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_getimage.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_getimage.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991-1997 Sam Leffler
|
||||
@@ -42,6 +42,28 @@ static int pickTileSeparateCase(TIFFRGBAImage*);
|
||||
|
||||
static const char photoTag[] = "PhotometricInterpretation";
|
||||
|
||||
/*
|
||||
* Helper constants used in Orientation tag handling
|
||||
*/
|
||||
#define FLIP_VERTICALLY 0x01
|
||||
#define FLIP_HORIZONTALLY 0x02
|
||||
|
||||
/*
|
||||
* Color conversion constants. We will define display types here.
|
||||
*/
|
||||
|
||||
TIFFDisplay display_sRGB = {
|
||||
{ /* XYZ -> luminance matrix */
|
||||
{ 3.2410F, -1.5374F, -0.4986F },
|
||||
{ -0.9692F, 1.8760F, 0.0416F },
|
||||
{ 0.0556F, -0.2040F, 1.0570F }
|
||||
},
|
||||
100.0F, 100.0F, 100.0F, /* Light o/p for reference white */
|
||||
255, 255, 255, /* Pixel values for ref. white */
|
||||
1.0F, 1.0F, 1.0F, /* Residual light o/p for black pixel */
|
||||
2.4F, 2.4F, 2.4F, /* Gamma values for the three guns */
|
||||
};
|
||||
|
||||
/*
|
||||
* Check the image to see if TIFFReadRGBAImage can deal with it.
|
||||
* 1/0 is returned according to whether or not the image can
|
||||
@@ -117,7 +139,6 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024])
|
||||
return (0);
|
||||
}
|
||||
break;
|
||||
#ifdef CMYK_SUPPORT
|
||||
case PHOTOMETRIC_SEPARATED:
|
||||
if (td->td_inkset != INKSET_CMYK) {
|
||||
sprintf(emsg, "Sorry, can not handle separated image with %s=%d",
|
||||
@@ -130,7 +151,6 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024])
|
||||
return (0);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case PHOTOMETRIC_LOGL:
|
||||
if (td->td_compression != COMPRESSION_SGILOG) {
|
||||
sprintf(emsg, "Sorry, LogL data must have %s=%d",
|
||||
@@ -151,6 +171,8 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024])
|
||||
return (0);
|
||||
}
|
||||
break;
|
||||
case PHOTOMETRIC_CIELAB:
|
||||
break;
|
||||
default:
|
||||
sprintf(emsg, "Sorry, can not handle image with %s=%d",
|
||||
photoTag, photometric);
|
||||
@@ -162,20 +184,22 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024])
|
||||
void
|
||||
TIFFRGBAImageEnd(TIFFRGBAImage* img)
|
||||
{
|
||||
if (img->Map)
|
||||
_TIFFfree(img->Map), img->Map = NULL;
|
||||
if (img->BWmap)
|
||||
_TIFFfree(img->BWmap), img->BWmap = NULL;
|
||||
if (img->PALmap)
|
||||
_TIFFfree(img->PALmap), img->PALmap = NULL;
|
||||
if (img->ycbcr)
|
||||
_TIFFfree(img->ycbcr), img->ycbcr = NULL;
|
||||
if (img->Map)
|
||||
_TIFFfree(img->Map), img->Map = NULL;
|
||||
if (img->BWmap)
|
||||
_TIFFfree(img->BWmap), img->BWmap = NULL;
|
||||
if (img->PALmap)
|
||||
_TIFFfree(img->PALmap), img->PALmap = NULL;
|
||||
if (img->ycbcr)
|
||||
_TIFFfree(img->ycbcr), img->ycbcr = NULL;
|
||||
if (img->cielab)
|
||||
_TIFFfree(img->cielab), img->cielab = NULL;
|
||||
|
||||
if( img->redcmap ) {
|
||||
_TIFFfree( img->redcmap );
|
||||
_TIFFfree( img->greencmap );
|
||||
_TIFFfree( img->bluecmap );
|
||||
}
|
||||
if( img->redcmap ) {
|
||||
_TIFFfree( img->redcmap );
|
||||
_TIFFfree( img->greencmap );
|
||||
_TIFFfree( img->bluecmap );
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -206,6 +230,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024])
|
||||
img->redcmap = NULL;
|
||||
img->greencmap = NULL;
|
||||
img->bluecmap = NULL;
|
||||
img->req_orientation = ORIENTATION_BOTLEFT; /* It is the default */
|
||||
|
||||
img->tif = tif;
|
||||
img->stoponerr = stop;
|
||||
@@ -215,7 +240,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024])
|
||||
case 8: case 16:
|
||||
break;
|
||||
default:
|
||||
sprintf(emsg, "Sorry, can not image with %d-bit samples",
|
||||
sprintf(emsg, "Sorry, can not handle images with %d-bit samples",
|
||||
img->bitspersample);
|
||||
return (0);
|
||||
}
|
||||
@@ -375,6 +400,8 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024])
|
||||
img->photometric = PHOTOMETRIC_RGB; /* little white lie */
|
||||
img->bitspersample = 8;
|
||||
break;
|
||||
case PHOTOMETRIC_CIELAB:
|
||||
break;
|
||||
default:
|
||||
sprintf(emsg, "Sorry, can not handle image with %s=%d",
|
||||
photoTag, img->photometric);
|
||||
@@ -384,6 +411,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024])
|
||||
img->BWmap = NULL;
|
||||
img->PALmap = NULL;
|
||||
img->ycbcr = NULL;
|
||||
img->cielab = NULL;
|
||||
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &img->width);
|
||||
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &img->height);
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &img->orientation);
|
||||
@@ -414,17 +442,21 @@ TIFFRGBAImageGet(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the specified image into an ABGR-format raster.
|
||||
* Read the specified image into an ABGR-format rastertaking in account
|
||||
* specified orientation.
|
||||
*/
|
||||
int
|
||||
TIFFReadRGBAImage(TIFF* tif,
|
||||
uint32 rwidth, uint32 rheight, uint32* raster, int stop)
|
||||
TIFFReadRGBAImageOriented(TIFF* tif,
|
||||
uint32 rwidth, uint32 rheight, uint32* raster,
|
||||
int orientation, int stop)
|
||||
{
|
||||
char emsg[1024];
|
||||
TIFFRGBAImage img;
|
||||
int ok;
|
||||
|
||||
if (TIFFRGBAImageOK(tif, emsg) && TIFFRGBAImageBegin(&img, tif, stop, emsg)) {
|
||||
if (TIFFRGBAImageOK(tif, emsg) &&
|
||||
TIFFRGBAImageBegin(&img, tif, stop, emsg)) {
|
||||
img.req_orientation = orientation;
|
||||
/* XXX verify rwidth and rheight against width and height */
|
||||
ok = TIFFRGBAImageGet(&img, raster+(rheight-img.height)*rwidth,
|
||||
rwidth, img.height);
|
||||
@@ -436,34 +468,77 @@ TIFFReadRGBAImage(TIFF* tif,
|
||||
return (ok);
|
||||
}
|
||||
|
||||
static uint32
|
||||
setorientation(TIFFRGBAImage* img, uint32 h)
|
||||
/*
|
||||
* Read the specified image into an ABGR-format raster. Use bottom left
|
||||
* origin for raster by default.
|
||||
*/
|
||||
int
|
||||
TIFFReadRGBAImage(TIFF* tif,
|
||||
uint32 rwidth, uint32 rheight, uint32* raster, int stop)
|
||||
{
|
||||
TIFF* tif = img->tif;
|
||||
uint32 y;
|
||||
return TIFFReadRGBAImageOriented(tif, rwidth, rheight, raster,
|
||||
ORIENTATION_BOTLEFT, stop);
|
||||
}
|
||||
|
||||
switch (img->orientation) {
|
||||
case ORIENTATION_BOTRIGHT:
|
||||
case ORIENTATION_RIGHTBOT: /* XXX */
|
||||
case ORIENTATION_LEFTBOT: /* XXX */
|
||||
TIFFWarning(TIFFFileName(tif), "using bottom-left orientation");
|
||||
img->orientation = ORIENTATION_BOTLEFT;
|
||||
/* fall thru... */
|
||||
case ORIENTATION_BOTLEFT:
|
||||
y = 0;
|
||||
break;
|
||||
case ORIENTATION_TOPRIGHT:
|
||||
case ORIENTATION_RIGHTTOP: /* XXX */
|
||||
case ORIENTATION_LEFTTOP: /* XXX */
|
||||
default:
|
||||
TIFFWarning(TIFFFileName(tif), "using top-left orientation");
|
||||
img->orientation = ORIENTATION_TOPLEFT;
|
||||
/* fall thru... */
|
||||
case ORIENTATION_TOPLEFT:
|
||||
y = h-1;
|
||||
break;
|
||||
}
|
||||
return (y);
|
||||
static int
|
||||
setorientation(TIFFRGBAImage* img)
|
||||
{
|
||||
switch (img->orientation) {
|
||||
case ORIENTATION_TOPLEFT:
|
||||
case ORIENTATION_LEFTTOP:
|
||||
if (img->req_orientation == ORIENTATION_TOPRIGHT ||
|
||||
img->req_orientation == ORIENTATION_RIGHTTOP)
|
||||
return FLIP_HORIZONTALLY;
|
||||
else if (img->req_orientation == ORIENTATION_BOTRIGHT ||
|
||||
img->req_orientation == ORIENTATION_RIGHTBOT)
|
||||
return FLIP_HORIZONTALLY | FLIP_VERTICALLY;
|
||||
else if (img->req_orientation == ORIENTATION_BOTLEFT ||
|
||||
img->req_orientation == ORIENTATION_LEFTBOT)
|
||||
return FLIP_VERTICALLY;
|
||||
else
|
||||
return 0;
|
||||
case ORIENTATION_TOPRIGHT:
|
||||
case ORIENTATION_RIGHTTOP:
|
||||
if (img->req_orientation == ORIENTATION_TOPLEFT ||
|
||||
img->req_orientation == ORIENTATION_LEFTTOP)
|
||||
return FLIP_HORIZONTALLY;
|
||||
else if (img->req_orientation == ORIENTATION_BOTRIGHT ||
|
||||
img->req_orientation == ORIENTATION_RIGHTBOT)
|
||||
return FLIP_VERTICALLY;
|
||||
else if (img->req_orientation == ORIENTATION_BOTLEFT ||
|
||||
img->req_orientation == ORIENTATION_LEFTBOT)
|
||||
return FLIP_HORIZONTALLY | FLIP_VERTICALLY;
|
||||
else
|
||||
return 0;
|
||||
case ORIENTATION_BOTRIGHT:
|
||||
case ORIENTATION_RIGHTBOT:
|
||||
if (img->req_orientation == ORIENTATION_TOPLEFT ||
|
||||
img->req_orientation == ORIENTATION_LEFTTOP)
|
||||
return FLIP_HORIZONTALLY | FLIP_VERTICALLY;
|
||||
else if (img->req_orientation == ORIENTATION_TOPRIGHT ||
|
||||
img->req_orientation == ORIENTATION_RIGHTTOP)
|
||||
return FLIP_VERTICALLY;
|
||||
else if (img->req_orientation == ORIENTATION_BOTLEFT ||
|
||||
img->req_orientation == ORIENTATION_LEFTBOT)
|
||||
return FLIP_HORIZONTALLY;
|
||||
else
|
||||
return 0;
|
||||
case ORIENTATION_BOTLEFT:
|
||||
case ORIENTATION_LEFTBOT:
|
||||
if (img->req_orientation == ORIENTATION_TOPLEFT ||
|
||||
img->req_orientation == ORIENTATION_LEFTTOP)
|
||||
return FLIP_VERTICALLY;
|
||||
else if (img->req_orientation == ORIENTATION_TOPRIGHT ||
|
||||
img->req_orientation == ORIENTATION_RIGHTTOP)
|
||||
return FLIP_HORIZONTALLY | FLIP_VERTICALLY;
|
||||
else if (img->req_orientation == ORIENTATION_BOTRIGHT ||
|
||||
img->req_orientation == ORIENTATION_RIGHTBOT)
|
||||
return FLIP_HORIZONTALLY;
|
||||
else
|
||||
return 0;
|
||||
default: /* NOTREACHED */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -477,13 +552,13 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
{
|
||||
TIFF* tif = img->tif;
|
||||
tileContigRoutine put = img->put.contig;
|
||||
uint16 orientation;
|
||||
uint32 col, row, y, rowstoread, ret = 1;
|
||||
uint32 col, row, y, rowstoread;
|
||||
uint32 pos;
|
||||
uint32 tw, th;
|
||||
u_char* buf;
|
||||
int32 fromskew, toskew;
|
||||
uint32 nrow;
|
||||
int ret = 1, flip;
|
||||
|
||||
buf = (u_char*) _TIFFmalloc(TIFFTileSize(tif));
|
||||
if (buf == 0) {
|
||||
@@ -492,9 +567,17 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
}
|
||||
TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
|
||||
TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
|
||||
y = setorientation(img, h);
|
||||
orientation = img->orientation;
|
||||
toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? tw+w : tw-w);
|
||||
|
||||
flip = setorientation(img);
|
||||
if (flip & FLIP_VERTICALLY) {
|
||||
y = h - 1;
|
||||
toskew = -(int32)(tw + w);
|
||||
}
|
||||
else {
|
||||
y = 0;
|
||||
toskew = -(int32)(tw - w);
|
||||
}
|
||||
|
||||
for (row = 0; row < h; row += nrow)
|
||||
{
|
||||
rowstoread = th - (row + img->row_offset) % th;
|
||||
@@ -525,13 +608,28 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
{
|
||||
(*put)(img, raster+y*w+col, col, y, tw, nrow, 0, toskew, buf + pos);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
y += (orientation == ORIENTATION_TOPLEFT ? -(int32) nrow : (int32) nrow);
|
||||
y += (flip & FLIP_VERTICALLY ? -(int32) nrow : (int32) nrow);
|
||||
}
|
||||
_TIFFfree(buf);
|
||||
|
||||
if (flip & FLIP_HORIZONTALLY) {
|
||||
uint32 line;
|
||||
|
||||
for (line = 0; line < h; line++) {
|
||||
uint32 *left = raster + (line * w);
|
||||
uint32 *right = left + w - 1;
|
||||
|
||||
while ( left < right ) {
|
||||
uint32 temp = *left;
|
||||
*left = *right;
|
||||
*right = temp;
|
||||
left++, right--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
@@ -546,7 +644,6 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
{
|
||||
TIFF* tif = img->tif;
|
||||
tileSeparateRoutine put = img->put.separate;
|
||||
uint16 orientation;
|
||||
uint32 col, row, y, rowstoread;
|
||||
uint32 pos;
|
||||
uint32 tw, th;
|
||||
@@ -559,7 +656,7 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
int32 fromskew, toskew;
|
||||
int alpha = img->alpha;
|
||||
uint32 nrow;
|
||||
int ret = 1;
|
||||
int ret = 1, flip;
|
||||
|
||||
tilesize = TIFFTileSize(tif);
|
||||
buf = (u_char*) _TIFFmalloc(4*tilesize);
|
||||
@@ -575,9 +672,17 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
memset(a, 0xff, tilesize);
|
||||
TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw);
|
||||
TIFFGetField(tif, TIFFTAG_TILELENGTH, &th);
|
||||
y = setorientation(img, h);
|
||||
orientation = img->orientation;
|
||||
toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? tw+w : tw-w);
|
||||
|
||||
flip = setorientation(img);
|
||||
if (flip & FLIP_VERTICALLY) {
|
||||
y = h - 1;
|
||||
toskew = -(int32)(tw + w);
|
||||
}
|
||||
else {
|
||||
y = 0;
|
||||
toskew = -(int32)(tw - w);
|
||||
}
|
||||
|
||||
for (row = 0; row < h; row += nrow)
|
||||
{
|
||||
rowstoread = th - (row + img->row_offset) % th;
|
||||
@@ -630,8 +735,25 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
}
|
||||
}
|
||||
|
||||
y += (orientation == ORIENTATION_TOPLEFT ?-(int32) nrow : (int32) nrow);
|
||||
y += (flip & FLIP_VERTICALLY ?-(int32) nrow : (int32) nrow);
|
||||
}
|
||||
|
||||
if (flip & FLIP_HORIZONTALLY) {
|
||||
uint32 line;
|
||||
|
||||
for (line = 0; line < h; line++) {
|
||||
uint32 *left = raster + (line * w);
|
||||
uint32 *right = left + w - 1;
|
||||
|
||||
while ( left < right ) {
|
||||
uint32 temp = *left;
|
||||
*left = *right;
|
||||
*right = temp;
|
||||
left++, right--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_TIFFfree(buf);
|
||||
return (ret);
|
||||
}
|
||||
@@ -647,7 +769,6 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
{
|
||||
TIFF* tif = img->tif;
|
||||
tileContigRoutine put = img->put.contig;
|
||||
uint16 orientation;
|
||||
uint32 row, y, nrow, rowstoread;
|
||||
uint32 pos;
|
||||
u_char* buf;
|
||||
@@ -655,16 +776,24 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
uint32 imagewidth = img->width;
|
||||
tsize_t scanline;
|
||||
int32 fromskew, toskew;
|
||||
int ret = 1;
|
||||
int ret = 1, flip;
|
||||
|
||||
buf = (u_char*) _TIFFmalloc(TIFFStripSize(tif));
|
||||
if (buf == 0) {
|
||||
TIFFError(TIFFFileName(tif), "No space for strip buffer");
|
||||
return (0);
|
||||
}
|
||||
y = setorientation(img, h);
|
||||
orientation = img->orientation;
|
||||
toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? w+w : w-w);
|
||||
|
||||
flip = setorientation(img);
|
||||
if (flip & FLIP_VERTICALLY) {
|
||||
y = h - 1;
|
||||
toskew = -(int32)(w + w);
|
||||
}
|
||||
else {
|
||||
y = 0;
|
||||
toskew = -(int32)(w - w);
|
||||
}
|
||||
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
|
||||
scanline = TIFFScanlineSize(tif);
|
||||
fromskew = (w < imagewidth ? imagewidth - w : 0);
|
||||
@@ -684,8 +813,25 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
|
||||
pos = ((row + img->row_offset) % rowsperstrip) * scanline;
|
||||
(*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, buf + pos);
|
||||
y += (orientation == ORIENTATION_TOPLEFT ?-(int32) nrow : (int32) nrow);
|
||||
y += (flip & FLIP_VERTICALLY ? -(int32) nrow : (int32) nrow);
|
||||
}
|
||||
|
||||
if (flip & FLIP_HORIZONTALLY) {
|
||||
uint32 line;
|
||||
|
||||
for (line = 0; line < h; line++) {
|
||||
uint32 *left = raster + (line * w);
|
||||
uint32 *right = left + w - 1;
|
||||
|
||||
while ( left < right ) {
|
||||
uint32 temp = *left;
|
||||
*left = *right;
|
||||
*right = temp;
|
||||
left++, right--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_TIFFfree(buf);
|
||||
return (ret);
|
||||
}
|
||||
@@ -701,7 +847,6 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
{
|
||||
TIFF* tif = img->tif;
|
||||
tileSeparateRoutine put = img->put.separate;
|
||||
uint16 orientation;
|
||||
u_char *buf;
|
||||
u_char *r, *g, *b, *a;
|
||||
uint32 row, y, nrow, rowstoread;
|
||||
@@ -712,7 +857,7 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
tsize_t stripsize;
|
||||
int32 fromskew, toskew;
|
||||
int alpha = img->alpha;
|
||||
int ret = 1;
|
||||
int ret = 1, flip;
|
||||
|
||||
stripsize = TIFFStripSize(tif);
|
||||
r = buf = (u_char *)_TIFFmalloc(4*stripsize);
|
||||
@@ -725,9 +870,17 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
a = b + stripsize;
|
||||
if (!alpha)
|
||||
memset(a, 0xff, stripsize);
|
||||
y = setorientation(img, h);
|
||||
orientation = img->orientation;
|
||||
toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? w+w : w-w);
|
||||
|
||||
flip = setorientation(img);
|
||||
if (flip & FLIP_VERTICALLY) {
|
||||
y = h - 1;
|
||||
toskew = -(int32)(w + w);
|
||||
}
|
||||
else {
|
||||
y = 0;
|
||||
toskew = -(int32)(w - w);
|
||||
}
|
||||
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
|
||||
scanline = TIFFScanlineSize(tif);
|
||||
fromskew = (w < imagewidth ? imagewidth - w : 0);
|
||||
@@ -769,8 +922,25 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
pos = ((row + img->row_offset) % rowsperstrip) * scanline;
|
||||
(*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, r + pos, g + pos,
|
||||
b + pos, a + pos);
|
||||
y += (orientation == ORIENTATION_TOPLEFT ? -(int32) nrow : (int32) nrow);
|
||||
y += (flip & FLIP_VERTICALLY ? -(int32) nrow : (int32) nrow);
|
||||
}
|
||||
|
||||
if (flip & FLIP_HORIZONTALLY) {
|
||||
uint32 line;
|
||||
|
||||
for (line = 0; line < h; line++) {
|
||||
uint32 *left = raster + (line * w);
|
||||
uint32 *right = left + w - 1;
|
||||
|
||||
while ( left < right ) {
|
||||
uint32 temp = *left;
|
||||
*left = *right;
|
||||
*right = temp;
|
||||
left++, right--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_TIFFfree(buf);
|
||||
return (ret);
|
||||
}
|
||||
@@ -1374,25 +1544,39 @@ DECLARESepPutFunc(putRGBUAseparate16bittile)
|
||||
}
|
||||
|
||||
/*
|
||||
* YCbCr -> RGB conversion and packing routines. The colorspace
|
||||
* conversion algorithm comes from the IJG v5a code; see below
|
||||
* for more information on how it works.
|
||||
* 8-bit packed CIE L*a*b 1976 samples => RGB
|
||||
*/
|
||||
DECLAREContigPutFunc(putcontig8bitCIELab)
|
||||
{
|
||||
float X, Y, Z;
|
||||
uint32 r, g, b;
|
||||
(void) y;
|
||||
fromskew *= 3;
|
||||
while (h-- > 0) {
|
||||
for (x = w; x-- > 0;) {
|
||||
TIFFCIELabToXYZ(img->cielab,
|
||||
(u_char)pp[0],
|
||||
(signed char)pp[1],
|
||||
(signed char)pp[2],
|
||||
&X, &Y, &Z);
|
||||
TIFFXYZToRGB(img->cielab, X, Y, Z, &r, &g, &b);
|
||||
*cp++ = PACK(r, g, b);
|
||||
pp += 3;
|
||||
}
|
||||
cp += toskew;
|
||||
pp += fromskew;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* YCbCr -> RGB conversion and packing routines.
|
||||
*/
|
||||
|
||||
#define YCbCrtoRGB(dst, yc) { \
|
||||
int Y = (yc); \
|
||||
dst = PACK( \
|
||||
clamptab[Y+Crrtab[Cr]], \
|
||||
clamptab[Y + (int)((Cbgtab[Cb]+Crgtab[Cr])>>16)], \
|
||||
clamptab[Y+Cbbtab[Cb]]); \
|
||||
#define YCbCrtoRGB(dst, Y) { \
|
||||
uint32 r, g, b; \
|
||||
TIFFYCbCrtoRGB(img->ycbcr, (Y), Cb, Cr, &r, &g, &b); \
|
||||
dst = PACK(r, g, b); \
|
||||
}
|
||||
#define YCbCrSetup \
|
||||
TIFFYCbCrToRGB* ycbcr = img->ycbcr; \
|
||||
int* Crrtab = ycbcr->Cr_r_tab; \
|
||||
int* Cbbtab = ycbcr->Cb_b_tab; \
|
||||
int32* Crgtab = ycbcr->Cr_g_tab; \
|
||||
int32* Cbgtab = ycbcr->Cb_g_tab; \
|
||||
TIFFRGBValue* clamptab = ycbcr->clamptab
|
||||
|
||||
/*
|
||||
* 8-bit packed YCbCr samples => RGB
|
||||
@@ -1414,13 +1598,11 @@ static void putcontig8bitYCbCrGenericTile(
|
||||
int v_group )
|
||||
|
||||
{
|
||||
YCbCrSetup;
|
||||
|
||||
uint32* cp1 = cp+w+toskew;
|
||||
uint32* cp2 = cp1+w+toskew;
|
||||
uint32* cp3 = cp2+w+toskew;
|
||||
int32 incr = 3*w+4*toskew;
|
||||
int Cb, Cr;
|
||||
int32 Cb, Cr;
|
||||
int group_size = v_group * h_group + 2;
|
||||
|
||||
(void) y;
|
||||
@@ -1477,7 +1659,6 @@ static void putcontig8bitYCbCrGenericTile(
|
||||
*/
|
||||
DECLAREContigPutFunc(putcontig8bitYCbCr44tile)
|
||||
{
|
||||
YCbCrSetup;
|
||||
uint32* cp1 = cp+w+toskew;
|
||||
uint32* cp2 = cp1+w+toskew;
|
||||
uint32* cp3 = cp2+w+toskew;
|
||||
@@ -1490,8 +1671,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr44tile)
|
||||
for (; h >= 4; h -= 4) {
|
||||
x = w>>2;
|
||||
do {
|
||||
int Cb = pp[16];
|
||||
int Cr = pp[17];
|
||||
int32 Cb = pp[16];
|
||||
int32 Cr = pp[17];
|
||||
|
||||
YCbCrtoRGB(cp [0], pp[ 0]);
|
||||
YCbCrtoRGB(cp [1], pp[ 1]);
|
||||
@@ -1519,8 +1700,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr44tile)
|
||||
} else {
|
||||
while (h > 0) {
|
||||
for (x = w; x > 0;) {
|
||||
int Cb = pp[16];
|
||||
int Cr = pp[17];
|
||||
int32 Cb = pp[16];
|
||||
int32 Cr = pp[17];
|
||||
switch (x) {
|
||||
default:
|
||||
switch (h) {
|
||||
@@ -1575,7 +1756,6 @@ DECLAREContigPutFunc(putcontig8bitYCbCr44tile)
|
||||
*/
|
||||
DECLAREContigPutFunc(putcontig8bitYCbCr42tile)
|
||||
{
|
||||
YCbCrSetup;
|
||||
uint32* cp1 = cp+w+toskew;
|
||||
int32 incr = 2*toskew+w;
|
||||
|
||||
@@ -1585,8 +1765,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr42tile)
|
||||
for (; h >= 2; h -= 2) {
|
||||
x = w>>2;
|
||||
do {
|
||||
int Cb = pp[8];
|
||||
int Cr = pp[9];
|
||||
int32 Cb = pp[8];
|
||||
int32 Cr = pp[9];
|
||||
|
||||
YCbCrtoRGB(cp [0], pp[0]);
|
||||
YCbCrtoRGB(cp [1], pp[1]);
|
||||
@@ -1606,8 +1786,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr42tile)
|
||||
} else {
|
||||
while (h > 0) {
|
||||
for (x = w; x > 0;) {
|
||||
int Cb = pp[8];
|
||||
int Cr = pp[9];
|
||||
int32 Cb = pp[8];
|
||||
int32 Cr = pp[9];
|
||||
switch (x) {
|
||||
default:
|
||||
switch (h) {
|
||||
@@ -1654,15 +1834,13 @@ DECLAREContigPutFunc(putcontig8bitYCbCr42tile)
|
||||
*/
|
||||
DECLAREContigPutFunc(putcontig8bitYCbCr41tile)
|
||||
{
|
||||
YCbCrSetup;
|
||||
|
||||
(void) y;
|
||||
/* XXX adjust fromskew */
|
||||
do {
|
||||
x = w>>2;
|
||||
do {
|
||||
int Cb = pp[4];
|
||||
int Cr = pp[5];
|
||||
int32 Cb = pp[4];
|
||||
int32 Cr = pp[5];
|
||||
|
||||
YCbCrtoRGB(cp [0], pp[0]);
|
||||
YCbCrtoRGB(cp [1], pp[1]);
|
||||
@@ -1675,8 +1853,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr41tile)
|
||||
|
||||
if( (w&3) != 0 )
|
||||
{
|
||||
int Cb = pp[4];
|
||||
int Cr = pp[5];
|
||||
int32 Cb = pp[4];
|
||||
int32 Cr = pp[5];
|
||||
|
||||
switch( (w&3) ) {
|
||||
case 3: YCbCrtoRGB(cp [2], pp[2]);
|
||||
@@ -1700,7 +1878,6 @@ DECLAREContigPutFunc(putcontig8bitYCbCr41tile)
|
||||
*/
|
||||
DECLAREContigPutFunc(putcontig8bitYCbCr22tile)
|
||||
{
|
||||
YCbCrSetup;
|
||||
uint32* cp1 = cp+w+toskew;
|
||||
int32 incr = 2*toskew+w;
|
||||
|
||||
@@ -1710,8 +1887,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr22tile)
|
||||
for (; h >= 2; h -= 2) {
|
||||
x = w>>1;
|
||||
do {
|
||||
int Cb = pp[4];
|
||||
int Cr = pp[5];
|
||||
int32 Cb = pp[4];
|
||||
int32 Cr = pp[5];
|
||||
|
||||
YCbCrtoRGB(cp [0], pp[0]);
|
||||
YCbCrtoRGB(cp [1], pp[1]);
|
||||
@@ -1727,8 +1904,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr22tile)
|
||||
} else {
|
||||
while (h > 0) {
|
||||
for (x = w; x > 0;) {
|
||||
int Cb = pp[4];
|
||||
int Cr = pp[5];
|
||||
int32 Cb = pp[4];
|
||||
int32 Cr = pp[5];
|
||||
switch (x) {
|
||||
default:
|
||||
switch (h) {
|
||||
@@ -1765,15 +1942,13 @@ DECLAREContigPutFunc(putcontig8bitYCbCr22tile)
|
||||
*/
|
||||
DECLAREContigPutFunc(putcontig8bitYCbCr21tile)
|
||||
{
|
||||
YCbCrSetup;
|
||||
|
||||
(void) y;
|
||||
fromskew = (fromskew * 4) / 2;
|
||||
do {
|
||||
x = w>>1;
|
||||
do {
|
||||
int Cb = pp[2];
|
||||
int Cr = pp[3];
|
||||
int32 Cb = pp[2];
|
||||
int32 Cr = pp[3];
|
||||
|
||||
YCbCrtoRGB(cp[0], pp[0]);
|
||||
YCbCrtoRGB(cp[1], pp[1]);
|
||||
@@ -1784,8 +1959,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr21tile)
|
||||
|
||||
if( (w&1) != 0 )
|
||||
{
|
||||
int Cb = pp[2];
|
||||
int Cr = pp[3];
|
||||
int32 Cb = pp[2];
|
||||
int32 Cr = pp[3];
|
||||
|
||||
YCbCrtoRGB(cp [0], pp[0]);
|
||||
|
||||
@@ -1803,15 +1978,13 @@ DECLAREContigPutFunc(putcontig8bitYCbCr21tile)
|
||||
*/
|
||||
DECLAREContigPutFunc(putcontig8bitYCbCr11tile)
|
||||
{
|
||||
YCbCrSetup;
|
||||
|
||||
(void) y;
|
||||
fromskew *= 3;
|
||||
do {
|
||||
x = w; /* was x = w>>1; patched 2000/09/25 [email protected] */
|
||||
do {
|
||||
int Cb = pp[1];
|
||||
int Cr = pp[2];
|
||||
int32 Cb = pp[1];
|
||||
int32 Cr = pp[2];
|
||||
|
||||
YCbCrtoRGB(*cp++, pp[0]);
|
||||
|
||||
@@ -1821,125 +1994,87 @@ DECLAREContigPutFunc(putcontig8bitYCbCr11tile)
|
||||
pp += fromskew;
|
||||
} while (--h);
|
||||
}
|
||||
#undef YCbCrSetup
|
||||
#undef YCbCrtoRGB
|
||||
|
||||
#define LumaRed coeffs[0]
|
||||
#define LumaGreen coeffs[1]
|
||||
#define LumaBlue coeffs[2]
|
||||
#define SHIFT 16
|
||||
#define FIX(x) ((int32)((x) * (1L<<SHIFT) + 0.5))
|
||||
#define ONE_HALF ((int32)(1<<(SHIFT-1)))
|
||||
|
||||
/*
|
||||
* Initialize the YCbCr->RGB conversion tables. The conversion
|
||||
* is done according to the 6.0 spec:
|
||||
*
|
||||
* R = Y + Cr*(2 - 2*LumaRed)
|
||||
* B = Y + Cb*(2 - 2*LumaBlue)
|
||||
* G = Y
|
||||
* - LumaBlue*Cb*(2-2*LumaBlue)/LumaGreen
|
||||
* - LumaRed*Cr*(2-2*LumaRed)/LumaGreen
|
||||
*
|
||||
* To avoid floating point arithmetic the fractional constants that
|
||||
* come out of the equations are represented as fixed point values
|
||||
* in the range 0...2^16. We also eliminate multiplications by
|
||||
* pre-calculating possible values indexed by Cb and Cr (this code
|
||||
* assumes conversion is being done for 8-bit samples).
|
||||
*/
|
||||
static void
|
||||
TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, TIFF* tif)
|
||||
{
|
||||
TIFFRGBValue* clamptab;
|
||||
float* coeffs;
|
||||
int i;
|
||||
|
||||
clamptab = (TIFFRGBValue*)(
|
||||
(tidata_t) ycbcr+TIFFroundup(sizeof (TIFFYCbCrToRGB), sizeof (long)));
|
||||
_TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */
|
||||
ycbcr->clamptab = (clamptab += 256);
|
||||
for (i = 0; i < 256; i++)
|
||||
clamptab[i] = i;
|
||||
_TIFFmemset(clamptab+256, 255, 2*256); /* v > 255 => 255 */
|
||||
TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRCOEFFICIENTS, &coeffs);
|
||||
_TIFFmemcpy(ycbcr->coeffs, coeffs, 3*sizeof (float));
|
||||
{ float f1 = 2-2*LumaRed; int32 D1 = FIX(f1);
|
||||
float f2 = LumaRed*f1/LumaGreen; int32 D2 = -FIX(f2);
|
||||
float f3 = 2-2*LumaBlue; int32 D3 = FIX(f3);
|
||||
float f4 = LumaBlue*f3/LumaGreen; int32 D4 = -FIX(f4);
|
||||
int x;
|
||||
|
||||
ycbcr->Cr_r_tab = (int*) (clamptab + 3*256);
|
||||
ycbcr->Cb_b_tab = ycbcr->Cr_r_tab + 256;
|
||||
ycbcr->Cr_g_tab = (int32*) (ycbcr->Cb_b_tab + 256);
|
||||
ycbcr->Cb_g_tab = ycbcr->Cr_g_tab + 256;
|
||||
/*
|
||||
* i is the actual input pixel value in the range 0..255
|
||||
* Cb and Cr values are in the range -128..127 (actually
|
||||
* they are in a range defined by the ReferenceBlackWhite
|
||||
* tag) so there is some range shifting to do here when
|
||||
* constructing tables indexed by the raw pixel data.
|
||||
*
|
||||
* XXX handle ReferenceBlackWhite correctly to calculate
|
||||
* Cb/Cr values to use in constructing the tables.
|
||||
*/
|
||||
for (i = 0, x = -128; i < 256; i++, x++) {
|
||||
ycbcr->Cr_r_tab[i] = (int)((D1*x + ONE_HALF)>>SHIFT);
|
||||
ycbcr->Cb_b_tab[i] = (int)((D3*x + ONE_HALF)>>SHIFT);
|
||||
ycbcr->Cr_g_tab[i] = D2*x;
|
||||
ycbcr->Cb_g_tab[i] = D4*x + ONE_HALF;
|
||||
}
|
||||
}
|
||||
}
|
||||
#undef SHIFT
|
||||
#undef ONE_HALF
|
||||
#undef FIX
|
||||
#undef LumaBlue
|
||||
#undef LumaGreen
|
||||
#undef LumaRed
|
||||
|
||||
static tileContigRoutine
|
||||
initYCbCrConversion(TIFFRGBAImage* img)
|
||||
{
|
||||
uint16 hs, vs;
|
||||
static char module[] = "initCIELabConversion";
|
||||
|
||||
float *luma, *refBlackWhite;
|
||||
uint16 hs, vs;
|
||||
|
||||
if (img->ycbcr == NULL) {
|
||||
img->ycbcr = (TIFFYCbCrToRGB*) _TIFFmalloc(
|
||||
TIFFroundup(sizeof (TIFFYCbCrToRGB), sizeof (long))
|
||||
+ 4*256*sizeof (TIFFRGBValue)
|
||||
+ 2*256*sizeof (int)
|
||||
+ 2*256*sizeof (int32)
|
||||
);
|
||||
if (img->ycbcr == NULL) {
|
||||
TIFFError(TIFFFileName(img->tif),
|
||||
"No space for YCbCr->RGB conversion state");
|
||||
return (NULL);
|
||||
img->ycbcr = (TIFFYCbCrToRGB*) _TIFFmalloc(
|
||||
TIFFroundup(sizeof (TIFFYCbCrToRGB), sizeof (long))
|
||||
+ 4*256*sizeof (TIFFRGBValue)
|
||||
+ 2*256*sizeof (int)
|
||||
+ 3*256*sizeof (int32)
|
||||
);
|
||||
if (img->ycbcr == NULL) {
|
||||
TIFFError(module,
|
||||
"No space for YCbCr->RGB conversion state");
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
TIFFYCbCrToRGBInit(img->ycbcr, img->tif);
|
||||
} else {
|
||||
float* coeffs;
|
||||
|
||||
TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRCOEFFICIENTS, &coeffs);
|
||||
if (_TIFFmemcmp(coeffs, img->ycbcr->coeffs, 3*sizeof (float)) != 0)
|
||||
TIFFYCbCrToRGBInit(img->ycbcr, img->tif);
|
||||
}
|
||||
/*
|
||||
* The 6.0 spec says that subsampling must be
|
||||
* one of 1, 2, or 4, and that vertical subsampling
|
||||
* must always be <= horizontal subsampling; so
|
||||
* there are only a few possibilities and we just
|
||||
* enumerate the cases.
|
||||
*/
|
||||
TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs);
|
||||
switch ((hs<<4)|vs) {
|
||||
case 0x44: return (putcontig8bitYCbCr44tile);
|
||||
case 0x42: return (putcontig8bitYCbCr42tile);
|
||||
case 0x41: return (putcontig8bitYCbCr41tile);
|
||||
case 0x22: return (putcontig8bitYCbCr22tile);
|
||||
case 0x21: return (putcontig8bitYCbCr21tile);
|
||||
case 0x11: return (putcontig8bitYCbCr11tile);
|
||||
}
|
||||
return (NULL);
|
||||
TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRCOEFFICIENTS, &luma);
|
||||
TIFFGetFieldDefaulted(img->tif, TIFFTAG_REFERENCEBLACKWHITE,
|
||||
&refBlackWhite);
|
||||
if (TIFFYCbCrToRGBInit(img->ycbcr, luma, refBlackWhite) < 0)
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* The 6.0 spec says that subsampling must be
|
||||
* one of 1, 2, or 4, and that vertical subsampling
|
||||
* must always be <= horizontal subsampling; so
|
||||
* there are only a few possibilities and we just
|
||||
* enumerate the cases.
|
||||
*/
|
||||
TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs);
|
||||
switch ((hs<<4)|vs) {
|
||||
case 0x44: return (putcontig8bitYCbCr44tile);
|
||||
case 0x42: return (putcontig8bitYCbCr42tile);
|
||||
case 0x41: return (putcontig8bitYCbCr41tile);
|
||||
case 0x22: return (putcontig8bitYCbCr22tile);
|
||||
case 0x21: return (putcontig8bitYCbCr21tile);
|
||||
case 0x11: return (putcontig8bitYCbCr11tile);
|
||||
}
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static tileContigRoutine
|
||||
initCIELabConversion(TIFFRGBAImage* img)
|
||||
{
|
||||
static char module[] = "initCIELabConversion";
|
||||
|
||||
float *whitePoint;
|
||||
float refWhite[3];
|
||||
|
||||
if (!img->cielab) {
|
||||
img->cielab = (TIFFCIELabToRGB *)
|
||||
_TIFFmalloc(sizeof(TIFFCIELabToRGB));
|
||||
if (!img->cielab) {
|
||||
TIFFError(module,
|
||||
"No space for CIE L*a*b*->RGB conversion state.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
TIFFGetFieldDefaulted(img->tif, TIFFTAG_WHITEPOINT, &whitePoint);
|
||||
refWhite[1] = 100.0F;
|
||||
refWhite[0] = whitePoint[0] / whitePoint[1] * refWhite[1];
|
||||
refWhite[2] = (1.0F - whitePoint[0] - whitePoint[1])
|
||||
/ whitePoint[1] * refWhite[1];
|
||||
if (TIFFCIELabToRGBInit(img->cielab, &display_sRGB, refWhite) < 0) {
|
||||
TIFFError(module,
|
||||
"Failed to initialize CIE L*a*b*->RGB conversion state.");
|
||||
_TIFFfree(img->cielab);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return putcontig8bitCIELab;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2106,7 +2241,7 @@ makecmap(TIFFRGBAImage* img)
|
||||
for (i = 0; i < 256; i++) {
|
||||
TIFFRGBValue c;
|
||||
img->PALmap[i] = p;
|
||||
#define CMAP(x) c = x; *p++ = PACK(r[c]&0xff, g[c]&0xff, b[c]&0xff);
|
||||
#define CMAP(x) c = (TIFFRGBValue) x; *p++ = PACK(r[c]&0xff, g[c]&0xff, b[c]&0xff);
|
||||
switch (bitspersample) {
|
||||
case 1:
|
||||
CMAP(i>>7);
|
||||
@@ -2240,6 +2375,10 @@ pickTileContigCase(TIFFRGBAImage* img)
|
||||
if (img->bitspersample == 8)
|
||||
put = initYCbCrConversion(img);
|
||||
break;
|
||||
case PHOTOMETRIC_CIELAB:
|
||||
if (img->bitspersample == 8)
|
||||
put = initCIELabConversion(img);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ((img->put.contig = put) != 0);
|
||||
@@ -2383,9 +2522,10 @@ TIFFReadRGBATile(TIFF* tif, uint32 col, uint32 row, uint32 * raster)
|
||||
* Setup the RGBA reader.
|
||||
*/
|
||||
|
||||
if (!TIFFRGBAImageOK(tif, emsg) || !TIFFRGBAImageBegin(&img, tif, 0, emsg)) {
|
||||
TIFFError(TIFFFileName(tif), emsg);
|
||||
return( 0 );
|
||||
if (!TIFFRGBAImageOK(tif, emsg)
|
||||
|| !TIFFRGBAImageBegin(&img, tif, 0, emsg)) {
|
||||
TIFFError(TIFFFileName(tif), emsg);
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2427,8 +2567,7 @@ TIFFReadRGBATile(TIFF* tif, uint32 col, uint32 row, uint32 * raster)
|
||||
if( read_xsize == tile_xsize && read_ysize == tile_ysize )
|
||||
return( ok );
|
||||
|
||||
for( i_row = 0; i_row < read_ysize; i_row++ )
|
||||
{
|
||||
for( i_row = 0; i_row < read_ysize; i_row++ ) {
|
||||
memmove( raster + (tile_ysize - i_row - 1) * tile_xsize,
|
||||
raster + (read_ysize - i_row - 1) * read_xsize,
|
||||
read_xsize * sizeof(uint32) );
|
||||
@@ -2436,8 +2575,7 @@ TIFFReadRGBATile(TIFF* tif, uint32 col, uint32 row, uint32 * raster)
|
||||
0, sizeof(uint32) * (tile_xsize - read_xsize) );
|
||||
}
|
||||
|
||||
for( i_row = read_ysize; i_row < tile_ysize; i_row++ )
|
||||
{
|
||||
for( i_row = read_ysize; i_row < tile_ysize; i_row++ ) {
|
||||
_TIFFmemset( raster + (tile_ysize - i_row - 1) * tile_xsize,
|
||||
0, sizeof(uint32) * tile_xsize );
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ LogL16Decode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s)
|
||||
for (i = 0; i < npixels && cc > 0; )
|
||||
if (*bp >= 128) { /* run */
|
||||
rc = *bp++ + (2-128);
|
||||
b = (int16)*bp++ << shft;
|
||||
b = (int16)(*bp++ << shft);
|
||||
cc -= 2;
|
||||
while (rc--)
|
||||
tp[i++] |= b;
|
||||
@@ -405,7 +405,7 @@ LogL16Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
|
||||
}
|
||||
mask = 0xff << shft; /* find next run */
|
||||
for (beg = i; beg < npixels; beg += rc) {
|
||||
b = tp[beg] & mask;
|
||||
b = (int16) (tp[beg] & mask);
|
||||
rc = 1;
|
||||
while (rc < 127+2 && beg+rc < npixels &&
|
||||
(tp[beg+rc] & mask) == b)
|
||||
@@ -414,36 +414,36 @@ LogL16Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
|
||||
break; /* long enough */
|
||||
}
|
||||
if (beg-i > 1 && beg-i < MINRUN) {
|
||||
b = tp[i] & mask; /* check short run */
|
||||
b = (int16) (tp[i] & mask);/*check short run */
|
||||
j = i+1;
|
||||
while ((tp[j++] & mask) == b)
|
||||
if (j == beg) {
|
||||
*op++ = 128-2+j-i;
|
||||
*op++ = b >> shft;
|
||||
occ -= 2;
|
||||
i = beg;
|
||||
break;
|
||||
}
|
||||
if (j == beg) {
|
||||
*op++ = (tidataval_t)(128-2+j-i);
|
||||
*op++ = (tidataval_t) (b >> shft);
|
||||
occ -= 2;
|
||||
i = beg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (i < beg) { /* write out non-run */
|
||||
if ((j = beg-i) > 127) j = 127;
|
||||
if (occ < j+3) {
|
||||
tif->tif_rawcp = op;
|
||||
tif->tif_rawcc = tif->tif_rawdatasize - occ;
|
||||
if (!TIFFFlushData1(tif))
|
||||
return (-1);
|
||||
op = tif->tif_rawcp;
|
||||
occ = tif->tif_rawdatasize - tif->tif_rawcc;
|
||||
tif->tif_rawcp = op;
|
||||
tif->tif_rawcc = tif->tif_rawdatasize - occ;
|
||||
if (!TIFFFlushData1(tif))
|
||||
return (-1);
|
||||
op = tif->tif_rawcp;
|
||||
occ = tif->tif_rawdatasize - tif->tif_rawcc;
|
||||
}
|
||||
*op++ = j; occ--;
|
||||
*op++ = (tidataval_t) j; occ--;
|
||||
while (j--) {
|
||||
*op++ = tp[i++] >> shft & 0xff;
|
||||
*op++ = (tidataval_t) (tp[i++] >> shft & 0xff);
|
||||
occ--;
|
||||
}
|
||||
}
|
||||
if (rc >= MINRUN) { /* write out run */
|
||||
*op++ = 128-2+rc;
|
||||
*op++ = tp[beg] >> shft & 0xff;
|
||||
*op++ = (tidataval_t) (128-2+rc);
|
||||
*op++ = (tidataval_t) (tp[beg] >> shft & 0xff);
|
||||
occ -= 2;
|
||||
} else
|
||||
rc = 0;
|
||||
@@ -569,14 +569,14 @@ LogLuvEncode32(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
|
||||
op = tif->tif_rawcp;
|
||||
occ = tif->tif_rawdatasize - tif->tif_rawcc;
|
||||
}
|
||||
*op++ = j; occ--;
|
||||
*op++ = (tidataval_t) j; occ--;
|
||||
while (j--) {
|
||||
*op++ = (tidataval_t)(tp[i++] >> shft & 0xff);
|
||||
occ--;
|
||||
}
|
||||
}
|
||||
if (rc >= MINRUN) { /* write out run */
|
||||
*op++ = 128-2+rc;
|
||||
*op++ = (tidataval_t) (128-2+rc);
|
||||
*op++ = (tidataval_t)(tp[beg] >> shft & 0xff);
|
||||
occ -= 2;
|
||||
} else
|
||||
@@ -693,7 +693,7 @@ L16toGry(LogLuvState* sp, tidata_t op, int n)
|
||||
|
||||
while (n-- > 0) {
|
||||
double Y = LogL16toY(*l16++);
|
||||
*gp++ = (Y <= 0.) ? 0 : (Y >= 1.) ? 255 : (int)(256.*sqrt(Y));
|
||||
*gp++ = (uint8) ((Y <= 0.) ? 0 : (Y >= 1.) ? 255 : (int)(256.*sqrt(Y)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -704,7 +704,7 @@ L16fromY(LogLuvState* sp, tidata_t op, int n)
|
||||
float* yp = (float*) op;
|
||||
|
||||
while (n-- > 0)
|
||||
*l16++ = LogL16fromY(*yp++, sp->encode_meth);
|
||||
*l16++ = (int16) (LogL16fromY(*yp++, sp->encode_meth));
|
||||
}
|
||||
|
||||
#if !LOGLUV_PUBLIC
|
||||
@@ -720,9 +720,9 @@ XYZtoRGB24(float xyz[3], uint8 rgb[3])
|
||||
b = 0.061*xyz[0] + -0.224*xyz[1] + 1.163*xyz[2];
|
||||
/* assume 2.0 gamma for speed */
|
||||
/* could use integer sqrt approx., but this is probably faster */
|
||||
rgb[0] = (r <= 0.) ? 0 : (r >= 1.) ? 255 : (int)(256.*sqrt(r));
|
||||
rgb[1] = (g <= 0.) ? 0 : (g >= 1.) ? 255 : (int)(256.*sqrt(g));
|
||||
rgb[2] = (b <= 0.) ? 0 : (b >= 1.) ? 255 : (int)(256.*sqrt(b));
|
||||
rgb[0] = (uint8)((r<=0.) ? 0 : (r >= 1.) ? 255 : (int)(256.*sqrt(r)));
|
||||
rgb[1] = (uint8)((g<=0.) ? 0 : (g >= 1.) ? 255 : (int)(256.*sqrt(g)));
|
||||
rgb[2] = (uint8)((b<=0.) ? 0 : (b >= 1.) ? 255 : (int)(256.*sqrt(b)));
|
||||
}
|
||||
|
||||
#if !LOGLUV_PUBLIC
|
||||
@@ -993,7 +993,7 @@ Luv24fromLuv48(LogLuvState* sp, tidata_t op, int n)
|
||||
else
|
||||
Le = itrunc(.25*(luv3[0]-3314.), sp->encode_meth);
|
||||
|
||||
Ce = uv_encode((luv[1]+.5)/(1<<15), (luv[2]+.5)/(1<<15),
|
||||
Ce = uv_encode((luv3[1]+.5)/(1<<15), (luv3[2]+.5)/(1<<15),
|
||||
sp->encode_meth);
|
||||
if (Ce < 0) /* never happens */
|
||||
Ce = uv_encode(U_NEU, V_NEU, SGILOGENCODE_NODITHER);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_lzw.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_lzw.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -107,6 +107,15 @@ typedef struct {
|
||||
#define lzw_nextdata base.nextdata
|
||||
#define lzw_nextbits base.nextbits
|
||||
|
||||
/*
|
||||
* Encoding-specific state.
|
||||
*/
|
||||
typedef uint16 hcode_t; /* codes fit in 16 bits */
|
||||
typedef struct {
|
||||
long hash;
|
||||
hcode_t code;
|
||||
} hash_t;
|
||||
|
||||
/*
|
||||
* Decoding-specific state.
|
||||
*/
|
||||
@@ -121,6 +130,8 @@ typedef int (*decodeFunc)(TIFF*, tidata_t, tsize_t, tsample_t);
|
||||
|
||||
typedef struct {
|
||||
LZWBaseState base;
|
||||
|
||||
/* Decoding specific data */
|
||||
long dec_nbitsmask; /* lzw_nbits 1 bits, right adjusted */
|
||||
long dec_restart; /* restart count */
|
||||
#ifdef LZW_CHECKEOS
|
||||
@@ -132,19 +143,8 @@ typedef struct {
|
||||
code_t* dec_free_entp; /* next free entry */
|
||||
code_t* dec_maxcodep; /* max available entry */
|
||||
code_t* dec_codetab; /* kept separate for small machines */
|
||||
} LZWDecodeState;
|
||||
|
||||
/*
|
||||
* Encoding-specific state.
|
||||
*/
|
||||
typedef uint16 hcode_t; /* codes fit in 16 bits */
|
||||
typedef struct {
|
||||
long hash;
|
||||
hcode_t code;
|
||||
} hash_t;
|
||||
|
||||
typedef struct {
|
||||
LZWBaseState base;
|
||||
/* Encoding specific data */
|
||||
int enc_oldcode; /* last code encountered */
|
||||
long enc_checkpoint; /* point at which to clear table */
|
||||
#define CHECK_GAP 10000 /* enc_ratio check interval */
|
||||
@@ -153,17 +153,17 @@ typedef struct {
|
||||
long enc_outcount; /* encoded (output) bytes */
|
||||
tidata_t enc_rawlimit; /* bound on tif_rawdata buffer */
|
||||
hash_t* enc_hashtab; /* kept separate for small machines */
|
||||
} LZWEncodeState;
|
||||
} LZWCodecState;
|
||||
|
||||
#define LZWState(tif) ((LZWBaseState*) (tif)->tif_data)
|
||||
#define DecoderState(tif) ((LZWDecodeState*) LZWState(tif))
|
||||
#define EncoderState(tif) ((LZWEncodeState*) LZWState(tif))
|
||||
#define DecoderState(tif) ((LZWCodecState*) LZWState(tif))
|
||||
#define EncoderState(tif) ((LZWCodecState*) LZWState(tif))
|
||||
|
||||
static int LZWDecode(TIFF*, tidata_t, tsize_t, tsample_t);
|
||||
#ifdef LZW_COMPAT
|
||||
static int LZWDecodeCompat(TIFF*, tidata_t, tsize_t, tsample_t);
|
||||
#endif
|
||||
static void cl_hash(LZWEncodeState*);
|
||||
static void cl_hash(LZWCodecState*);
|
||||
|
||||
/*
|
||||
* LZW Decoder.
|
||||
@@ -192,7 +192,7 @@ static void cl_hash(LZWEncodeState*);
|
||||
static int
|
||||
LZWSetupDecode(TIFF* tif)
|
||||
{
|
||||
LZWDecodeState* sp = DecoderState(tif);
|
||||
LZWCodecState* sp = DecoderState(tif);
|
||||
static const char module[] = " LZWSetupDecode";
|
||||
int code;
|
||||
|
||||
@@ -202,7 +202,7 @@ LZWSetupDecode(TIFF* tif)
|
||||
* Allocate state block so tag methods have storage to record
|
||||
* values.
|
||||
*/
|
||||
tif->tif_data = (tidata_t) _TIFFmalloc(sizeof(LZWDecodeState));
|
||||
tif->tif_data = (tidata_t) _TIFFmalloc(sizeof(LZWCodecState));
|
||||
if (tif->tif_data == NULL)
|
||||
{
|
||||
TIFFError("LZWPreDecode", "No space for LZW state block");
|
||||
@@ -248,7 +248,7 @@ LZWSetupDecode(TIFF* tif)
|
||||
static int
|
||||
LZWPreDecode(TIFF* tif, tsample_t s)
|
||||
{
|
||||
LZWDecodeState *sp = DecoderState(tif);
|
||||
LZWCodecState *sp = DecoderState(tif);
|
||||
|
||||
(void) s;
|
||||
assert(sp != NULL);
|
||||
@@ -339,7 +339,7 @@ codeLoop(TIFF* tif)
|
||||
static int
|
||||
LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s)
|
||||
{
|
||||
LZWDecodeState *sp = DecoderState(tif);
|
||||
LZWCodecState *sp = DecoderState(tif);
|
||||
char *op = (char*) op0;
|
||||
long occ = (long) occ0;
|
||||
char *tp;
|
||||
@@ -541,7 +541,7 @@ LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s)
|
||||
static int
|
||||
LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s)
|
||||
{
|
||||
LZWDecodeState *sp = DecoderState(tif);
|
||||
LZWCodecState *sp = DecoderState(tif);
|
||||
char *op = (char*) op0;
|
||||
long occ = (long) occ0;
|
||||
char *tp;
|
||||
@@ -713,7 +713,7 @@ LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s)
|
||||
static int
|
||||
LZWSetupEncode(TIFF* tif)
|
||||
{
|
||||
LZWEncodeState* sp = EncoderState(tif);
|
||||
LZWCodecState* sp = EncoderState(tif);
|
||||
static const char module[] = "LZWSetupEncode";
|
||||
|
||||
assert(sp != NULL);
|
||||
@@ -731,7 +731,7 @@ LZWSetupEncode(TIFF* tif)
|
||||
static int
|
||||
LZWPreEncode(TIFF* tif, tsample_t s)
|
||||
{
|
||||
LZWEncodeState *sp = EncoderState(tif);
|
||||
LZWCodecState *sp = EncoderState(tif);
|
||||
|
||||
(void) s;
|
||||
assert(sp != NULL);
|
||||
@@ -790,7 +790,7 @@ LZWPreEncode(TIFF* tif, tsample_t s)
|
||||
static int
|
||||
LZWEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
|
||||
{
|
||||
register LZWEncodeState *sp = EncoderState(tif);
|
||||
register LZWCodecState *sp = EncoderState(tif);
|
||||
register long fcode;
|
||||
register hash_t *hp;
|
||||
register int h, c;
|
||||
@@ -952,7 +952,7 @@ LZWEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
|
||||
static int
|
||||
LZWPostEncode(TIFF* tif)
|
||||
{
|
||||
register LZWEncodeState *sp = EncoderState(tif);
|
||||
register LZWCodecState *sp = EncoderState(tif);
|
||||
tidata_t op = tif->tif_rawcp;
|
||||
long nextbits = sp->lzw_nextbits;
|
||||
long nextdata = sp->lzw_nextdata;
|
||||
@@ -979,7 +979,7 @@ LZWPostEncode(TIFF* tif)
|
||||
* Reset encoding hash table.
|
||||
*/
|
||||
static void
|
||||
cl_hash(LZWEncodeState* sp)
|
||||
cl_hash(LZWCodecState* sp)
|
||||
{
|
||||
register hash_t *hp = &sp->enc_hashtab[HSIZE-1];
|
||||
register long i = HSIZE-8;
|
||||
@@ -1004,13 +1004,12 @@ static void
|
||||
LZWCleanup(TIFF* tif)
|
||||
{
|
||||
if (tif->tif_data) {
|
||||
if (LZWState(tif)->rw_mode == O_RDONLY) {
|
||||
if (DecoderState(tif)->dec_codetab)
|
||||
_TIFFfree(DecoderState(tif)->dec_codetab);
|
||||
} else {
|
||||
if (EncoderState(tif)->enc_hashtab)
|
||||
_TIFFfree(EncoderState(tif)->enc_hashtab);
|
||||
}
|
||||
if (DecoderState(tif)->dec_codetab)
|
||||
_TIFFfree(DecoderState(tif)->dec_codetab);
|
||||
|
||||
if (EncoderState(tif)->enc_hashtab)
|
||||
_TIFFfree(EncoderState(tif)->enc_hashtab);
|
||||
|
||||
_TIFFfree(tif->tif_data);
|
||||
tif->tif_data = NULL;
|
||||
}
|
||||
@@ -1023,19 +1022,12 @@ TIFFInitLZW(TIFF* tif, int scheme)
|
||||
/*
|
||||
* Allocate state block so tag methods have storage to record values.
|
||||
*/
|
||||
if (tif->tif_mode == O_RDONLY) {
|
||||
tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (LZWDecodeState));
|
||||
if (tif->tif_data == NULL)
|
||||
goto bad;
|
||||
DecoderState(tif)->dec_codetab = NULL;
|
||||
DecoderState(tif)->dec_decode = NULL;
|
||||
} else {
|
||||
tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (LZWEncodeState));
|
||||
if (tif->tif_data == NULL)
|
||||
goto bad;
|
||||
EncoderState(tif)->enc_hashtab = NULL;
|
||||
}
|
||||
|
||||
tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (LZWCodecState));
|
||||
if (tif->tif_data == NULL)
|
||||
goto bad;
|
||||
DecoderState(tif)->dec_codetab = NULL;
|
||||
DecoderState(tif)->dec_decode = NULL;
|
||||
EncoderState(tif)->enc_hashtab = NULL;
|
||||
LZWState(tif)->rw_mode = tif->tif_mode;
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_next.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_next.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
#define SETPIXEL(op, v) { \
|
||||
switch (npixels++ & 3) { \
|
||||
case 0: op[0] = (v) << 6; break; \
|
||||
case 0: op[0] = (u_char) ((v) << 6); break; \
|
||||
case 1: op[0] |= (v) << 4; break; \
|
||||
case 2: op[0] |= (v) << 2; break; \
|
||||
case 3: *op++ |= (v); break; \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_open.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_open.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -32,19 +32,19 @@
|
||||
void _TIFFSetDefaultCompressionState(TIFF* tif);
|
||||
|
||||
static const long typemask[13] = {
|
||||
0L, /* TIFF_NOTYPE */
|
||||
0x000000ffL, /* TIFF_BYTE */
|
||||
0xffffffffL, /* TIFF_ASCII */
|
||||
0x0000ffffL, /* TIFF_SHORT */
|
||||
0xffffffffL, /* TIFF_LONG */
|
||||
0xffffffffL, /* TIFF_RATIONAL */
|
||||
0x000000ffL, /* TIFF_SBYTE */
|
||||
0x000000ffL, /* TIFF_UNDEFINED */
|
||||
0x0000ffffL, /* TIFF_SSHORT */
|
||||
0xffffffffL, /* TIFF_SLONG */
|
||||
0xffffffffL, /* TIFF_SRATIONAL */
|
||||
0xffffffffL, /* TIFF_FLOAT */
|
||||
0xffffffffL, /* TIFF_DOUBLE */
|
||||
(long)0L, /* TIFF_NOTYPE */
|
||||
(long)0x000000ffL, /* TIFF_BYTE */
|
||||
(long)0xffffffffL, /* TIFF_ASCII */
|
||||
(long)0x0000ffffL, /* TIFF_SHORT */
|
||||
(long)0xffffffffL, /* TIFF_LONG */
|
||||
(long)0xffffffffL, /* TIFF_RATIONAL */
|
||||
(long)0x000000ffL, /* TIFF_SBYTE */
|
||||
(long)0x000000ffL, /* TIFF_UNDEFINED */
|
||||
(long)0x0000ffffL, /* TIFF_SSHORT */
|
||||
(long)0xffffffffL, /* TIFF_SLONG */
|
||||
(long)0xffffffffL, /* TIFF_SRATIONAL */
|
||||
(long)0xffffffffL, /* TIFF_FLOAT */
|
||||
(long)0xffffffffL, /* TIFF_DOUBLE */
|
||||
};
|
||||
static const int bigTypeshift[13] = {
|
||||
0, /* TIFF_NOTYPE */
|
||||
@@ -313,6 +313,8 @@ TIFFClientOpen(
|
||||
if (!TIFFDefaultDirectory(tif))
|
||||
goto bad;
|
||||
tif->tif_diroff = 0;
|
||||
tif->tif_dirlist = NULL;
|
||||
tif->tif_dirnumber = 0;
|
||||
return (tif);
|
||||
}
|
||||
/*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_packbits.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_packbits.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -109,16 +109,16 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
|
||||
state = RUN;
|
||||
if (n > 128) {
|
||||
*op++ = (tidata) -127;
|
||||
*op++ = b;
|
||||
*op++ = (tidataval_t) b;
|
||||
n -= 128;
|
||||
goto again;
|
||||
}
|
||||
*op++ = (tidataval_t)(-(n-1));
|
||||
*op++ = b;
|
||||
*op++ = (tidataval_t) b;
|
||||
} else {
|
||||
lastliteral = op;
|
||||
*op++ = 0;
|
||||
*op++ = b;
|
||||
*op++ = (tidataval_t) b;
|
||||
state = LITERAL;
|
||||
}
|
||||
break;
|
||||
@@ -127,32 +127,32 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
|
||||
state = LITERAL_RUN;
|
||||
if (n > 128) {
|
||||
*op++ = (tidata) -127;
|
||||
*op++ = b;
|
||||
*op++ = (tidataval_t) b;
|
||||
n -= 128;
|
||||
goto again;
|
||||
}
|
||||
*op++ = (tidataval_t)(-(n-1)); /* encode run */
|
||||
*op++ = b;
|
||||
*op++ = (tidataval_t) b;
|
||||
} else { /* extend literal */
|
||||
if (++(*lastliteral) == 127)
|
||||
state = BASE;
|
||||
*op++ = b;
|
||||
*op++ = (tidataval_t) b;
|
||||
}
|
||||
break;
|
||||
case RUN: /* last object was run */
|
||||
if (n > 1) {
|
||||
if (n > 128) {
|
||||
*op++ = (tidata) -127;
|
||||
*op++ = b;
|
||||
*op++ = (tidataval_t) b;
|
||||
n -= 128;
|
||||
goto again;
|
||||
}
|
||||
*op++ = (tidataval_t)(-(n-1));
|
||||
*op++ = b;
|
||||
*op++ = (tidataval_t) b;
|
||||
} else {
|
||||
lastliteral = op;
|
||||
*op++ = 0;
|
||||
*op++ = b;
|
||||
*op++ = (tidataval_t) b;
|
||||
state = LITERAL;
|
||||
}
|
||||
break;
|
||||
@@ -188,31 +188,40 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
|
||||
static int
|
||||
PackBitsEncodeChunk(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
|
||||
{
|
||||
tsize_t rowsize = (tsize_t) tif->tif_data;
|
||||
|
||||
assert(rowsize > 0);
|
||||
|
||||
#ifdef YCBCR_SUPPORT
|
||||
/*
|
||||
* YCBCR data isn't really separable into rows, so we
|
||||
* might as well encode the whole tile/strip as one chunk.
|
||||
*/
|
||||
if( tif->tif_dir.td_photometric == PHOTOMETRIC_YCBCR )
|
||||
rowsize = (tsize_t) tif->tif_data;
|
||||
#if defined(__hpux) && defined(__LP64__)
|
||||
tsize_t rowsize = (tsize_t)(unsigned long) tif->tif_data;
|
||||
#else
|
||||
tsize_t rowsize = (tsize_t) tif->tif_data;
|
||||
#endif
|
||||
|
||||
while ((long)cc > 0) {
|
||||
int chunk = rowsize;
|
||||
|
||||
if( cc < chunk )
|
||||
chunk = cc;
|
||||
assert(rowsize > 0);
|
||||
|
||||
#ifdef YCBCR_SUPPORT
|
||||
/*
|
||||
* YCBCR data isn't really separable into rows, so we
|
||||
* might as well encode the whole tile/strip as one chunk.
|
||||
*/
|
||||
if( tif->tif_dir.td_photometric == PHOTOMETRIC_YCBCR ) {
|
||||
#if defined(__hpux) && defined(__LP64__)
|
||||
rowsize = (tsize_t)(unsigned long) tif->tif_data;
|
||||
#else
|
||||
rowsize = (tsize_t) tif->tif_data;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (PackBitsEncode(tif, bp, chunk, s) < 0)
|
||||
return (-1);
|
||||
bp += chunk;
|
||||
cc -= chunk;
|
||||
}
|
||||
return (1);
|
||||
while ((long)cc > 0) {
|
||||
int chunk = rowsize;
|
||||
|
||||
if( cc < chunk )
|
||||
chunk = cc;
|
||||
|
||||
if (PackBitsEncode(tif, bp, chunk, s) < 0)
|
||||
return (-1);
|
||||
bp += chunk;
|
||||
cc -= chunk;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -249,7 +258,7 @@ PackBitsDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s)
|
||||
occ -= n;
|
||||
b = *bp++, cc--;
|
||||
while (n-- > 0)
|
||||
*op++ = b;
|
||||
*op++ = (tidataval_t) b;
|
||||
} else { /* copy next n+1 bytes literally */
|
||||
if (occ < n + 1)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_predict.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_predict.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -174,9 +174,9 @@ horAcc8(TIFF* tif, tidata_t cp0, tsize_t cc)
|
||||
u_int cb = cp[2];
|
||||
do {
|
||||
cc -= 3, cp += 3;
|
||||
cp[0] = (cr += cp[0]);
|
||||
cp[1] = (cg += cp[1]);
|
||||
cp[2] = (cb += cp[2]);
|
||||
cp[0] = (char) (cr += cp[0]);
|
||||
cp[1] = (char) (cg += cp[1]);
|
||||
cp[2] = (char) (cb += cp[2]);
|
||||
} while ((int32) cc > 0);
|
||||
} else if (stride == 4) {
|
||||
u_int cr = cp[0];
|
||||
@@ -185,14 +185,14 @@ horAcc8(TIFF* tif, tidata_t cp0, tsize_t cc)
|
||||
u_int ca = cp[3];
|
||||
do {
|
||||
cc -= 4, cp += 4;
|
||||
cp[0] = (cr += cp[0]);
|
||||
cp[1] = (cg += cp[1]);
|
||||
cp[2] = (cb += cp[2]);
|
||||
cp[3] = (ca += cp[3]);
|
||||
cp[0] = (char) (cr += cp[0]);
|
||||
cp[1] = (char) (cg += cp[1]);
|
||||
cp[2] = (char) (cb += cp[2]);
|
||||
cp[3] = (char) (ca += cp[3]);
|
||||
} while ((int32) cc > 0);
|
||||
} else {
|
||||
do {
|
||||
REPEAT4(stride, cp[stride] += *cp; cp++)
|
||||
REPEAT4(stride, cp[stride] = (char) (cp[stride] + *cp); cp++)
|
||||
cc -= stride;
|
||||
} while ((int32) cc > 0);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_strip.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_strip.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991-1997 Sam Leffler
|
||||
@@ -111,6 +111,26 @@ TIFFVStripSize(TIFF* tif, uint32 nrows)
|
||||
return ((tsize_t)(nrows * TIFFScanlineSize(tif)));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Compute the # bytes in a raw strip.
|
||||
*/
|
||||
tsize_t
|
||||
TIFFRawStripSize(TIFF* tif, tstrip_t strip)
|
||||
{
|
||||
TIFFDirectory* td = &tif->tif_dir;
|
||||
tsize_t bytecount = td->td_stripbytecount[strip];
|
||||
|
||||
if (bytecount <= 0) {
|
||||
TIFFError(tif->tif_name,
|
||||
"%lu: Invalid strip byte count, strip %lu",
|
||||
(u_long) bytecount, (u_long) strip);
|
||||
bytecount = (tsize_t) -1;
|
||||
}
|
||||
|
||||
return bytecount;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute the # bytes in a (row-aligned) strip.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_swab.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_swab.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -36,7 +36,7 @@ void
|
||||
TIFFSwabShort(uint16* wp)
|
||||
{
|
||||
register u_char* cp = (u_char*) wp;
|
||||
int t;
|
||||
u_char t;
|
||||
|
||||
t = cp[1]; cp[1] = cp[0]; cp[0] = t;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ void
|
||||
TIFFSwabLong(uint32* lp)
|
||||
{
|
||||
register u_char* cp = (u_char*) lp;
|
||||
int t;
|
||||
u_char t;
|
||||
|
||||
t = cp[3]; cp[3] = cp[0]; cp[0] = t;
|
||||
t = cp[2]; cp[2] = cp[1]; cp[1] = t;
|
||||
@@ -59,7 +59,7 @@ void
|
||||
TIFFSwabArrayOfShort(uint16* wp, register u_long n)
|
||||
{
|
||||
register u_char* cp;
|
||||
register int t;
|
||||
register u_char t;
|
||||
|
||||
/* XXX unroll loop some */
|
||||
while (n-- > 0) {
|
||||
@@ -75,7 +75,7 @@ void
|
||||
TIFFSwabArrayOfLong(register uint32* lp, register u_long n)
|
||||
{
|
||||
register unsigned char *cp;
|
||||
register int t;
|
||||
register unsigned char t;
|
||||
|
||||
/* XXX unroll loop some */
|
||||
while (n-- > 0) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_thunder.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_thunder.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -60,7 +60,7 @@ static const int threebitdeltas[8] = { 0, 1, 2, 3, 0, -3, -2, -1 };
|
||||
if (npixels++ & 1) \
|
||||
*op++ |= lastpixel; \
|
||||
else \
|
||||
op[0] = lastpixel << 4; \
|
||||
op[0] = (tidataval_t) (lastpixel << 4); \
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -92,7 +92,7 @@ ThunderDecode(TIFF* tif, tidata_t op, tsize_t maxpixels)
|
||||
lastpixel |= lastpixel << 4;
|
||||
npixels += n;
|
||||
for (; n > 0; n -= 2)
|
||||
*op++ = lastpixel;
|
||||
*op++ = (tidataval_t) lastpixel;
|
||||
if (n == -1)
|
||||
*--op &= 0xf0;
|
||||
lastpixel &= 0xf;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_tile.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_tile.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991-1997 Sam Leffler
|
||||
@@ -62,7 +62,7 @@ TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t s)
|
||||
xpt*(y/dy) +
|
||||
x/dx;
|
||||
else
|
||||
tile = (xpt*ypt)*(z/dz) + xpt*(y/dy) + x/dx + s;
|
||||
tile = (xpt*ypt)*(z/dz) + xpt*(y/dy) + x/dx;
|
||||
}
|
||||
return (tile);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_write.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_write.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -152,6 +152,10 @@ TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample)
|
||||
return (-1);
|
||||
tif->tif_row = row;
|
||||
}
|
||||
|
||||
/* swab if needed - note that source buffer will be altered */
|
||||
tif->tif_postdecode( tif, (tidata_t) buf, tif->tif_scanlinesize );
|
||||
|
||||
status = (*tif->tif_encoderow)(tif, (tidata_t) buf,
|
||||
tif->tif_scanlinesize, sample);
|
||||
|
||||
@@ -229,6 +233,10 @@ TIFFWriteEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc)
|
||||
sample = (tsample_t)(strip / td->td_stripsperimage);
|
||||
if (!(*tif->tif_preencode)(tif, sample))
|
||||
return ((tsize_t) -1);
|
||||
|
||||
/* swab if needed - note that source buffer will be altered */
|
||||
tif->tif_postdecode( tif, (tidata_t) data, cc );
|
||||
|
||||
if (!(*tif->tif_encodestrip)(tif, (tidata_t) data, cc, sample))
|
||||
return ((tsize_t) 0);
|
||||
if (!(*tif->tif_postencode)(tif))
|
||||
@@ -386,6 +394,10 @@ TIFFWriteEncodedTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc)
|
||||
*/
|
||||
if ( cc < 1 || cc > tif->tif_tilesize)
|
||||
cc = tif->tif_tilesize;
|
||||
|
||||
/* swab if needed - note that source buffer will be altered */
|
||||
tif->tif_postdecode( tif, (tidata_t) data, cc );
|
||||
|
||||
if (!(*tif->tif_encodetile)(tif, (tidata_t) data, cc, sample))
|
||||
return ((tsize_t) 0);
|
||||
if (!(*tif->tif_postencode)(tif))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_zip.c,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tif_zip.c,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995-1997 Sam Leffler
|
||||
@@ -228,7 +228,8 @@ ZIPPostEncode(TIFF* tif)
|
||||
switch (state) {
|
||||
case Z_STREAM_END:
|
||||
case Z_OK:
|
||||
if (sp->stream.avail_out != tif->tif_rawdatasize) {
|
||||
if ((int)sp->stream.avail_out != (int)tif->tif_rawdatasize)
|
||||
{
|
||||
tif->tif_rawcc =
|
||||
tif->tif_rawdatasize - sp->stream.avail_out;
|
||||
TIFFFlushData1(tif);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tiff.h,v 1.2 2003/07/31 23:09:27 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tiff.h,v 1.3 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -76,10 +76,10 @@ typedef struct {
|
||||
* offset field.
|
||||
*/
|
||||
typedef struct {
|
||||
uint16 tdir_tag; /* see below */
|
||||
uint16 tdir_type; /* data type; see below */
|
||||
uint32 tdir_count; /* number of items; length in spec */
|
||||
uint32 tdir_offset; /* byte offset to field data */
|
||||
uint16 tdir_tag; /* see below */
|
||||
uint16 tdir_type; /* data type; see below */
|
||||
uint32 tdir_count; /* number of items; length in spec */
|
||||
uint32 tdir_offset; /* byte offset to field data */
|
||||
} TIFFDirEntry;
|
||||
|
||||
/*
|
||||
@@ -108,7 +108,8 @@ typedef enum {
|
||||
TIFF_SLONG = 9, /* !32-bit signed integer */
|
||||
TIFF_SRATIONAL = 10, /* !64-bit signed fraction */
|
||||
TIFF_FLOAT = 11, /* !32-bit IEEE floating point */
|
||||
TIFF_DOUBLE = 12 /* !64-bit IEEE floating point */
|
||||
TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */
|
||||
TIFF_IFD = 13 /* %32-bit unsigned integer (offset) */
|
||||
} TIFFDataType;
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tiffcomp.h,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tiffcomp.h,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990-1997 Sam Leffler
|
||||
@@ -119,11 +119,17 @@
|
||||
* then define BSDTYPES in your Makefile.
|
||||
*/
|
||||
#if defined(BSDTYPES)
|
||||
# ifndef _BSDTYPES_DEFINED
|
||||
# ifndef __u_char_defined
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned long u_long;
|
||||
#endif
|
||||
# define __u_char_defined
|
||||
# endif /* __u_char_defined */
|
||||
# define _BSDTYPES_DEFINED
|
||||
# endif /* _BSDTYPES_DEFINED */
|
||||
#endif /* BSDTYPES */
|
||||
|
||||
/*
|
||||
* dblparam_t is the type that a double precision
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tiffconf.h,v 1.2 2003/07/20 14:34:15 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tiffconf.h,v 1.3 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
@@ -27,6 +27,7 @@
|
||||
#define _TIFFCONF_
|
||||
|
||||
#include <endian.h>
|
||||
// For getting Endianness from BeOS (BIG_ENDIAN)
|
||||
|
||||
/*
|
||||
* Library Configuration Definitions.
|
||||
@@ -36,7 +37,7 @@
|
||||
* #defines on the command line, this file can be edited to
|
||||
* configure the library. Otherwise, one can override portability
|
||||
* and configuration-related definitions from a Makefile or command
|
||||
* line by defining FEATURE_SUPPORT and COMPRESSION_SUPPORT (see below).
|
||||
* line by defining COMPRESSION_SUPPORT (see below).
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -71,25 +72,6 @@
|
||||
# define USE_64BIT_API 0
|
||||
#endif
|
||||
|
||||
#ifndef FEATURE_SUPPORT
|
||||
/*
|
||||
* Feature support definitions:
|
||||
*
|
||||
* COLORIMETRY_SUPPORT enable support for 6.0 colorimetry tags
|
||||
* YCBCR_SUPPORT enable support for 6.0 YCbCr tags
|
||||
* CMYK_SUPPORT enable support for 6.0 CMYK tags
|
||||
* ICC_SUPPORT enable support for ICC profile tag
|
||||
* PHOTOSHOP_SUPPORT enable support for PHOTOSHOP resource tag
|
||||
* IPTC_SUPPORT enable support for RichTIFF IPTC tag
|
||||
*/
|
||||
#define COLORIMETRY_SUPPORT
|
||||
#define YCBCR_SUPPORT
|
||||
#define CMYK_SUPPORT
|
||||
#define ICC_SUPPORT
|
||||
#define PHOTOSHOP_SUPPORT
|
||||
#define IPTC_SUPPORT
|
||||
#endif /* FEATURE_SUPPORT */
|
||||
|
||||
#ifndef COMPRESSION_SUPPORT
|
||||
/*
|
||||
* Compression support defines:
|
||||
@@ -160,4 +142,16 @@
|
||||
#define CHECK_JPEG_YCBCR_SUBSAMPLING 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Feature support definitions.
|
||||
* XXX: These macros are obsoleted. Don't use them in your apps!
|
||||
* Macros stays here for backward compatibility and should be always defined.
|
||||
*/
|
||||
#define COLORIMETRY_SUPPORT
|
||||
#define YCBCR_SUPPORT
|
||||
#define CMYK_SUPPORT
|
||||
#define ICC_SUPPORT
|
||||
#define PHOTOSHOP_SUPPORT
|
||||
#define IPTC_SUPPORT
|
||||
|
||||
#endif /* _TIFFCONF_ */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tiffio.h,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tiffio.h,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -114,10 +114,72 @@ typedef void* thandle_t; /* client data handle */
|
||||
#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */
|
||||
#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */
|
||||
|
||||
/*
|
||||
* Colour conversion stuff
|
||||
*/
|
||||
|
||||
/* reference white */
|
||||
#define D65_X0 (95.0470F)
|
||||
#define D65_Y0 (100.0F)
|
||||
#define D65_Z0 (108.8827F)
|
||||
|
||||
#define D50_X0 (96.4250F)
|
||||
#define D50_Y0 (100.0F)
|
||||
#define D50_Z0 (82.4680F)
|
||||
|
||||
/* Structure for holding information about a display device. */
|
||||
|
||||
typedef unsigned char TIFFRGBValue; /* 8-bit samples */
|
||||
|
||||
typedef struct {
|
||||
float d_mat[3][3]; /* XYZ -> luminance matrix */
|
||||
float d_YCR; /* Light o/p for reference white */
|
||||
float d_YCG;
|
||||
float d_YCB;
|
||||
uint32 d_Vrwr; /* Pixel values for ref. white */
|
||||
uint32 d_Vrwg;
|
||||
uint32 d_Vrwb;
|
||||
float d_Y0R; /* Residual light for black pixel */
|
||||
float d_Y0G;
|
||||
float d_Y0B;
|
||||
float d_gammaR; /* Gamma values for the three guns */
|
||||
float d_gammaG;
|
||||
float d_gammaB;
|
||||
} TIFFDisplay;
|
||||
|
||||
typedef struct { /* YCbCr->RGB support */
|
||||
TIFFRGBValue* clamptab; /* range clamping table */
|
||||
int* Cr_r_tab;
|
||||
int* Cb_b_tab;
|
||||
int32* Cr_g_tab;
|
||||
int32* Cb_g_tab;
|
||||
int32* Y_tab;
|
||||
} TIFFYCbCrToRGB;
|
||||
|
||||
typedef struct { /* CIE Lab 1976->RGB support */
|
||||
int range; /* Size of conversion table */
|
||||
#define CIELABTORGB_TABLE_RANGE 1500
|
||||
float rstep, gstep, bstep;
|
||||
float X0, Y0, Z0; /* Reference white point */
|
||||
TIFFDisplay display;
|
||||
float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */
|
||||
float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */
|
||||
float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */
|
||||
} TIFFCIELabToRGB;
|
||||
|
||||
extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, TIFFDisplay *, float*);
|
||||
extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32,
|
||||
float *, float *, float *);
|
||||
extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float,
|
||||
uint32 *, uint32 *, uint32 *);
|
||||
|
||||
extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*);
|
||||
extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32,
|
||||
uint32 *, uint32 *, uint32 *);
|
||||
|
||||
/*
|
||||
* RGBA-style image support.
|
||||
*/
|
||||
typedef unsigned char TIFFRGBValue; /* 8-bit samples */
|
||||
typedef struct _TIFFRGBAImage TIFFRGBAImage;
|
||||
/*
|
||||
* The image reading and conversion routines invoke
|
||||
@@ -138,15 +200,6 @@ typedef void (*tileSeparateRoutine)
|
||||
/*
|
||||
* RGBA-reader state.
|
||||
*/
|
||||
typedef struct { /* YCbCr->RGB support */
|
||||
TIFFRGBValue* clamptab; /* range clamping table */
|
||||
int* Cr_r_tab;
|
||||
int* Cb_b_tab;
|
||||
int32* Cr_g_tab;
|
||||
int32* Cb_g_tab;
|
||||
float coeffs[3]; /* cached for repeated use */
|
||||
} TIFFYCbCrToRGB;
|
||||
|
||||
struct _TIFFRGBAImage {
|
||||
TIFF* tif; /* image handle */
|
||||
int stoponerr; /* stop on read error */
|
||||
@@ -157,6 +210,7 @@ struct _TIFFRGBAImage {
|
||||
uint16 bitspersample; /* image bits/sample */
|
||||
uint16 samplesperpixel; /* image samples/pixel */
|
||||
uint16 orientation; /* image orientation */
|
||||
uint16 req_orientation; /* requested orientation */
|
||||
uint16 photometric; /* image photometric interp */
|
||||
uint16* redcmap; /* colormap pallete */
|
||||
uint16* greencmap;
|
||||
@@ -172,6 +226,7 @@ struct _TIFFRGBAImage {
|
||||
uint32** BWmap; /* black&white map */
|
||||
uint32** PALmap; /* palette image map */
|
||||
TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */
|
||||
TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */
|
||||
|
||||
int row_offset;
|
||||
int col_offset;
|
||||
@@ -225,6 +280,7 @@ extern const char* TIFFGetVersion(void);
|
||||
extern const TIFFCodec* TIFFFindCODEC(uint16);
|
||||
extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod);
|
||||
extern void TIFFUnRegisterCODEC(TIFFCodec*);
|
||||
extern int TIFFIsCODECConfigured(uint16);
|
||||
|
||||
extern tdata_t _TIFFmalloc(tsize_t);
|
||||
extern tdata_t _TIFFrealloc(tdata_t, tsize_t);
|
||||
@@ -244,6 +300,7 @@ extern int TIFFReadDirectory(TIFF*);
|
||||
extern tsize_t TIFFScanlineSize(TIFF*);
|
||||
extern tsize_t TIFFRasterScanlineSize(TIFF*);
|
||||
extern tsize_t TIFFStripSize(TIFF*);
|
||||
extern tsize_t TIFFRawStripSize(TIFF*, tstrip_t);
|
||||
extern tsize_t TIFFVStripSize(TIFF*, uint32);
|
||||
extern tsize_t TIFFTileRowSize(TIFF*);
|
||||
extern tsize_t TIFFTileSize(TIFF*);
|
||||
@@ -283,11 +340,14 @@ extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0);
|
||||
extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t = 0);
|
||||
extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t = 0);
|
||||
extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0);
|
||||
extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*,
|
||||
int = ORIENTATION_BOTLEFT, int = 0);
|
||||
#else
|
||||
extern void TIFFPrintDirectory(TIFF*, FILE*, long);
|
||||
extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t);
|
||||
extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t);
|
||||
extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int);
|
||||
extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int);
|
||||
#endif
|
||||
|
||||
extern int TIFFReadRGBAStrip(TIFF*, tstrip_t, uint32 * );
|
||||
@@ -327,7 +387,7 @@ extern tsize_t TIFFWriteEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
|
||||
extern tsize_t TIFFWriteRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t);
|
||||
extern tsize_t TIFFWriteEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t);
|
||||
extern tsize_t TIFFWriteRawTile(TIFF*, ttile_t, tdata_t, tsize_t);
|
||||
extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */
|
||||
extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */
|
||||
extern void TIFFSetWriteOffset(TIFF*, toff_t);
|
||||
extern void TIFFSwabShort(uint16*);
|
||||
extern void TIFFSwabLong(uint32*);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tiffiop.h,v 1.1 2003/07/19 16:40:33 mwilber Exp $ */
|
||||
/* $Header: /tmp/bonefish/open-beos/current/src/add-ons/translators/libtifftranslator/tiffiop.h,v 1.2 2004/01/03 15:22:08 mwilber Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -92,6 +92,9 @@ struct tiff {
|
||||
#define TIFF_STRIPCHOP 0x8000 /* enable strip chopping support */
|
||||
toff_t tif_diroff; /* file offset of current directory */
|
||||
toff_t tif_nextdiroff; /* file offset of following directory */
|
||||
toff_t* tif_dirlist; /* list of offsets to already seen */
|
||||
/* directories to prevent IFD looping */
|
||||
uint16 tif_dirnumber; /* number of already seen directories */
|
||||
TIFFDirectory tif_dir; /* internal rep of current directory */
|
||||
TIFFHeader tif_header; /* file's header block */
|
||||
const int* tif_typeshift; /* data type shift counts */
|
||||
@@ -198,6 +201,9 @@ struct tiff {
|
||||
#define TIFFhowmany(x, y) ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y)))
|
||||
#define TIFFroundup(x, y) (TIFFhowmany(x,y)*((uint32)(y)))
|
||||
|
||||
#define TIFFmax(A,B) ((A)>(B)?(A):(B))
|
||||
#define TIFFmin(A,B) ((A)<(B)?(A):(B))
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 3.6.0 beta2\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
|
||||
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 3.6.1\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
|
||||
/*
|
||||
* This define can be used in code that requires
|
||||
* compilation-related definitions specific to a
|
||||
@@ -6,4 +6,4 @@
|
||||
* version checking should be done based on the
|
||||
* string returned by TIFFGetVersion.
|
||||
*/
|
||||
#define TIFFLIB_VERSION 20030619
|
||||
#define TIFFLIB_VERSION 20031226
|
||||
|
||||
Reference in New Issue
Block a user