Visualization Library 2.0.0-b5

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
tif_dir.c
Go to the documentation of this file.
1 /* $Id: tif_dir.c,v 1.72 2006/03/15 12:49:35 dron Exp $ */
2 
3 /*
4  * Copyright (c) 1988-1997 Sam Leffler
5  * Copyright (c) 1991-1997 Silicon Graphics, Inc.
6  *
7  * Permission to use, copy, modify, distribute, and sell this software and
8  * its documentation for any purpose is hereby granted without fee, provided
9  * that (i) the above copyright notices and this permission notice appear in
10  * all copies of the software and related documentation, and (ii) the names of
11  * Sam Leffler and Silicon Graphics may not be used in any advertising or
12  * publicity relating to the software without the specific, prior written
13  * permission of Sam Leffler and Silicon Graphics.
14  *
15  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
17  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
18  *
19  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
20  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
21  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
22  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24  * OF THIS SOFTWARE.
25  */
26 
27 /*
28  * TIFF Library.
29  *
30  * Directory Tag Get & Set Routines.
31  * (and also some miscellaneous stuff)
32  */
33 #include "tiffiop.h"
34 
35 /*
36  * These are used in the backwards compatibility code...
37  */
38 #define DATATYPE_VOID 0 /* !untyped data */
39 #define DATATYPE_INT 1 /* !signed integer data */
40 #define DATATYPE_UINT 2 /* !unsigned integer data */
41 #define DATATYPE_IEEEFP 3 /* !IEEE floating point data */
42 
43 static void
44 setByteArray(void** vpp, void* vp, size_t nmemb, size_t elem_size)
45 {
46  if (*vpp)
47  _TIFFfree(*vpp), *vpp = 0;
48  if (vp) {
49  tsize_t bytes = nmemb * elem_size;
50  if (elem_size && bytes / elem_size == nmemb)
51  *vpp = (void*) _TIFFmalloc(bytes);
52  if (*vpp)
53  _TIFFmemcpy(*vpp, vp, bytes);
54  }
55 }
56 void _TIFFsetByteArray(void** vpp, void* vp, uint32 n)
57  { setByteArray(vpp, vp, n, 1); }
58 void _TIFFsetString(char** cpp, char* cp)
59  { setByteArray((void**) cpp, (void*) cp, strlen(cp)+1, 1); }
60 void _TIFFsetNString(char** cpp, char* cp, uint32 n)
61  { setByteArray((void**) cpp, (void*) cp, n, 1); }
63  { setByteArray((void**) wpp, (void*) wp, n, sizeof (uint16)); }
65  { setByteArray((void**) lpp, (void*) lp, n, sizeof (uint32)); }
66 void _TIFFsetFloatArray(float** fpp, float* fp, uint32 n)
67  { setByteArray((void**) fpp, (void*) fp, n, sizeof (float)); }
68 void _TIFFsetDoubleArray(double** dpp, double* dp, uint32 n)
69  { setByteArray((void**) dpp, (void*) dp, n, sizeof (double)); }
70 
71 /*
72  * Install extra samples information.
73  */
74 static int
75 setExtraSamples(TIFFDirectory* td, va_list ap, uint32* v)
76 {
77  uint16* va;
78  uint32 i;
79 
80  *v = va_arg(ap, uint32);
81  if ((uint16) *v > td->td_samplesperpixel)
82  return (0);
83  va = va_arg(ap, uint16*);
84  if (*v > 0 && va == NULL) /* typically missing param */
85  return (0);
86  for (i = 0; i < *v; i++)
87  if (va[i] > EXTRASAMPLE_UNASSALPHA)
88  return (0);
89  td->td_extrasamples = (uint16) *v;
91  return (1);
92 }
93 
94 static uint32
95 checkInkNamesString(TIFF* tif, uint32 slen, const char* s)
96 {
97  TIFFDirectory* td = &tif->tif_dir;
99 
100  if (slen > 0) {
101  const char* ep = s+slen;
102  const char* cp = s;
103  for (; i > 0; i--) {
104  for (; *cp != '\0'; cp++)
105  if (cp >= ep)
106  goto bad;
107  cp++; /* skip \0 */
108  }
109  return (cp-s);
110  }
111 bad:
112  TIFFErrorExt(tif->tif_clientdata, "TIFFSetField",
113  "%s: Invalid InkNames value; expecting %d names, found %d",
114  tif->tif_name,
115  td->td_samplesperpixel,
116  td->td_samplesperpixel-i);
117  return (0);
118 }
119 
120 static int
121 _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
122 {
123  static const char module[] = "_TIFFVSetField";
124 
125  TIFFDirectory* td = &tif->tif_dir;
126  int status = 1;
127  uint32 v32, i, v;
128  char* s;
129 
130  switch (tag) {
131  case TIFFTAG_SUBFILETYPE:
132  td->td_subfiletype = va_arg(ap, uint32);
133  break;
134  case TIFFTAG_IMAGEWIDTH:
135  td->td_imagewidth = va_arg(ap, uint32);
136  break;
137  case TIFFTAG_IMAGELENGTH:
138  td->td_imagelength = va_arg(ap, uint32);
139  break;
141  td->td_bitspersample = (uint16) va_arg(ap, int);
142  /*
143  * If the data require post-decoding processing to byte-swap
144  * samples, set it up here. Note that since tags are required
145  * to be ordered, compression code can override this behaviour
146  * in the setup method if it wants to roll the post decoding
147  * work in with its normal work.
148  */
149  if (tif->tif_flags & TIFF_SWAB) {
150  if (td->td_bitspersample == 16)
152  else if (td->td_bitspersample == 24)
154  else if (td->td_bitspersample == 32)
156  else if (td->td_bitspersample == 64)
158  else if (td->td_bitspersample == 128) /* two 64's */
160  }
161  break;
162  case TIFFTAG_COMPRESSION:
163  v = va_arg(ap, uint32) & 0xffff;
164  /*
165  * If we're changing the compression scheme, the notify the
166  * previous module so that it can cleanup any state it's
167  * setup.
168  */
169  if (TIFFFieldSet(tif, FIELD_COMPRESSION)) {
170  if (td->td_compression == v)
171  break;
172  (*tif->tif_cleanup)(tif);
173  tif->tif_flags &= ~TIFF_CODERSETUP;
174  }
175  /*
176  * Setup new compression routine state.
177  */
178  if( (status = TIFFSetCompressionScheme(tif, v)) != 0 )
179  td->td_compression = (uint16) v;
180  else
181  status = 0;
182  break;
183  case TIFFTAG_PHOTOMETRIC:
184  td->td_photometric = (uint16) va_arg(ap, int);
185  break;
187  td->td_threshholding = (uint16) va_arg(ap, int);
188  break;
189  case TIFFTAG_FILLORDER:
190  v = va_arg(ap, uint32);
191  if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB)
192  goto badvalue;
193  td->td_fillorder = (uint16) v;
194  break;
195  break;
196  case TIFFTAG_ORIENTATION:
197  v = va_arg(ap, uint32);
198  if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v) {
200  "Bad value %lu for \"%s\" tag ignored",
201  v, _TIFFFieldWithTag(tif, tag)->field_name);
202  } else
203  td->td_orientation = (uint16) v;
204  break;
206  /* XXX should cross check -- e.g. if pallette, then 1 */
207  v = va_arg(ap, uint32);
208  if (v == 0)
209  goto badvalue;
210  td->td_samplesperpixel = (uint16) v;
211  break;
213  v32 = va_arg(ap, uint32);
214  if (v32 == 0)
215  goto badvalue32;
216  td->td_rowsperstrip = v32;
217  if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) {
218  td->td_tilelength = v32;
219  td->td_tilewidth = td->td_imagewidth;
220  }
221  break;
223  td->td_minsamplevalue = (uint16) va_arg(ap, int);
224  break;
226  td->td_maxsamplevalue = (uint16) va_arg(ap, int);
227  break;
229  td->td_sminsamplevalue = va_arg(ap, double);
230  break;
232  td->td_smaxsamplevalue = va_arg(ap, double);
233  break;
234  case TIFFTAG_XRESOLUTION:
235  td->td_xresolution = (float) va_arg(ap, double);
236  break;
237  case TIFFTAG_YRESOLUTION:
238  td->td_yresolution = (float) va_arg(ap, double);
239  break;
241  v = va_arg(ap, uint32);
243  goto badvalue;
244  td->td_planarconfig = (uint16) v;
245  break;
246  case TIFFTAG_XPOSITION:
247  td->td_xposition = (float) va_arg(ap, double);
248  break;
249  case TIFFTAG_YPOSITION:
250  td->td_yposition = (float) va_arg(ap, double);
251  break;
253  v = va_arg(ap, uint32);
254  if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v)
255  goto badvalue;
256  td->td_resolutionunit = (uint16) v;
257  break;
258  case TIFFTAG_PAGENUMBER:
259  td->td_pagenumber[0] = (uint16) va_arg(ap, int);
260  td->td_pagenumber[1] = (uint16) va_arg(ap, int);
261  break;
263  td->td_halftonehints[0] = (uint16) va_arg(ap, int);
264  td->td_halftonehints[1] = (uint16) va_arg(ap, int);
265  break;
266  case TIFFTAG_COLORMAP:
267  v32 = (uint32)(1L<<td->td_bitspersample);
268  _TIFFsetShortArray(&td->td_colormap[0], va_arg(ap, uint16*), v32);
269  _TIFFsetShortArray(&td->td_colormap[1], va_arg(ap, uint16*), v32);
270  _TIFFsetShortArray(&td->td_colormap[2], va_arg(ap, uint16*), v32);
271  break;
273  if (!setExtraSamples(td, ap, &v))
274  goto badvalue;
275  break;
276  case TIFFTAG_MATTEING:
277  td->td_extrasamples = (uint16) (va_arg(ap, int) != 0);
278  if (td->td_extrasamples) {
280  _TIFFsetShortArray(&td->td_sampleinfo, &sv, 1);
281  }
282  break;
283  case TIFFTAG_TILEWIDTH:
284  v32 = va_arg(ap, uint32);
285  if (v32 % 16) {
286  if (tif->tif_mode != O_RDONLY)
287  goto badvalue32;
289  "Nonstandard tile width %d, convert file", v32);
290  }
291  td->td_tilewidth = v32;
292  tif->tif_flags |= TIFF_ISTILED;
293  break;
294  case TIFFTAG_TILELENGTH:
295  v32 = va_arg(ap, uint32);
296  if (v32 % 16) {
297  if (tif->tif_mode != O_RDONLY)
298  goto badvalue32;
300  "Nonstandard tile length %d, convert file", v32);
301  }
302  td->td_tilelength = v32;
303  tif->tif_flags |= TIFF_ISTILED;
304  break;
305  case TIFFTAG_TILEDEPTH:
306  v32 = va_arg(ap, uint32);
307  if (v32 == 0)
308  goto badvalue32;
309  td->td_tiledepth = v32;
310  break;
311  case TIFFTAG_DATATYPE:
312  v = va_arg(ap, uint32);
313  switch (v) {
314  case DATATYPE_VOID: v = SAMPLEFORMAT_VOID; break;
315  case DATATYPE_INT: v = SAMPLEFORMAT_INT; break;
316  case DATATYPE_UINT: v = SAMPLEFORMAT_UINT; break;
317  case DATATYPE_IEEEFP: v = SAMPLEFORMAT_IEEEFP;break;
318  default: goto badvalue;
319  }
320  td->td_sampleformat = (uint16) v;
321  break;
323  v = va_arg(ap, uint32);
325  goto badvalue;
326  td->td_sampleformat = (uint16) v;
327 
328  /* Try to fix up the SWAB function for complex data. */
330  && td->td_bitspersample == 32
333  else if( (td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT
335  && td->td_bitspersample == 64
338  break;
339  case TIFFTAG_IMAGEDEPTH:
340  td->td_imagedepth = va_arg(ap, uint32);
341  break;
342  case TIFFTAG_SUBIFD:
343  if ((tif->tif_flags & TIFF_INSUBIFD) == 0) {
344  td->td_nsubifd = (uint16) va_arg(ap, int);
345  _TIFFsetLongArray(&td->td_subifd, va_arg(ap, uint32*),
346  (long) td->td_nsubifd);
347  } else {
348  TIFFErrorExt(tif->tif_clientdata, module, "%s: Sorry, cannot nest SubIFDs",
349  tif->tif_name);
350  status = 0;
351  }
352  break;
354  td->td_ycbcrpositioning = (uint16) va_arg(ap, int);
355  break;
357  td->td_ycbcrsubsampling[0] = (uint16) va_arg(ap, int);
358  td->td_ycbcrsubsampling[1] = (uint16) va_arg(ap, int);
359  break;
361  v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1;
362  for (i = 0; i < v; i++)
364  va_arg(ap, uint16*), 1L<<td->td_bitspersample);
365  break;
366  case TIFFTAG_INKNAMES:
367  v = va_arg(ap, uint32);
368  s = va_arg(ap, char*);
369  v = checkInkNamesString(tif, v, s);
370  status = v > 0;
371  if( v > 0 ) {
372  _TIFFsetNString(&td->td_inknames, s, v);
373  td->td_inknameslen = v;
374  }
375  break;
376  default: {
377  const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY);
378  TIFFTagValue *tv;
379  int tv_size, iCustom;
380 
381  /*
382  * This can happen if multiple images are open with different
383  * codecs which have private tags. The global tag information
384  * table may then have tags that are valid for one file but not
385  * the other. If the client tries to set a tag that is not valid
386  * for the image's codec then we'll arrive here. This
387  * happens, for example, when tiffcp is used to convert between
388  * compression schemes and codec-specific tags are blindly copied.
389  */
390  if(fip == NULL || fip->field_bit != FIELD_CUSTOM) {
391  TIFFErrorExt(tif->tif_clientdata, module,
392  "%s: Invalid %stag \"%s\" (not supported by codec)",
393  tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
394  _TIFFFieldWithTag(tif, tag)->field_name);
395  status = 0;
396  break;
397  }
398 
399  /*
400  * Find the existing entry for this custom value.
401  */
402  tv = NULL;
403  for(iCustom = 0; iCustom < td->td_customValueCount; iCustom++) {
404  if(td->td_customValues[iCustom].info == fip) {
405  tv = td->td_customValues + iCustom;
406  if(tv->value != NULL)
407  {
408  _TIFFfree(tv->value);
409  tv->value = NULL;
410  }
411  break;
412  }
413  }
414 
415  /*
416  * Grow the custom list if the entry was not found.
417  */
418  if(tv == NULL) {
419  TIFFTagValue *new_customValues;
420 
421  td->td_customValueCount++;
422  new_customValues = (TIFFTagValue *)
424  sizeof(TIFFTagValue) * td->td_customValueCount);
425  if (!new_customValues) {
426  TIFFErrorExt(tif->tif_clientdata, module,
427  "%s: Failed to allocate space for list of custom values",
428  tif->tif_name);
429  status = 0;
430  goto end;
431  }
432 
433  td->td_customValues = new_customValues;
434 
435  tv = td->td_customValues + (td->td_customValueCount-1);
436  tv->info = fip;
437  tv->value = NULL;
438  tv->count = 0;
439  }
440 
441  /*
442  * Set custom value ... save a copy of the custom tag value.
443  */
444  tv_size = _TIFFDataSize(fip->field_type);
445  if (tv_size == 0) {
446  status = 0;
447  TIFFErrorExt(tif->tif_clientdata, module,
448  "%s: Bad field type %d for \"%s\"",
449  tif->tif_name, fip->field_type,
450  fip->field_name);
451  goto end;
452  }
453 
454  if(fip->field_passcount) {
455  if (fip->field_writecount == TIFF_VARIABLE2)
456  tv->count = (uint32) va_arg(ap, uint32);
457  else
458  tv->count = (int) va_arg(ap, int);
459  } else if (fip->field_writecount == TIFF_VARIABLE
460  || fip->field_writecount == TIFF_VARIABLE2)
461  tv->count = 1;
462  else if (fip->field_writecount == TIFF_SPP)
463  tv->count = td->td_samplesperpixel;
464  else
465  tv->count = fip->field_writecount;
466 
467 
468  if (fip->field_type == TIFF_ASCII)
469  _TIFFsetString((char **)&tv->value, va_arg(ap, char *));
470  else {
471  tv->value = _TIFFmalloc(tv_size * tv->count);
472  if (!tv->value) {
473  status = 0;
474  goto end;
475  }
476 
477  if ((fip->field_passcount
480  || fip->field_writecount == TIFF_SPP
481  || tv->count > 1)
482  && fip->field_tag != TIFFTAG_PAGENUMBER
485  && fip->field_tag != TIFFTAG_DOTRANGE) {
486  _TIFFmemcpy(tv->value, va_arg(ap, void *),
487  tv->count * tv_size);
488  } else {
489  /*
490  * XXX: The following loop required to handle
491  * TIFFTAG_PAGENUMBER, TIFFTAG_HALFTONEHINTS,
492  * TIFFTAG_YCBCRSUBSAMPLING and TIFFTAG_DOTRANGE tags.
493  * These tags are actually arrays and should be passed as
494  * array pointers to TIFFSetField() function, but actually
495  * passed as a list of separate values. This behaviour
496  * must be changed in the future!
497  */
498  int i;
499  char *val = (char *)tv->value;
500 
501  for (i = 0; i < tv->count; i++, val += tv_size) {
502  switch (fip->field_type) {
503  case TIFF_BYTE:
504  case TIFF_UNDEFINED:
505  {
506  uint8 v = (uint8)va_arg(ap, int);
507  _TIFFmemcpy(val, &v, tv_size);
508  }
509  break;
510  case TIFF_SBYTE:
511  {
512  int8 v = (int8)va_arg(ap, int);
513  _TIFFmemcpy(val, &v, tv_size);
514  }
515  break;
516  case TIFF_SHORT:
517  {
518  uint16 v = (uint16)va_arg(ap, int);
519  _TIFFmemcpy(val, &v, tv_size);
520  }
521  break;
522  case TIFF_SSHORT:
523  {
524  int16 v = (int16)va_arg(ap, int);
525  _TIFFmemcpy(val, &v, tv_size);
526  }
527  break;
528  case TIFF_LONG:
529  case TIFF_IFD:
530  {
531  uint32 v = va_arg(ap, uint32);
532  _TIFFmemcpy(val, &v, tv_size);
533  }
534  break;
535  case TIFF_SLONG:
536  {
537  int32 v = va_arg(ap, int32);
538  _TIFFmemcpy(val, &v, tv_size);
539  }
540  break;
541  case TIFF_RATIONAL:
542  case TIFF_SRATIONAL:
543  case TIFF_FLOAT:
544  {
545  float v = (float)va_arg(ap, double);
546  _TIFFmemcpy(val, &v, tv_size);
547  }
548  break;
549  case TIFF_DOUBLE:
550  {
551  double v = va_arg(ap, double);
552  _TIFFmemcpy(val, &v, tv_size);
553  }
554  break;
555  default:
556  _TIFFmemset(val, 0, tv_size);
557  status = 0;
558  break;
559  }
560  }
561  }
562  }
563  }
564  }
565  if (status) {
566  TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit);
567  tif->tif_flags |= TIFF_DIRTYDIRECT;
568  }
569 
570 end:
571  va_end(ap);
572  return (status);
573 badvalue:
574  TIFFErrorExt(tif->tif_clientdata, module, "%s: Bad value %d for \"%s\"",
575  tif->tif_name, v, _TIFFFieldWithTag(tif, tag)->field_name);
576  va_end(ap);
577  return (0);
578 badvalue32:
579  TIFFErrorExt(tif->tif_clientdata, module, "%s: Bad value %ld for \"%s\"",
580  tif->tif_name, v32, _TIFFFieldWithTag(tif, tag)->field_name);
581  va_end(ap);
582  return (0);
583 }
584 
585 /*
586  * Return 1/0 according to whether or not
587  * it is permissible to set the tag's value.
588  * Note that we allow ImageLength to be changed
589  * so that we can append and extend to images.
590  * Any other tag may not be altered once writing
591  * has commenced, unless its value has no effect
592  * on the format of the data that is written.
593  */
594 static int
595 OkToChangeTag(TIFF* tif, ttag_t tag)
596 {
597  const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY);
598  if (!fip) { /* unknown tag */
599  TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Unknown %stag %u",
600  tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag);
601  return (0);
602  }
603  if (tag != TIFFTAG_IMAGELENGTH && (tif->tif_flags & TIFF_BEENWRITING) &&
604  !fip->field_oktochange) {
605  /*
606  * Consult info table to see if tag can be changed
607  * after we've started writing. We only allow changes
608  * to those tags that don't/shouldn't affect the
609  * compression and/or format of the data.
610  */
611  TIFFErrorExt(tif->tif_clientdata, "TIFFSetField",
612  "%s: Cannot modify tag \"%s\" while writing",
613  tif->tif_name, fip->field_name);
614  return (0);
615  }
616  return (1);
617 }
618 
619 /*
620  * Record the value of a field in the
621  * internal directory structure. The
622  * field will be written to the file
623  * when/if the directory structure is
624  * updated.
625  */
626 int
627 TIFFSetField(TIFF* tif, ttag_t tag, ...)
628 {
629  va_list ap;
630  int status;
631 
632  va_start(ap, tag);
633  status = TIFFVSetField(tif, tag, ap);
634  va_end(ap);
635  return (status);
636 }
637 
638 /*
639  * Like TIFFSetField, but taking a varargs
640  * parameter list. This routine is useful
641  * for building higher-level interfaces on
642  * top of the library.
643  */
644 int
645 TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
646 {
647  return OkToChangeTag(tif, tag) ?
648  (*tif->tif_tagmethods.vsetfield)(tif, tag, ap) : 0;
649 }
650 
651 static int
652 _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
653 {
654  TIFFDirectory* td = &tif->tif_dir;
655  int ret_val = 1;
656 
657  switch (tag) {
658  case TIFFTAG_SUBFILETYPE:
659  *va_arg(ap, uint32*) = td->td_subfiletype;
660  break;
661  case TIFFTAG_IMAGEWIDTH:
662  *va_arg(ap, uint32*) = td->td_imagewidth;
663  break;
664  case TIFFTAG_IMAGELENGTH:
665  *va_arg(ap, uint32*) = td->td_imagelength;
666  break;
668  *va_arg(ap, uint16*) = td->td_bitspersample;
669  break;
670  case TIFFTAG_COMPRESSION:
671  *va_arg(ap, uint16*) = td->td_compression;
672  break;
673  case TIFFTAG_PHOTOMETRIC:
674  *va_arg(ap, uint16*) = td->td_photometric;
675  break;
677  *va_arg(ap, uint16*) = td->td_threshholding;
678  break;
679  case TIFFTAG_FILLORDER:
680  *va_arg(ap, uint16*) = td->td_fillorder;
681  break;
682  case TIFFTAG_ORIENTATION:
683  *va_arg(ap, uint16*) = td->td_orientation;
684  break;
686  *va_arg(ap, uint16*) = td->td_samplesperpixel;
687  break;
689  *va_arg(ap, uint32*) = td->td_rowsperstrip;
690  break;
692  *va_arg(ap, uint16*) = td->td_minsamplevalue;
693  break;
695  *va_arg(ap, uint16*) = td->td_maxsamplevalue;
696  break;
698  *va_arg(ap, double*) = td->td_sminsamplevalue;
699  break;
701  *va_arg(ap, double*) = td->td_smaxsamplevalue;
702  break;
703  case TIFFTAG_XRESOLUTION:
704  *va_arg(ap, float*) = td->td_xresolution;
705  break;
706  case TIFFTAG_YRESOLUTION:
707  *va_arg(ap, float*) = td->td_yresolution;
708  break;
710  *va_arg(ap, uint16*) = td->td_planarconfig;
711  break;
712  case TIFFTAG_XPOSITION:
713  *va_arg(ap, float*) = td->td_xposition;
714  break;
715  case TIFFTAG_YPOSITION:
716  *va_arg(ap, float*) = td->td_yposition;
717  break;
719  *va_arg(ap, uint16*) = td->td_resolutionunit;
720  break;
721  case TIFFTAG_PAGENUMBER:
722  *va_arg(ap, uint16*) = td->td_pagenumber[0];
723  *va_arg(ap, uint16*) = td->td_pagenumber[1];
724  break;
726  *va_arg(ap, uint16*) = td->td_halftonehints[0];
727  *va_arg(ap, uint16*) = td->td_halftonehints[1];
728  break;
729  case TIFFTAG_COLORMAP:
730  *va_arg(ap, uint16**) = td->td_colormap[0];
731  *va_arg(ap, uint16**) = td->td_colormap[1];
732  *va_arg(ap, uint16**) = td->td_colormap[2];
733  break;
735  case TIFFTAG_TILEOFFSETS:
736  *va_arg(ap, uint32**) = td->td_stripoffset;
737  break;
740  *va_arg(ap, uint32**) = td->td_stripbytecount;
741  break;
742  case TIFFTAG_MATTEING:
743  *va_arg(ap, uint16*) =
744  (td->td_extrasamples == 1 &&
746  break;
748  *va_arg(ap, uint16*) = td->td_extrasamples;
749  *va_arg(ap, uint16**) = td->td_sampleinfo;
750  break;
751  case TIFFTAG_TILEWIDTH:
752  *va_arg(ap, uint32*) = td->td_tilewidth;
753  break;
754  case TIFFTAG_TILELENGTH:
755  *va_arg(ap, uint32*) = td->td_tilelength;
756  break;
757  case TIFFTAG_TILEDEPTH:
758  *va_arg(ap, uint32*) = td->td_tiledepth;
759  break;
760  case TIFFTAG_DATATYPE:
761  switch (td->td_sampleformat) {
762  case SAMPLEFORMAT_UINT:
763  *va_arg(ap, uint16*) = DATATYPE_UINT;
764  break;
765  case SAMPLEFORMAT_INT:
766  *va_arg(ap, uint16*) = DATATYPE_INT;
767  break;
768  case SAMPLEFORMAT_IEEEFP:
769  *va_arg(ap, uint16*) = DATATYPE_IEEEFP;
770  break;
771  case SAMPLEFORMAT_VOID:
772  *va_arg(ap, uint16*) = DATATYPE_VOID;
773  break;
774  }
775  break;
777  *va_arg(ap, uint16*) = td->td_sampleformat;
778  break;
779  case TIFFTAG_IMAGEDEPTH:
780  *va_arg(ap, uint32*) = td->td_imagedepth;
781  break;
782  case TIFFTAG_SUBIFD:
783  *va_arg(ap, uint16*) = td->td_nsubifd;
784  *va_arg(ap, uint32**) = td->td_subifd;
785  break;
787  *va_arg(ap, uint16*) = td->td_ycbcrpositioning;
788  break;
790  *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[0];
791  *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[1];
792  break;
794  *va_arg(ap, uint16**) = td->td_transferfunction[0];
795  if (td->td_samplesperpixel - td->td_extrasamples > 1) {
796  *va_arg(ap, uint16**) = td->td_transferfunction[1];
797  *va_arg(ap, uint16**) = td->td_transferfunction[2];
798  }
799  break;
800  case TIFFTAG_INKNAMES:
801  *va_arg(ap, char**) = td->td_inknames;
802  break;
803  default:
804  {
805  const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY);
806  int i;
807 
808  /*
809  * This can happen if multiple images are open with
810  * different codecs which have private tags. The
811  * global tag information table may then have tags
812  * that are valid for one file but not the other.
813  * If the client tries to get a tag that is not valid
814  * for the image's codec then we'll arrive here.
815  */
816  if( fip == NULL || fip->field_bit != FIELD_CUSTOM )
817  {
818  TIFFErrorExt(tif->tif_clientdata, "_TIFFVGetField",
819  "%s: Invalid %stag \"%s\" (not supported by codec)",
820  tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
821  _TIFFFieldWithTag(tif, tag)->field_name);
822  ret_val = 0;
823  break;
824  }
825 
826  /*
827  * Do we have a custom value?
828  */
829  ret_val = 0;
830  for (i = 0; i < td->td_customValueCount; i++) {
831  TIFFTagValue *tv = td->td_customValues + i;
832 
833  if (tv->info->field_tag != tag)
834  continue;
835 
836  if (fip->field_passcount) {
837  if (fip->field_readcount == TIFF_VARIABLE2)
838  *va_arg(ap, uint32*) = (uint32)tv->count;
839  else /* Assume TIFF_VARIABLE */
840  *va_arg(ap, uint16*) = (uint16)tv->count;
841  *va_arg(ap, void **) = tv->value;
842  ret_val = 1;
843  } else {
844  if ((fip->field_type == TIFF_ASCII
845  || fip->field_readcount == TIFF_VARIABLE
847  || fip->field_readcount == TIFF_SPP
848  || tv->count > 1)
849  && fip->field_tag != TIFFTAG_PAGENUMBER
852  && fip->field_tag != TIFFTAG_DOTRANGE) {
853  *va_arg(ap, void **) = tv->value;
854  ret_val = 1;
855  } else {
856  int j;
857  char *val = (char *)tv->value;
858 
859  for (j = 0; j < tv->count;
860  j++, val += _TIFFDataSize(tv->info->field_type)) {
861  switch (fip->field_type) {
862  case TIFF_BYTE:
863  case TIFF_UNDEFINED:
864  *va_arg(ap, uint8*) =
865  *(uint8 *)val;
866  ret_val = 1;
867  break;
868  case TIFF_SBYTE:
869  *va_arg(ap, int8*) =
870  *(int8 *)val;
871  ret_val = 1;
872  break;
873  case TIFF_SHORT:
874  *va_arg(ap, uint16*) =
875  *(uint16 *)val;
876  ret_val = 1;
877  break;
878  case TIFF_SSHORT:
879  *va_arg(ap, int16*) =
880  *(int16 *)val;
881  ret_val = 1;
882  break;
883  case TIFF_LONG:
884  case TIFF_IFD:
885  *va_arg(ap, uint32*) =
886  *(uint32 *)val;
887  ret_val = 1;
888  break;
889  case TIFF_SLONG:
890  *va_arg(ap, int32*) =
891  *(int32 *)val;
892  ret_val = 1;
893  break;
894  case TIFF_RATIONAL:
895  case TIFF_SRATIONAL:
896  case TIFF_FLOAT:
897  *va_arg(ap, float*) =
898  *(float *)val;
899  ret_val = 1;
900  break;
901  case TIFF_DOUBLE:
902  *va_arg(ap, double*) =
903  *(double *)val;
904  ret_val = 1;
905  break;
906  default:
907  ret_val = 0;
908  break;
909  }
910  }
911  }
912  }
913  break;
914  }
915  }
916  }
917  return(ret_val);
918 }
919 
920 /*
921  * Return the value of a field in the
922  * internal directory structure.
923  */
924 int
925 TIFFGetField(TIFF* tif, ttag_t tag, ...)
926 {
927  int status;
928  va_list ap;
929 
930  va_start(ap, tag);
931  status = TIFFVGetField(tif, tag, ap);
932  va_end(ap);
933  return (status);
934 }
935 
936 /*
937  * Like TIFFGetField, but taking a varargs
938  * parameter list. This routine is useful
939  * for building higher-level interfaces on
940  * top of the library.
941  */
942 int
943 TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
944 {
945  const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY);
946  return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit)) ?
947  (*tif->tif_tagmethods.vgetfield)(tif, tag, ap) : 0);
948 }
949 
950 #define CleanupField(member) { \
951  if (td->member) { \
952  _TIFFfree(td->member); \
953  td->member = 0; \
954  } \
955 }
956 
957 /*
958  * Release storage associated with a directory.
959  */
960 void
962 {
963  TIFFDirectory *td = &tif->tif_dir;
964  int i;
965 
967  CleanupField(td_colormap[0]);
968  CleanupField(td_colormap[1]);
969  CleanupField(td_colormap[2]);
970  CleanupField(td_sampleinfo);
971  CleanupField(td_subifd);
972  CleanupField(td_inknames);
973  CleanupField(td_transferfunction[0]);
974  CleanupField(td_transferfunction[1]);
975  CleanupField(td_transferfunction[2]);
976  CleanupField(td_stripoffset);
977  CleanupField(td_stripbytecount);
980 
981  /* Cleanup custom tag values */
982  for( i = 0; i < td->td_customValueCount; i++ ) {
983  if (td->td_customValues[i].value)
985  }
986 
987  td->td_customValueCount = 0;
988  CleanupField(td_customValues);
989 }
990 #undef CleanupField
991 
992 /*
993  * Client Tag extension support (from Niles Ritter).
994  */
995 static TIFFExtendProc _TIFFextender = (TIFFExtendProc) NULL;
996 
999 {
1000  TIFFExtendProc prev = _TIFFextender;
1001  _TIFFextender = extender;
1002  return (prev);
1003 }
1004 
1005 /*
1006  * Setup for a new directory. Should we automatically call
1007  * TIFFWriteDirectory() if the current one is dirty?
1008  *
1009  * The newly created directory will not exist on the file till
1010  * TIFFWriteDirectory(), TIFFFlush() or TIFFClose() is called.
1011  */
1012 int
1014 {
1015  TIFFDefaultDirectory(tif);
1016  tif->tif_diroff = 0;
1017  tif->tif_nextdiroff = 0;
1018  tif->tif_curoff = 0;
1019  tif->tif_row = (uint32) -1;
1020  tif->tif_curstrip = (tstrip_t) -1;
1021 
1022  return 0;
1023 }
1024 
1025 /*
1026  * Setup a default directory structure.
1027  */
1028 int
1030 {
1031  register TIFFDirectory* td = &tif->tif_dir;
1032 
1033  size_t tiffFieldInfoCount;
1034  const TIFFFieldInfo *tiffFieldInfo =
1035  _TIFFGetFieldInfo(&tiffFieldInfoCount);
1036  _TIFFSetupFieldInfo(tif, tiffFieldInfo, tiffFieldInfoCount);
1037 
1038  _TIFFmemset(td, 0, sizeof (*td));
1040  td->td_bitspersample = 1;
1043  td->td_samplesperpixel = 1;
1044  td->td_rowsperstrip = (uint32) -1;
1045  td->td_tilewidth = 0;
1046  td->td_tilelength = 0;
1047  td->td_tiledepth = 1;
1048  td->td_stripbytecountsorted = 1; /* Our own arrays always sorted. */
1051  td->td_imagedepth = 1;
1052  td->td_ycbcrsubsampling[0] = 2;
1053  td->td_ycbcrsubsampling[1] = 2;
1056  tif->tif_foundfield = NULL;
1057  tif->tif_tagmethods.vsetfield = _TIFFVSetField;
1058  tif->tif_tagmethods.vgetfield = _TIFFVGetField;
1059  tif->tif_tagmethods.printdir = NULL;
1060  /*
1061  * Give client code a chance to install their own
1062  * tag extensions & methods, prior to compression overloads.
1063  */
1064  if (_TIFFextender)
1065  (*_TIFFextender)(tif);
1067  /*
1068  * NB: The directory is marked dirty as a result of setting
1069  * up the default compression scheme. However, this really
1070  * isn't correct -- we want TIFF_DIRTYDIRECT to be set only
1071  * if the user does something. We could just do the setup
1072  * by hand, but it seems better to use the normal mechanism
1073  * (i.e. TIFFSetField).
1074  */
1075  tif->tif_flags &= ~TIFF_DIRTYDIRECT;
1076 
1077  /*
1078  * As per http://bugzilla.remotesensing.org/show_bug.cgi?id=19
1079  * we clear the ISTILED flag when setting up a new directory.
1080  * Should we also be clearing stuff like INSUBIFD?
1081  */
1082  tif->tif_flags &= ~TIFF_ISTILED;
1083 
1084  return (1);
1085 }
1086 
1087 static int
1088 TIFFAdvanceDirectory(TIFF* tif, uint32* nextdir, toff_t* off)
1089 {
1090  static const char module[] = "TIFFAdvanceDirectory";
1091  uint16 dircount;
1092  if (isMapped(tif))
1093  {
1094  toff_t poff=*nextdir;
1095  if (poff+sizeof(uint16) > tif->tif_size)
1096  {
1097  TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count",
1098  tif->tif_name);
1099  return (0);
1100  }
1101  _TIFFmemcpy(&dircount, tif->tif_base+poff, sizeof (uint16));
1102  if (tif->tif_flags & TIFF_SWAB)
1103  TIFFSwabShort(&dircount);
1104  poff+=sizeof (uint16)+dircount*sizeof (TIFFDirEntry);
1105  if (off != NULL)
1106  *off = poff;
1107  if (((toff_t) (poff+sizeof (uint32))) > tif->tif_size)
1108  {
1109  TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link",
1110  tif->tif_name);
1111  return (0);
1112  }
1113  _TIFFmemcpy(nextdir, tif->tif_base+poff, sizeof (uint32));
1114  if (tif->tif_flags & TIFF_SWAB)
1115  TIFFSwabLong(nextdir);
1116  return (1);
1117  }
1118  else
1119  {
1120  if (!SeekOK(tif, *nextdir) ||
1121  !ReadOK(tif, &dircount, sizeof (uint16))) {
1122  TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count",
1123  tif->tif_name);
1124  return (0);
1125  }
1126  if (tif->tif_flags & TIFF_SWAB)
1127  TIFFSwabShort(&dircount);
1128  if (off != NULL)
1129  *off = TIFFSeekFile(tif,
1130  dircount*sizeof (TIFFDirEntry), SEEK_CUR);
1131  else
1132  (void) TIFFSeekFile(tif,
1133  dircount*sizeof (TIFFDirEntry), SEEK_CUR);
1134  if (!ReadOK(tif, nextdir, sizeof (uint32))) {
1135  TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link",
1136  tif->tif_name);
1137  return (0);
1138  }
1139  if (tif->tif_flags & TIFF_SWAB)
1140  TIFFSwabLong(nextdir);
1141  return (1);
1142  }
1143 }
1144 
1145 /*
1146  * Count the number of directories in a file.
1147  */
1148 tdir_t
1150 {
1151  toff_t nextdir = tif->tif_header.tiff_diroff;
1152  tdir_t n = 0;
1153 
1154  while (nextdir != 0 && TIFFAdvanceDirectory(tif, &nextdir, NULL))
1155  n++;
1156  return (n);
1157 }
1158 
1159 /*
1160  * Set the n-th directory as the current directory.
1161  * NB: Directories are numbered starting at 0.
1162  */
1163 int
1165 {
1166  toff_t nextdir;
1167  tdir_t n;
1168 
1169  nextdir = tif->tif_header.tiff_diroff;
1170  for (n = dirn; n > 0 && nextdir != 0; n--)
1171  if (!TIFFAdvanceDirectory(tif, &nextdir, NULL))
1172  return (0);
1173  tif->tif_nextdiroff = nextdir;
1174  /*
1175  * Set curdir to the actual directory index. The
1176  * -1 is because TIFFReadDirectory will increment
1177  * tif_curdir after successfully reading the directory.
1178  */
1179  tif->tif_curdir = (dirn - n) - 1;
1180  /*
1181  * Reset tif_dirnumber counter and start new list of seen directories.
1182  * We need this to prevent IFD loops.
1183  */
1184  tif->tif_dirnumber = 0;
1185  return (TIFFReadDirectory(tif));
1186 }
1187 
1188 /*
1189  * Set the current directory to be the directory
1190  * located at the specified file offset. This interface
1191  * is used mainly to access directories linked with
1192  * the SubIFD tag (e.g. thumbnail images).
1193  */
1194 int
1196 {
1197  tif->tif_nextdiroff = diroff;
1198  /*
1199  * Reset tif_dirnumber counter and start new list of seen directories.
1200  * We need this to prevent IFD loops.
1201  */
1202  tif->tif_dirnumber = 0;
1203  return (TIFFReadDirectory(tif));
1204 }
1205 
1206 /*
1207  * Return file offset of the current directory.
1208  */
1209 uint32
1211 {
1212  return (tif->tif_diroff);
1213 }
1214 
1215 /*
1216  * Return an indication of whether or not we are
1217  * at the last directory in the file.
1218  */
1219 int
1221 {
1222  return (tif->tif_nextdiroff == 0);
1223 }
1224 
1225 /*
1226  * Unlink the specified directory from the directory chain.
1227  */
1228 int
1230 {
1231  static const char module[] = "TIFFUnlinkDirectory";
1232  toff_t nextdir;
1233  toff_t off;
1234  tdir_t n;
1235 
1236  if (tif->tif_mode == O_RDONLY) {
1237  TIFFErrorExt(tif->tif_clientdata, module,
1238  "Can not unlink directory in read-only file");
1239  return (0);
1240  }
1241  /*
1242  * Go to the directory before the one we want
1243  * to unlink and nab the offset of the link
1244  * field we'll need to patch.
1245  */
1246  nextdir = tif->tif_header.tiff_diroff;
1247  off = sizeof (uint16) + sizeof (uint16);
1248  for (n = dirn-1; n > 0; n--) {
1249  if (nextdir == 0) {
1250  TIFFErrorExt(tif->tif_clientdata, module, "Directory %d does not exist", dirn);
1251  return (0);
1252  }
1253  if (!TIFFAdvanceDirectory(tif, &nextdir, &off))
1254  return (0);
1255  }
1256  /*
1257  * Advance to the directory to be unlinked and fetch
1258  * the offset of the directory that follows.
1259  */
1260  if (!TIFFAdvanceDirectory(tif, &nextdir, NULL))
1261  return (0);
1262  /*
1263  * Go back and patch the link field of the preceding
1264  * directory to point to the offset of the directory
1265  * that follows.
1266  */
1267  (void) TIFFSeekFile(tif, off, SEEK_SET);
1268  if (tif->tif_flags & TIFF_SWAB)
1269  TIFFSwabLong(&nextdir);
1270  if (!WriteOK(tif, &nextdir, sizeof (uint32))) {
1271  TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link");
1272  return (0);
1273  }
1274  /*
1275  * Leave directory state setup safely. We don't have
1276  * facilities for doing inserting and removing directories,
1277  * so it's safest to just invalidate everything. This
1278  * means that the caller can only append to the directory
1279  * chain.
1280  */
1281  (*tif->tif_cleanup)(tif);
1282  if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) {
1283  _TIFFfree(tif->tif_rawdata);
1284  tif->tif_rawdata = NULL;
1285  tif->tif_rawcc = 0;
1286  }
1288  TIFFFreeDirectory(tif);
1289  TIFFDefaultDirectory(tif);
1290  tif->tif_diroff = 0; /* force link on next write */
1291  tif->tif_nextdiroff = 0; /* next write must be at end */
1292  tif->tif_curoff = 0;
1293  tif->tif_row = (uint32) -1;
1294  tif->tif_curstrip = (tstrip_t) -1;
1295  return (1);
1296 }
1297 
1298 /* [BFC]
1299  *
1300  * Author: Bruce Cameron <cameron@petris.com>
1301  *
1302  * Set a table of tags that are to be replaced during directory process by the
1303  * 'IGNORE' state - or return TRUE/FALSE for the requested tag such that
1304  * 'ReadDirectory' can use the stored information.
1305  *
1306  * FIXME: this is never used properly. Should be removed in the future.
1307  */
1308 int
1309 TIFFReassignTagToIgnore (enum TIFFIgnoreSense task, int TIFFtagID)
1310 {
1311  static int TIFFignoretags [FIELD_LAST];
1312  static int tagcount = 0 ;
1313  int i; /* Loop index */
1314  int j; /* Loop index */
1315 
1316  switch (task)
1317  {
1318  case TIS_STORE:
1319  if ( tagcount < (FIELD_LAST - 1) )
1320  {
1321  for ( j = 0 ; j < tagcount ; ++j )
1322  { /* Do not add duplicate tag */
1323  if ( TIFFignoretags [j] == TIFFtagID )
1324  return (TRUE) ;
1325  }
1326  TIFFignoretags [tagcount++] = TIFFtagID ;
1327  return (TRUE) ;
1328  }
1329  break ;
1330 
1331  case TIS_EXTRACT:
1332  for ( i = 0 ; i < tagcount ; ++i )
1333  {
1334  if ( TIFFignoretags [i] == TIFFtagID )
1335  return (TRUE) ;
1336  }
1337  break;
1338 
1339  case TIS_EMPTY:
1340  tagcount = 0 ; /* Clear the list */
1341  return (TRUE) ;
1342 
1343  default:
1344  break;
1345  }
1346 
1347  return (FALSE);
1348 }
1349 
1350 /* vim: set ts=8 sts=8 sw=8 noet: */
#define DATATYPE_IEEEFP
Definition: tif_dir.c:41
int32 tsize_t
Definition: tiffio.h:66
uint16 td_pagenumber[2]
Definition: tif_dir.h:59
#define TIFFTAG_SUBFILETYPE
Definition: tiff.h:157
uint32 ttag_t
Definition: tiffio.h:61
#define TIFF_BEENWRITING
Definition: tiffiop.h:105
TIFFTagMethods tif_tagmethods
Definition: tiffiop.h:183
uint16 td_threshholding
Definition: tif_dir.h:48
Definition: tiff.h:89
void _TIFFsetString(char **cpp, char *cp)
Definition: tif_dir.c:58
void _TIFFsetLongArray(uint32 **lpp, uint32 *lp, uint32 n)
Definition: tif_dir.c:64
uint32 td_imagewidth
Definition: tif_dir.h:41
for(n=1;n< outline->n_points;n++)
Definition: ftbbox.c:593
#define TIFF_VARIABLE
Definition: tiffio.h:295
#define FIELD_CUSTOM
Definition: tiffio.h:299
uint32 td_imagedepth
Definition: tif_dir.h:41
int TIFFReadDirectory(TIFF *tif)
Definition: tif_dirread.c:70
#define TIFFClrFieldBit(tif, field)
Definition: tif_dir.h:169
#define TIFFTAG_BITSPERSAMPLE
Definition: tiff.h:167
void TIFFWarningExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_warning.c:63
#define TIFFTAG_ROWSPERSTRIP
Definition: tiff.h:236
int TIFFLastDirectory(TIFF *tif)
Definition: tif_dir.c:1220
#define TIFF_ANY
Definition: tiffio.h:294
tstrip_t tif_curstrip
Definition: tiffiop.h:128
uint16 td_bitspersample
Definition: tif_dir.h:44
uint16 td_nsubifd
Definition: tif_dir.h:69
#define TIFFTAG_STRIPBYTECOUNTS
Definition: tiff.h:237
#define TIFFTAG_COLORMAP
Definition: tiff.h:287
#define THRESHHOLD_BILEVEL
Definition: tiff.h:213
float td_xresolution
Definition: tif_dir.h:55
uint16 td_minsamplevalue
Definition: tif_dir.h:53
#define NULL
Definition: ftobjs.h:61
#define TIFFTAG_EXTRASAMPLES
Definition: tiff.h:307
#define WriteOK(tif, buf, size)
Definition: tiffiop.h:220
#define TIFFTAG_ORIENTATION
Definition: tiff.h:226
#define isPseudoTag(t)
Definition: tiffiop.h:187
#define TIFFSeekFile(tif, off, whence)
Definition: tiffiop.h:197
#define TIFF_ISTILED
Definition: tiffiop.h:109
#define TIFFTAG_IMAGEWIDTH
Definition: tiff.h:165
#define TIFFTAG_YRESOLUTION
Definition: tiff.h:241
sizeof(AF_ModuleRec)
#define TIFFTAG_DATATYPE
Definition: tiff.h:363
#define TIFFTAG_MINSAMPLEVALUE
Definition: tiff.h:238
uint32 TIFFCurrentDirOffset(TIFF *tif)
Definition: tif_dir.c:1210
#define TIFFTAG_INKNAMES
Definition: tiff.h:303
#define TIFFTAG_FILLORDER
Definition: tiff.h:218
#define FIELD_LAST
Definition: tif_dir.h:153
uint32 * td_stripoffset
Definition: tif_dir.h:66
#define FILLORDER_LSB2MSB
Definition: tiff.h:220
unsigned char uint8
Definition: tiff.h:67
uint16 * td_transferfunction[3]
Definition: tif_dir.h:75
signed char int8
Definition: tiff.h:65
TIFFTagValue * td_customValues
Definition: tif_dir.h:81
#define TIFFTAG_DOTRANGE
Definition: tiff.h:305
tidata_t tif_rawdata
Definition: tiffiop.h:161
#define TIFFTAG_STRIPOFFSETS
Definition: tiff.h:225
#define TIFFTAG_SUBIFD
Definition: tiff.h:299
toff_t tif_curoff
Definition: tiffiop.h:129
#define TIFFTAG_THRESHHOLDING
Definition: tiff.h:212
void _TIFFSwab32BitData(TIFF *tif, tidata_t buf, tsize_t cc)
Definition: tif_read.c:635
uint32 td_subfiletype
Definition: tif_dir.h:43
#define TIFFTAG_YCBCRSUBSAMPLING
Definition: tiff.h:346
thandle_t tif_clientdata
Definition: tiffiop.h:171
#define TIFFTAG_YPOSITION
Definition: tiff.h:247
#define TIFFTAG_SMINSAMPLEVALUE
Definition: tiff.h:318
float td_xposition
Definition: tif_dir.h:58
#define TIFFTAG_PLANARCONFIG
Definition: tiff.h:242
#define ORIENTATION_TOPLEFT
Definition: tiff.h:227
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
#define TIFFTAG_MATTEING
Definition: tiff.h:362
char * tif_name
Definition: tiffiop.h:96
#define TIFF_DIRTYDIRECT
Definition: tiffiop.h:102
const TIFFFieldInfo * _TIFFGetFieldInfo(size_t *)
Definition: tif_dirinfo.c:513
int td_inknameslen
Definition: tif_dir.h:77
Definition: tiffiop.h:95
#define FIELD_YCBCRSUBSAMPLING
Definition: tif_dir.h:131
#define FIELD_SETLONGS
Definition: tif_dir.h:37
#define SAMPLEFORMAT_INT
Definition: tiff.h:313
#define RESUNIT_INCH
Definition: tiff.h:267
png_uint_32 i
Definition: png.h:2640
#define TIFFTAG_TILEBYTECOUNTS
Definition: tiff.h:292
Definition: tiff.h:116
uint16 td_extrasamples
Definition: tif_dir.h:62
unsigned long td_fieldsset[FIELD_SETLONGS]
Definition: tif_dir.h:39
void _TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c)
Definition: tif_acorn.c:485
TIFFPrintMethod printdir
Definition: tiffio.h:332
#define SEEK_CUR
Definition: zconf.h:250
#define TIFFSetFieldBit(tif, field)
Definition: tif_dir.h:168
int td_customValueCount
Definition: tif_dir.h:80
#define TIFF_SWAB
Definition: tiffiop.h:106
#define TIFFTAG_YCBCRPOSITIONING
Definition: tiff.h:347
const TIFFFieldInfo * info
Definition: tiffio.h:313
#define TIFFTAG_TILEWIDTH
Definition: tiff.h:289
#define DATATYPE_VOID
Definition: tif_dir.c:38
toff_t tif_size
Definition: tiffiop.h:167
uint32 tstrip_t
Definition: tiffio.h:64
uint16 td_ycbcrsubsampling[2]
Definition: tif_dir.h:72
uint16 td_orientation
Definition: tif_dir.h:50
#define YCBCRPOSITION_CENTERED
Definition: tiff.h:348
uint16 * td_sampleinfo
Definition: tif_dir.h:63
png_FILE_p fp
Definition: png.h:1791
Definition: tiff.h:87
void _TIFFsetFloatArray(float **fpp, float *fp, uint32 n)
Definition: tif_dir.c:66
#define TIFFTAG_TILELENGTH
Definition: tiff.h:290
int tif_mode
Definition: tiffiop.h:98
unsigned char field_passcount
Definition: tiffio.h:308
uint32 tif_flags
Definition: tiffiop.h:99
uint32 td_tilewidth
Definition: tif_dir.h:42
#define TIFFTAG_IMAGELENGTH
Definition: tiff.h:166
#define TIFFTAG_TILEOFFSETS
Definition: tiff.h:291
#define TIFFTAG_SAMPLESPERPIXEL
Definition: tiff.h:235
int TIFFVSetField(TIFF *tif, ttag_t tag, va_list ap)
Definition: tif_dir.c:645
uint32 td_tilelength
Definition: tif_dir.h:42
tidata_t tif_base
Definition: tiffiop.h:166
#define SAMPLEFORMAT_VOID
Definition: tiff.h:315
#define TIFF_POSTENCODE
Definition: tiffiop.h:111
#define isMapped(tif)
Definition: tiffiop.h:190
int TIFFSetDirectory(TIFF *tif, tdir_t dirn)
Definition: tif_dir.c:1164
#define CleanupField(member)
Definition: tif_dir.c:950
void TIFFFreeDirectory(TIFF *tif)
Definition: tif_dir.c:961
int td_stripbytecountsorted
Definition: tif_dir.h:68
const GLdouble * v
tdir_t tif_curdir
Definition: tiffiop.h:127
#define SAMPLEFORMAT_COMPLEXIEEEFP
Definition: tiff.h:317
unsigned short uint16
Definition: tiff.h:71
#define SAMPLEFORMAT_UINT
Definition: tiff.h:312
void TIFFSwabShort(uint16 *wp)
Definition: tif_swab.c:36
void _TIFFsetNString(char **cpp, char *cp, uint32 n)
Definition: tif_dir.c:60
uint16 * td_colormap[3]
Definition: tif_dir.h:60
TIFFVSetMethod vsetfield
Definition: tiffio.h:330
#define RESUNIT_CENTIMETER
Definition: tiff.h:268
uint32 td_imagelength
Definition: tif_dir.h:41
#define SAMPLEFORMAT_IEEEFP
Definition: tiff.h:314
TIFFPostMethod tif_postdecode
Definition: tiffiop.h:178
#define TIFFTAG_XPOSITION
Definition: tiff.h:246
GLuint GLfloat * val
GLdouble n
TIFFIgnoreSense
Definition: tiff.h:85
uint32 * td_subifd
Definition: tif_dir.h:70
#define TIFFTAG_HALFTONEHINTS
Definition: tiff.h:288
uint32 td_rowsperstrip
Definition: tif_dir.h:52
void * _TIFFrealloc(tdata_t p, tsize_t s)
Definition: tif_acorn.c:473
float td_yposition
Definition: tif_dir.h:58
uint16 td_maxsamplevalue
Definition: tif_dir.h:53
uint16 td_halftonehints[2]
Definition: tif_dir.h:61
uint16 td_planarconfig
Definition: tif_dir.h:57
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:63
#define TIFFTAG_PHOTOMETRIC
Definition: tiff.h:199
short field_readcount
Definition: tiffio.h:303
#define EXTRASAMPLE_UNASSALPHA
Definition: tiff.h:310
#define TIFFFieldSet(tif, field)
Definition: tif_dir.h:167
#define TIFFTAG_PAGENUMBER
Definition: tiff.h:269
int TIFFReassignTagToIgnore(enum TIFFIgnoreSense task, int TIFFtagID)
Definition: tif_dir.c:1309
tsize_t tif_rawcc
Definition: tiffiop.h:164
void _TIFFsetByteArray(void **vpp, void *vp, uint32 n)
Definition: tif_dir.c:56
#define FIELD_COMPRESSION
Definition: tif_dir.h:109
#define FALSE
Definition: ftobjs.h:57
uint16 tif_dirnumber
Definition: tiffiop.h:121
void(* TIFFExtendProc)(TIFF *)
Definition: tiffio.h:267
double td_smaxsamplevalue
Definition: tif_dir.h:54
#define TIFFTAG_TRANSFERFUNCTION
Definition: tiff.h:276
TIFFHeader tif_header
Definition: tiffiop.h:123
#define COMPRESSION_NONE
Definition: tiff.h:169
#define TIFFTAG_COMPRESSION
Definition: tiff.h:168
GLuint GLuint end
#define PLANARCONFIG_SEPARATE
Definition: tiff.h:244
TIFFVoidMethod tif_cleanup
Definition: tiffiop.h:154
void _TIFFmemset(tdata_t p, int v, tsize_t c)
Definition: tif_acorn.c:479
#define TIFFTAG_SMAXSAMPLEVALUE
Definition: tiff.h:319
#define DATATYPE_UINT
Definition: tif_dir.c:40
void _TIFFNoPostDecode(TIFF *tif, tidata_t buf, tsize_t cc)
Definition: tif_read.c:613
unsigned long uint32
Definition: md5.h:41
#define TIFF_BUFFERSETUP
Definition: tiffiop.h:103
uint16 td_samplesperpixel
Definition: tif_dir.h:51
#define TIFF_CODERSETUP
Definition: tiffiop.h:104
#define FIELD_YCBCRPOSITIONING
Definition: tif_dir.h:132
float td_yresolution
Definition: tif_dir.h:55
typedef int
Definition: png.h:978
void _TIFFSwab24BitData(TIFF *tif, tidata_t buf, tsize_t cc)
Definition: tif_read.c:627
int _TIFFDataSize(TIFFDataType type)
Definition: tif_dirinfo.c:655
int TIFFUnlinkDirectory(TIFF *tif, tdir_t dirn)
Definition: tif_dir.c:1229
#define TIFF_VARIABLE2
Definition: tiffio.h:297
char * td_inknames
Definition: tif_dir.h:78
int TIFFVGetField(TIFF *tif, ttag_t tag, va_list ap)
Definition: tif_dir.c:943
const TIFFFieldInfo * _TIFFFieldWithTag(TIFF *tif, ttag_t tag)
Definition: tif_dirinfo.c:771
double td_sminsamplevalue
Definition: tif_dir.h:54
void _TIFFSwab16BitData(TIFF *tif, tidata_t buf, tsize_t cc)
Definition: tif_read.c:619
uint32 tif_row
Definition: tiffiop.h:126
short int16
Definition: tiff.h:69
#define TIFFTAG_TILEDEPTH
Definition: tiff.h:365
#define TIFFTAG_IMAGEDEPTH
Definition: tiff.h:364
uint32 td_tiledepth
Definition: tif_dir.h:42
#define TIFFTAG_RESOLUTIONUNIT
Definition: tiff.h:265
void TIFFSwabLong(uint32 *lp)
Definition: tif_swab.c:47
#define TIFF_SPP
Definition: tiffio.h:296
uint16 td_ycbcrpositioning
Definition: tif_dir.h:73
#define TIFFTAG_XRESOLUTION
Definition: tiff.h:240
void _TIFFSwab64BitData(TIFF *tif, tidata_t buf, tsize_t cc)
Definition: tif_read.c:643
uint32 toff_t
Definition: tiffio.h:68
TIFFDirectory tif_dir
Definition: tiffiop.h:122
#define FIELD_TILEDIMENSIONS
Definition: tif_dir.h:102
int TIFFSetCompressionScheme(TIFF *tif, int scheme)
Definition: tif_compress.c:151
#define SeekOK(tif, off)
Definition: tiffiop.h:216
ttag_t field_tag
Definition: tiffio.h:302
const TIFFFieldInfo * tif_foundfield
Definition: tiffiop.h:182
uint16 tdir_t
Definition: tiffio.h:62
GLdouble s
int TIFFSetField(TIFF *tif, ttag_t tag,...)
Definition: tif_dir.c:627
uint16 td_compression
Definition: tif_dir.h:46
unsigned char field_oktochange
Definition: tiffio.h:307
TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc extender)
Definition: tif_dir.c:998
#define SAMPLEFORMAT_COMPLEXINT
Definition: tiff.h:316
const TIFFFieldInfo * _TIFFFindFieldInfo(TIFF *tif, ttag_t tag, TIFFDataType dt)
Definition: tif_dirinfo.c:705
void * _TIFFmalloc(tsize_t s)
Definition: tif_acorn.c:461
int TIFFDefaultDirectory(TIFF *tif)
Definition: tif_dir.c:1029
void _TIFFsetShortArray(uint16 **wpp, uint16 *wp, uint32 n)
Definition: tif_dir.c:62
char * field_name
Definition: tiffio.h:309
uint16 td_sampleformat
Definition: tif_dir.h:45
toff_t tif_nextdiroff
Definition: tiffiop.h:118
#define ReadOK(file, buffer, len)
Definition: rdbmp.c:45
int TIFFGetField(TIFF *tif, ttag_t tag,...)
Definition: tif_dir.c:925
TIFFDataType field_type
Definition: tiffio.h:305
#define DATATYPE_INT
Definition: tif_dir.c:39
#define RESUNIT_NONE
Definition: tiff.h:266
uint16 td_resolutionunit
Definition: tif_dir.h:56
void _TIFFfree(tdata_t p)
Definition: tif_acorn.c:467
tdir_t TIFFNumberOfDirectories(TIFF *tif)
Definition: tif_dir.c:1149
Definition: tiff.h:151
int TIFFCreateDirectory(TIFF *tif)
Definition: tif_dir.c:1013
#define TIFFTAG_SAMPLEFORMAT
Definition: tiff.h:311
#define EXTRASAMPLE_ASSOCALPHA
Definition: tiff.h:309
int TIFFSetSubDirectory(TIFF *tif, uint32 diroff)
Definition: tif_dir.c:1195
TIFFVGetMethod vgetfield
Definition: tiffio.h:331
void _TIFFsetDoubleArray(double **dpp, double *dp, uint32 n)
Definition: tif_dir.c:68
#define ORIENTATION_LEFTBOT
Definition: tiff.h:234
unsigned short field_bit
Definition: tiffio.h:306
#define TIFF_INSUBIFD
Definition: tiffiop.h:112
#define TRUE
Definition: ftobjs.h:53
#define FILLORDER_MSB2LSB
Definition: tiff.h:219
#define TIFFTAG_MAXSAMPLEVALUE
Definition: tiff.h:239
#define TIFF_MYBUFFER
Definition: tiffiop.h:108
short field_writecount
Definition: tiffio.h:304
#define SEEK_SET
Definition: zconf.h:249
void * value
Definition: tiffio.h:315
uint32 tiff_diroff
Definition: tiff.h:100
#define PLANARCONFIG_CONTIG
Definition: tiff.h:243
toff_t tif_diroff
Definition: tiffiop.h:117
uint16 td_photometric
Definition: tif_dir.h:47
uint16 td_fillorder
Definition: tif_dir.h:49
void _TIFFSetupFieldInfo(TIFF *, const TIFFFieldInfo[], size_t)
Definition: tif_dirinfo.c:527
uint32 * td_stripbytecount
Definition: tif_dir.h:67