35 # define TIFFCvtNativeToIEEEFloat(tif, n, fp) 36 # define TIFFCvtNativeToIEEEDouble(tif, n, dp) 55 static int TIFFWriteAnyArray(
TIFF*,
60 static int TIFFLinkDirectory(
TIFF*);
62 #define WriteRationalPair(type, tag1, v1, tag2, v2) { \ 63 TIFFWriteRational((tif), (type), (tag1), (dir), (v1)) \ 64 TIFFWriteRational((tif), (type), (tag2), (dir)+1, (v2)) \ 67 #define TIFFWriteRational(tif, type, tag, dir, v) \ 68 (dir)->tdir_tag = (tag); \ 69 (dir)->tdir_type = (type); \ 70 (dir)->tdir_count = 1; \ 71 if (!TIFFWriteRationalArray((tif), (dir), &(v))) \ 81 _TIFFWriteDirectory(
TIFF* tif,
int done)
107 "Error post-encoding before directory write");
118 "Error flushing data before directory write");
145 "Cannot write directory, out of space");
153 if (tif->
tif_diroff == 0 && !TIFFLinkDirectory(tif))
176 for (fi = 0, nfi = tif->
tif_nfields; nfi > 0; nfi--, fi++) {
186 int ci, is_set =
FALSE;
237 if (!TIFFWriteLongArray(tif, dir,
284 if (!TIFFWritePerSampleShorts(tif, fip->
field_tag, dir))
289 if (!TIFFWritePerSampleAnys(tif,
296 if (!TIFFSetupShortPair(tif, fip->
field_tag, dir))
300 if (!TIFFWriteInkNames(tif, dir))
304 if (!TIFFWriteTransferFunction(tif, dir))
340 if (!TIFFSetupShortPair(tif, fip->
field_tag, dir))
343 else if (!TIFFWriteNormalTag(tif, dir, fip))
356 dircount = (
uint16) nfields;
373 dircount = (
uint16) nfields;
378 if (!
WriteOK(tif, &dircount,
sizeof (dircount))) {
382 if (!
WriteOK(tif, data, dirsize)) {
386 if (!
WriteOK(tif, &diroff,
sizeof (diroff))) {
407 #undef WriteRationalPair 412 return _TIFFWriteDirectory(tif,
TRUE);
428 rc = _TIFFWriteDirectory(tif,
FALSE);
458 if (!TIFFWriteShortArray(tif, dir, wp))
469 if (!TIFFWriteShortArray(tif, dir, wp))
486 if (!TIFFWriteLongArray(tif, dir, lp))
496 if (!TIFFWriteLongArray(tif, dir, lp))
512 if (!TIFFWriteRationalArray(tif, dir, fp))
518 if (!TIFFWriteRationalArray(tif, dir, &fv))
523 if (!TIFFWriteRationalArray(tif, dir, fp))
538 if (!TIFFWriteFloatArray(tif, dir, fp))
544 if (!TIFFWriteFloatArray(tif, dir, &fv))
549 if (!TIFFWriteFloatArray(tif, dir, fp))
564 if (!TIFFWriteDoubleArray(tif, dir, dp))
570 if (!TIFFWriteDoubleArray(tif, dir, &dv))
575 if (!TIFFWriteDoubleArray(tif, dir, dp))
589 if (!TIFFWriteByteArray(tif, dir, cp))
605 if (!TIFFWriteByteArray(tif, dir, cp))
611 if (!TIFFWriteByteArray(tif, dir, &cv))
616 if (!TIFFWriteByteArray(tif, dir, cp))
632 if (!TIFFWriteByteArray(tif, dir, cp))
672 #undef MakeShortDirent 674 #define NITEMS(x) (sizeof (x) / sizeof (x[0])) 689 if (samples >
NITEMS(buf)) {
693 "No space to write per-sample shorts");
704 status = TIFFWriteShortArray(tif, dir, w);
716 TIFFWritePerSampleAnys(
TIFF* tif,
724 if (samples >
NITEMS(buf)) {
725 w = (
double*)
_TIFFmalloc(samples *
sizeof (
double));
728 "No space to write per-sample values");
735 status = TIFFWriteAnyArray(tif,
type, tag, dir, samples, w);
756 return (TIFFWriteShortArray(tif, dir, v));
765 TIFFWriteShortTable(
TIFF* tif,
775 for (i = 0; i <
n; i++)
776 if (!TIFFWriteData(tif, dir, (
char *)table[
i]))
790 if (!TIFFWriteData(tif, dir, cp))
816 return (TIFFWriteData(tif, dir, (
char*)
v));
830 return (TIFFWriteData(tif, dir, (
char*) v));
847 "No space to write RATIONAL array");
858 "\"%s\": Information lost writing value (%g) as (unsigned) RATIONAL",
867 while (fv < 1L<<(31-3) && den < 1L<<(31-3))
868 fv *= 1<<3, den *= 1L<<3;
870 t[2*i+0] = (
uint32) (sign * (fv + 0.5));
873 status = TIFFWriteData(tif, dir, (
char *)t);
886 return (TIFFWriteData(tif, dir, (
char*) v));
893 return (TIFFWriteData(tif, dir, (
char*) v));
906 TIFFWriteAnyArray(
TIFF* tif,
909 char buf[10 *
sizeof(double)];
917 "No space to write array");
930 for (i = 0; i < (
int)
n; i++)
932 if (!TIFFWriteByteArray(tif, dir, (
char*) bp))
939 for (i = 0; i < (
int)
n; i++)
941 if (!TIFFWriteByteArray(tif, dir, (
char*) bp))
948 for (i = 0; i < (
int)
n; i++)
950 if (!TIFFWriteShortArray(tif, dir, (
uint16*)bp))
957 for (i = 0; i < (
int)
n; i++)
959 if (!TIFFWriteShortArray(tif, dir, (
uint16*)bp))
966 for (i = 0; i < (
int)
n; i++)
968 if (!TIFFWriteLongArray(tif, dir, bp))
974 int32* bp = (int32*) w;
975 for (i = 0; i < (
int)
n; i++)
976 bp[i] = (int32) v[
i];
977 if (!TIFFWriteLongArray(tif, dir, (
uint32*) bp))
983 float* bp = (
float*) w;
984 for (i = 0; i < (
int)
n; i++)
985 bp[i] = (
float) v[
i];
986 if (!TIFFWriteFloatArray(tif, dir, bp))
991 return (TIFFWriteDoubleArray(tif, dir, v));
1022 default:
if (
_TIFFmemcmp(tf[0], tf[2], n)) { ncols = 3;
break; }
1023 case 2:
if (
_TIFFmemcmp(tf[0], tf[1], n)) { ncols = 3;
break; }
1024 case 1:
case 0: ncols = 1;
1026 return (TIFFWriteShortTable(tif,
1038 return (TIFFWriteByteArray(tif, dir, td->
td_inknames));
1091 static const char module[] =
"TIFFRewriteDirectory";
1125 if (!
SeekOK(tif, nextdir) ||
1126 !
ReadOK(tif, &dircount,
sizeof (dircount))) {
1134 if (!
ReadOK(tif, &nextdir,
sizeof (nextdir))) {
1140 }
while (nextdir != tif->
tif_diroff && nextdir != 0);
1163 TIFFLinkDirectory(
TIFF* tif)
1165 static const char module[] =
"TIFFLinkDirectory";
1179 if (!
WriteOK(tif, &diroff,
sizeof (diroff))) {
1181 "%s: Error writing SubIFD directory link",
1205 if (!
WriteOK(tif, &diroff,
sizeof (diroff))) {
1218 if (!
SeekOK(tif, nextdir) ||
1219 !
ReadOK(tif, &dircount,
sizeof (dircount))) {
1227 if (!
ReadOK(tif, &nextdir,
sizeof (nextdir))) {
1233 }
while (nextdir != 0);
1236 if (!
WriteOK(tif, &diroff,
sizeof (diroff))) {
int TIFFRewriteDirectory(TIFF *tif)
#define FIELD_MINSAMPLEVALUE
void TIFFWarningExt(thandle_t fd, const char *module, const char *fmt,...)
#define TIFFTAG_ROWSPERSTRIP
int TIFFSetupStrips(TIFF *tif)
#define FIELD_STRIPOFFSETS
#define TIFFTAG_STRIPBYTECOUNTS
#define TIFFInsertData(tif, type, v)
#define WriteOK(tif, buf, size)
#define FIELD_IMAGEDIMENSIONS
#define TIFFSeekFile(tif, off, whence)
#define TIFFTAG_IMAGEWIDTH
#define TIFFTAG_YRESOLUTION
uint16 * td_transferfunction[3]
#define FIELD_HALFTONEHINTS
TIFFTagValue * td_customValues
#define TIFFTAG_STRIPOFFSETS
void TIFFSwabArrayOfShort(uint16 *wp, register unsigned long n)
#define TIFFTAG_YPOSITION
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
#define FIELD_YCBCRSUBSAMPLING
GLboolean GLboolean GLboolean b
#define FIELD_SMAXSAMPLEVALUE
#define TIFFTAG_TILEBYTECOUNTS
#define FIELD_TRANSFERFUNCTION
unsigned long td_fieldsset[FIELD_SETLONGS]
void _TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c)
#define FIELD_MAXSAMPLEVALUE
GLenum GLuint GLenum GLsizei const GLchar * buf
#define FIELD_BITSPERSAMPLE
int _TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c)
const TIFFFieldInfo * info
#define TIFFTAG_TILEWIDTH
#define FIELD_STRIPBYTECOUNTS
TIFFDataType _TIFFSampleToTagType(TIFF *)
#define TIFFTAG_TILELENGTH
unsigned char field_passcount
int TIFFWriteDirectory(TIFF *tif)
#define TIFFTAG_IMAGELENGTH
#define TIFFTAG_TILEOFFSETS
void TIFFFreeDirectory(TIFF *tif)
#define TIFF_VERSION_SIZE
local int out(void *out_desc, unsigned char *buf, unsigned len)
GLsizei GLsizei GLenum GLenum const GLvoid * data
void TIFFSwabShort(uint16 *wp)
TIFFBoolMethod tif_postencode
#define TIFFTAG_XPOSITION
typedef long(ZCALLBACK *tell_file_func) OF((voidpf opaque
#define FIELD_PHOTOMETRIC
#define ResetFieldBit(fields, f)
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
#define TIFFTAG_PHOTOMETRIC
void TIFFSwabArrayOfLong(register uint32 *lp, register unsigned long n)
#define TIFFFieldSet(tif, field)
#define FIELD_COMPRESSION
#define FIELD_SMINSAMPLEVALUE
#define FIELD_ROWSPERSTRIP
#define TIFFTAG_TRANSFERFUNCTION
TIFFFieldInfo ** tif_fieldinfo
#define TIFFTAG_COMPRESSION
TIFFVoidMethod tif_cleanup
if(!abbox) return FT_THROW(Invalid_Argument)
uint16 td_samplesperpixel
int TIFFDataWidth(TIFFDataType type)
#define FIELD_EXTRASAMPLES
void TIFFSetWriteOffset(TIFF *tif, toff_t off)
#define TIFFCvtNativeToIEEEDouble(tif, n, dp)
void TIFFSwabArrayOfDouble(double *dp, register unsigned long n)
const TIFFFieldInfo * _TIFFFieldWithTag(TIFF *tif, ttag_t tag)
GLubyte GLubyte GLubyte GLubyte w
int TIFFCheckpointDirectory(TIFF *tif)
void TIFFSwabLong(uint32 *lp)
#define TIFFTAG_XRESOLUTION
#define FIELD_TILEDIMENSIONS
#define FieldSet(fields, f)
void * _TIFFmalloc(tsize_t s)
#define ReadOK(file, buffer, len)
int TIFFGetField(TIFF *tif, ttag_t tag,...)
#define TIFFCvtNativeToIEEEFloat(tif, n, fp)
void _TIFFfree(tdata_t p)
int TIFFCreateDirectory(TIFF *tif)
GLenum GLsizei GLenum GLenum const GLvoid * table
#define FIELD_SAMPLEFORMAT
#define WriteRationalPair(type, tag1, v1, tag2, v2)
int TIFFFlushData1(TIFF *tif)
#define FIELD_SUBFILETYPE
uint32 * td_stripbytecount