ReactOS  0.4.15-dev-1177-g6cb3b62
tif_print.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1988-1997 Sam Leffler
3  * Copyright (c) 1991-1997 Silicon Graphics, Inc.
4  *
5  * Permission to use, copy, modify, distribute, and sell this software and
6  * its documentation for any purpose is hereby granted without fee, provided
7  * that (i) the above copyright notices and this permission notice appear in
8  * all copies of the software and related documentation, and (ii) the names of
9  * Sam Leffler and Silicon Graphics may not be used in any advertising or
10  * publicity relating to the software without the specific, prior written
11  * permission of Sam Leffler and Silicon Graphics.
12  *
13  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
14  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
18  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22  * OF THIS SOFTWARE.
23  */
24 
25 /*
26  * TIFF Library.
27  *
28  * Directory Printing Support
29  */
30 #include <precomp.h>
31 //#include <stdio.h>
32 
33 //#include <ctype.h>
34 
35 static void
36 _TIFFprintAsciiBounded(FILE* fd, const char* cp, size_t max_chars);
37 
38 static const char * const photoNames[] = {
39  "min-is-white", /* PHOTOMETRIC_MINISWHITE */
40  "min-is-black", /* PHOTOMETRIC_MINISBLACK */
41  "RGB color", /* PHOTOMETRIC_RGB */
42  "palette color (RGB from colormap)", /* PHOTOMETRIC_PALETTE */
43  "transparency mask", /* PHOTOMETRIC_MASK */
44  "separated", /* PHOTOMETRIC_SEPARATED */
45  "YCbCr", /* PHOTOMETRIC_YCBCR */
46  "7 (0x7)",
47  "CIE L*a*b*", /* PHOTOMETRIC_CIELAB */
48  "ICC L*a*b*", /* PHOTOMETRIC_ICCLAB */
49  "ITU L*a*b*" /* PHOTOMETRIC_ITULAB */
50 };
51 #define NPHOTONAMES (sizeof (photoNames) / sizeof (photoNames[0]))
52 
53 static const char * const orientNames[] = {
54  "0 (0x0)",
55  "row 0 top, col 0 lhs", /* ORIENTATION_TOPLEFT */
56  "row 0 top, col 0 rhs", /* ORIENTATION_TOPRIGHT */
57  "row 0 bottom, col 0 rhs", /* ORIENTATION_BOTRIGHT */
58  "row 0 bottom, col 0 lhs", /* ORIENTATION_BOTLEFT */
59  "row 0 lhs, col 0 top", /* ORIENTATION_LEFTTOP */
60  "row 0 rhs, col 0 top", /* ORIENTATION_RIGHTTOP */
61  "row 0 rhs, col 0 bottom", /* ORIENTATION_RIGHTBOT */
62  "row 0 lhs, col 0 bottom", /* ORIENTATION_LEFTBOT */
63 };
64 #define NORIENTNAMES (sizeof (orientNames) / sizeof (orientNames[0]))
65 
66 static void
68  uint32 value_count, void *raw_data)
69 {
70  uint32 j;
71 
72  fprintf(fd, " %s: ", fip->field_name);
73 
74  for(j = 0; j < value_count; j++) {
75  if(fip->field_type == TIFF_BYTE)
76  fprintf(fd, "%u", ((uint8 *) raw_data)[j]);
77  else if(fip->field_type == TIFF_UNDEFINED)
78  fprintf(fd, "0x%x",
79  (unsigned int) ((unsigned char *) raw_data)[j]);
80  else if(fip->field_type == TIFF_SBYTE)
81  fprintf(fd, "%d", ((int8 *) raw_data)[j]);
82  else if(fip->field_type == TIFF_SHORT)
83  fprintf(fd, "%u", ((uint16 *) raw_data)[j]);
84  else if(fip->field_type == TIFF_SSHORT)
85  fprintf(fd, "%d", ((int16 *) raw_data)[j]);
86  else if(fip->field_type == TIFF_LONG)
87  fprintf(fd, "%lu",
88  (unsigned long)((uint32 *) raw_data)[j]);
89  else if(fip->field_type == TIFF_SLONG)
90  fprintf(fd, "%ld", (long)((int32 *) raw_data)[j]);
91  else if(fip->field_type == TIFF_IFD)
92  fprintf(fd, "0x%lx",
93  (unsigned long)((uint32 *) raw_data)[j]);
94  else if(fip->field_type == TIFF_RATIONAL
95  || fip->field_type == TIFF_SRATIONAL
96  || fip->field_type == TIFF_FLOAT)
97  fprintf(fd, "%f", ((float *) raw_data)[j]);
98  else if(fip->field_type == TIFF_LONG8)
99 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
100  fprintf(fd, "%I64u",
101  (unsigned __int64)((uint64 *) raw_data)[j]);
102 #else
103  fprintf(fd, "%llu",
104  (unsigned long long)((uint64 *) raw_data)[j]);
105 #endif
106  else if(fip->field_type == TIFF_SLONG8)
107 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
108  fprintf(fd, "%I64d", (__int64)((int64 *) raw_data)[j]);
109 #else
110  fprintf(fd, "%lld", (long long)((int64 *) raw_data)[j]);
111 #endif
112  else if(fip->field_type == TIFF_IFD8)
113 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
114  fprintf(fd, "0x%I64x",
115  (unsigned __int64)((uint64 *) raw_data)[j]);
116 #else
117  fprintf(fd, "0x%llx",
118  (unsigned long long)((uint64 *) raw_data)[j]);
119 #endif
120  else if(fip->field_type == TIFF_FLOAT)
121  fprintf(fd, "%f", ((float *)raw_data)[j]);
122  else if(fip->field_type == TIFF_DOUBLE)
123  fprintf(fd, "%f", ((double *) raw_data)[j]);
124  else if(fip->field_type == TIFF_ASCII) {
125  fprintf(fd, "%s", (char *) raw_data);
126  break;
127  }
128  else {
129  fprintf(fd, "<unsupported data type in TIFFPrint>");
130  break;
131  }
132 
133  if(j < value_count - 1)
134  fprintf(fd, ",");
135  }
136 
137  fprintf(fd, "\n");
138 }
139 
140 static int
142  uint32 value_count, void *raw_data)
143 {
144  (void) tif;
145 
146  /* do not try to pretty print auto-defined fields */
147  if (strncmp(fip->field_name,"Tag ", 4) == 0) {
148  return 0;
149  }
150 
151  switch (tag)
152  {
153  case TIFFTAG_INKSET:
154  if (value_count == 2 && fip->field_type == TIFF_SHORT) {
155  fprintf(fd, " Ink Set: ");
156  switch (*((uint16*)raw_data)) {
157  case INKSET_CMYK:
158  fprintf(fd, "CMYK\n");
159  break;
160  default:
161  fprintf(fd, "%u (0x%x)\n",
162  *((uint16*)raw_data),
163  *((uint16*)raw_data));
164  break;
165  }
166  return 1;
167  }
168  return 0;
169 
170  case TIFFTAG_DOTRANGE:
171  if (value_count == 2 && fip->field_type == TIFF_SHORT) {
172  fprintf(fd, " Dot Range: %u-%u\n",
173  ((uint16*)raw_data)[0], ((uint16*)raw_data)[1]);
174  return 1;
175  }
176  return 0;
177 
178  case TIFFTAG_WHITEPOINT:
179  if (value_count == 2 && fip->field_type == TIFF_RATIONAL) {
180  fprintf(fd, " White Point: %g-%g\n",
181  ((float *)raw_data)[0], ((float *)raw_data)[1]);
182  return 1;
183  }
184  return 0;
185 
186  case TIFFTAG_XMLPACKET:
187  {
188  uint32 i;
189 
190  fprintf(fd, " XMLPacket (XMP Metadata):\n" );
191  for(i = 0; i < value_count; i++)
192  fputc(((char *)raw_data)[i], fd);
193  fprintf( fd, "\n" );
194  return 1;
195  }
197  /*
198  * XXX: for some weird reason RichTIFFIPTC tag
199  * defined as array of LONG values.
200  */
201  fprintf(fd,
202  " RichTIFFIPTC Data: <present>, %lu bytes\n",
203  (unsigned long) value_count * 4);
204  return 1;
205 
206  case TIFFTAG_PHOTOSHOP:
207  fprintf(fd, " Photoshop Data: <present>, %lu bytes\n",
208  (unsigned long) value_count);
209  return 1;
210 
211  case TIFFTAG_ICCPROFILE:
212  fprintf(fd, " ICC Profile: <present>, %lu bytes\n",
213  (unsigned long) value_count);
214  return 1;
215 
216  case TIFFTAG_STONITS:
217  if (value_count == 1 && fip->field_type == TIFF_DOUBLE) {
218  fprintf(fd,
219  " Sample to Nits conversion factor: %.4e\n",
220  *((double*)raw_data));
221  return 1;
222  }
223  return 0;
224  }
225 
226  return 0;
227 }
228 
229 /*
230  * Print the contents of the current directory
231  * to the specified stdio file stream.
232  */
233 void
235 {
236  TIFFDirectory *td = &tif->tif_dir;
237  char *sep;
238  long l, n;
239 
240 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
241  fprintf(fd, "TIFF Directory at offset 0x%I64x (%I64u)\n",
242  (unsigned __int64) tif->tif_diroff,
243  (unsigned __int64) tif->tif_diroff);
244 #else
245  fprintf(fd, "TIFF Directory at offset 0x%llx (%llu)\n",
246  (unsigned long long) tif->tif_diroff,
247  (unsigned long long) tif->tif_diroff);
248 #endif
249  if (TIFFFieldSet(tif,FIELD_SUBFILETYPE)) {
250  fprintf(fd, " Subfile Type:");
251  sep = " ";
253  fprintf(fd, "%sreduced-resolution image", sep);
254  sep = "/";
255  }
256  if (td->td_subfiletype & FILETYPE_PAGE) {
257  fprintf(fd, "%smulti-page document", sep);
258  sep = "/";
259  }
260  if (td->td_subfiletype & FILETYPE_MASK)
261  fprintf(fd, "%stransparency mask", sep);
262  fprintf(fd, " (%lu = 0x%lx)\n",
263  (unsigned long) td->td_subfiletype, (long) td->td_subfiletype);
264  }
266  fprintf(fd, " Image Width: %lu Image Length: %lu",
267  (unsigned long) td->td_imagewidth, (unsigned long) td->td_imagelength);
269  fprintf(fd, " Image Depth: %lu",
270  (unsigned long) td->td_imagedepth);
271  fprintf(fd, "\n");
272  }
274  fprintf(fd, " Tile Width: %lu Tile Length: %lu",
275  (unsigned long) td->td_tilewidth, (unsigned long) td->td_tilelength);
276  if (TIFFFieldSet(tif,FIELD_TILEDEPTH))
277  fprintf(fd, " Tile Depth: %lu",
278  (unsigned long) td->td_tiledepth);
279  fprintf(fd, "\n");
280  }
281  if (TIFFFieldSet(tif,FIELD_RESOLUTION)) {
282  fprintf(fd, " Resolution: %g, %g",
283  td->td_xresolution, td->td_yresolution);
285  switch (td->td_resolutionunit) {
286  case RESUNIT_NONE:
287  fprintf(fd, " (unitless)");
288  break;
289  case RESUNIT_INCH:
290  fprintf(fd, " pixels/inch");
291  break;
292  case RESUNIT_CENTIMETER:
293  fprintf(fd, " pixels/cm");
294  break;
295  default:
296  fprintf(fd, " (unit %u = 0x%x)",
297  td->td_resolutionunit,
298  td->td_resolutionunit);
299  break;
300  }
301  }
302  fprintf(fd, "\n");
303  }
304  if (TIFFFieldSet(tif,FIELD_POSITION))
305  fprintf(fd, " Position: %g, %g\n",
306  td->td_xposition, td->td_yposition);
308  fprintf(fd, " Bits/Sample: %u\n", td->td_bitspersample);
309  if (TIFFFieldSet(tif,FIELD_SAMPLEFORMAT)) {
310  fprintf(fd, " Sample Format: ");
311  switch (td->td_sampleformat) {
312  case SAMPLEFORMAT_VOID:
313  fprintf(fd, "void\n");
314  break;
315  case SAMPLEFORMAT_INT:
316  fprintf(fd, "signed integer\n");
317  break;
318  case SAMPLEFORMAT_UINT:
319  fprintf(fd, "unsigned integer\n");
320  break;
321  case SAMPLEFORMAT_IEEEFP:
322  fprintf(fd, "IEEE floating point\n");
323  break;
325  fprintf(fd, "complex signed integer\n");
326  break;
328  fprintf(fd, "complex IEEE floating point\n");
329  break;
330  default:
331  fprintf(fd, "%u (0x%x)\n",
333  break;
334  }
335  }
336  if (TIFFFieldSet(tif,FIELD_COMPRESSION)) {
337  const TIFFCodec* c = TIFFFindCODEC(td->td_compression);
338  fprintf(fd, " Compression Scheme: ");
339  if (c)
340  fprintf(fd, "%s\n", c->name);
341  else
342  fprintf(fd, "%u (0x%x)\n",
343  td->td_compression, td->td_compression);
344  }
345  if (TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) {
346  fprintf(fd, " Photometric Interpretation: ");
347  if (td->td_photometric < NPHOTONAMES)
348  fprintf(fd, "%s\n", photoNames[td->td_photometric]);
349  else {
350  switch (td->td_photometric) {
351  case PHOTOMETRIC_LOGL:
352  fprintf(fd, "CIE Log2(L)\n");
353  break;
354  case PHOTOMETRIC_LOGLUV:
355  fprintf(fd, "CIE Log2(L) (u',v')\n");
356  break;
357  default:
358  fprintf(fd, "%u (0x%x)\n",
359  td->td_photometric, td->td_photometric);
360  break;
361  }
362  }
363  }
365  uint16 i;
366  fprintf(fd, " Extra Samples: %u<", td->td_extrasamples);
367  sep = "";
368  for (i = 0; i < td->td_extrasamples; i++) {
369  switch (td->td_sampleinfo[i]) {
371  fprintf(fd, "%sunspecified", sep);
372  break;
374  fprintf(fd, "%sassoc-alpha", sep);
375  break;
377  fprintf(fd, "%sunassoc-alpha", sep);
378  break;
379  default:
380  fprintf(fd, "%s%u (0x%x)", sep,
381  td->td_sampleinfo[i], td->td_sampleinfo[i]);
382  break;
383  }
384  sep = ", ";
385  }
386  fprintf(fd, ">\n");
387  }
388  if (TIFFFieldSet(tif,FIELD_INKNAMES)) {
389  char* cp;
390  uint16 i;
391  fprintf(fd, " Ink Names: ");
392  i = td->td_samplesperpixel;
393  sep = "";
394  for (cp = td->td_inknames;
395  i > 0 && cp < td->td_inknames + td->td_inknameslen;
396  cp = strchr(cp,'\0')+1, i--) {
397  size_t max_chars =
398  td->td_inknameslen - (cp - td->td_inknames);
399  fputs(sep, fd);
400  _TIFFprintAsciiBounded(fd, cp, max_chars);
401  sep = ", ";
402  }
403  fputs("\n", fd);
404  }
406  fprintf(fd, " Thresholding: ");
407  switch (td->td_threshholding) {
408  case THRESHHOLD_BILEVEL:
409  fprintf(fd, "bilevel art scan\n");
410  break;
411  case THRESHHOLD_HALFTONE:
412  fprintf(fd, "halftone or dithered scan\n");
413  break;
415  fprintf(fd, "error diffused\n");
416  break;
417  default:
418  fprintf(fd, "%u (0x%x)\n",
420  break;
421  }
422  }
423  if (TIFFFieldSet(tif,FIELD_FILLORDER)) {
424  fprintf(fd, " FillOrder: ");
425  switch (td->td_fillorder) {
426  case FILLORDER_MSB2LSB:
427  fprintf(fd, "msb-to-lsb\n");
428  break;
429  case FILLORDER_LSB2MSB:
430  fprintf(fd, "lsb-to-msb\n");
431  break;
432  default:
433  fprintf(fd, "%u (0x%x)\n",
434  td->td_fillorder, td->td_fillorder);
435  break;
436  }
437  }
439  {
440  fprintf(fd, " YCbCr Subsampling: %u, %u\n",
441  td->td_ycbcrsubsampling[0], td->td_ycbcrsubsampling[1] );
442  }
444  fprintf(fd, " YCbCr Positioning: ");
445  switch (td->td_ycbcrpositioning) {
447  fprintf(fd, "centered\n");
448  break;
450  fprintf(fd, "cosited\n");
451  break;
452  default:
453  fprintf(fd, "%u (0x%x)\n",
455  break;
456  }
457  }
459  fprintf(fd, " Halftone Hints: light %u dark %u\n",
460  td->td_halftonehints[0], td->td_halftonehints[1]);
461  if (TIFFFieldSet(tif,FIELD_ORIENTATION)) {
462  fprintf(fd, " Orientation: ");
463  if (td->td_orientation < NORIENTNAMES)
464  fprintf(fd, "%s\n", orientNames[td->td_orientation]);
465  else
466  fprintf(fd, "%u (0x%x)\n",
467  td->td_orientation, td->td_orientation);
468  }
470  fprintf(fd, " Samples/Pixel: %u\n", td->td_samplesperpixel);
471  if (TIFFFieldSet(tif,FIELD_ROWSPERSTRIP)) {
472  fprintf(fd, " Rows/Strip: ");
473  if (td->td_rowsperstrip == (uint32) -1)
474  fprintf(fd, "(infinite)\n");
475  else
476  fprintf(fd, "%lu\n", (unsigned long) td->td_rowsperstrip);
477  }
479  fprintf(fd, " Min Sample Value: %u\n", td->td_minsamplevalue);
481  fprintf(fd, " Max Sample Value: %u\n", td->td_maxsamplevalue);
483  int i;
484  int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1;
485  fprintf(fd, " SMin Sample Value:");
486  for (i = 0; i < count; ++i)
487  fprintf(fd, " %g", td->td_sminsamplevalue[i]);
488  fprintf(fd, "\n");
489  }
491  int i;
492  int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1;
493  fprintf(fd, " SMax Sample Value:");
494  for (i = 0; i < count; ++i)
495  fprintf(fd, " %g", td->td_smaxsamplevalue[i]);
496  fprintf(fd, "\n");
497  }
498  if (TIFFFieldSet(tif,FIELD_PLANARCONFIG)) {
499  fprintf(fd, " Planar Configuration: ");
500  switch (td->td_planarconfig) {
501  case PLANARCONFIG_CONTIG:
502  fprintf(fd, "single image plane\n");
503  break;
505  fprintf(fd, "separate image planes\n");
506  break;
507  default:
508  fprintf(fd, "%u (0x%x)\n",
510  break;
511  }
512  }
514  fprintf(fd, " Page Number: %u-%u\n",
515  td->td_pagenumber[0], td->td_pagenumber[1]);
516  if (TIFFFieldSet(tif,FIELD_COLORMAP)) {
517  fprintf(fd, " Color Map: ");
518  if (flags & TIFFPRINT_COLORMAP) {
519  fprintf(fd, "\n");
520  n = 1L<<td->td_bitspersample;
521  for (l = 0; l < n; l++)
522  fprintf(fd, " %5ld: %5u %5u %5u\n",
523  l,
524  td->td_colormap[0][l],
525  td->td_colormap[1][l],
526  td->td_colormap[2][l]);
527  } else
528  fprintf(fd, "(present)\n");
529  }
531  int i;
532  fprintf(fd, " Reference Black/White:\n");
533  for (i = 0; i < 3; i++)
534  fprintf(fd, " %2d: %5g %5g\n", i,
535  td->td_refblackwhite[2*i+0],
536  td->td_refblackwhite[2*i+1]);
537  }
539  fprintf(fd, " Transfer Function: ");
540  if (flags & TIFFPRINT_CURVES) {
541  fprintf(fd, "\n");
542  n = 1L<<td->td_bitspersample;
543  for (l = 0; l < n; l++) {
544  uint16 i;
545  fprintf(fd, " %2ld: %5u",
546  l, td->td_transferfunction[0][l]);
547  for (i = 1; i < td->td_samplesperpixel - td->td_extrasamples && i < 3; i++)
548  fprintf(fd, " %5u",
549  td->td_transferfunction[i][l]);
550  fputc('\n', fd);
551  }
552  } else
553  fprintf(fd, "(present)\n");
554  }
555  if (TIFFFieldSet(tif, FIELD_SUBIFD) && (td->td_subifd)) {
556  uint16 i;
557  fprintf(fd, " SubIFD Offsets:");
558  for (i = 0; i < td->td_nsubifd; i++)
559 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
560  fprintf(fd, " %5I64u",
561  (unsigned __int64) td->td_subifd[i]);
562 #else
563  fprintf(fd, " %5llu",
564  (unsigned long long) td->td_subifd[i]);
565 #endif
566  fputc('\n', fd);
567  }
568 
569  /*
570  ** Custom tag support.
571  */
572  {
573  int i;
574  short count;
575 
577  for(i = 0; i < count; i++) {
579  const TIFFField *fip;
580  uint32 value_count;
581  int mem_alloc = 0;
582  void *raw_data;
583 
584  fip = TIFFFieldWithTag(tif, tag);
585  if(fip == NULL)
586  continue;
587 
588  if(fip->field_passcount) {
589  if (fip->field_readcount == TIFF_VARIABLE2 ) {
590  if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1)
591  continue;
592  } else if (fip->field_readcount == TIFF_VARIABLE ) {
593  uint16 small_value_count;
594  if(TIFFGetField(tif, tag, &small_value_count, &raw_data) != 1)
595  continue;
596  value_count = small_value_count;
597  } else {
599  || fip->field_readcount == TIFF_VARIABLE2);
600  continue;
601  }
602  } else {
603  if (fip->field_readcount == TIFF_VARIABLE
604  || fip->field_readcount == TIFF_VARIABLE2)
605  value_count = 1;
606  else if (fip->field_readcount == TIFF_SPP)
607  value_count = td->td_samplesperpixel;
608  else
609  value_count = fip->field_readcount;
610  if (fip->field_tag == TIFFTAG_DOTRANGE
611  && strcmp(fip->field_name,"DotRange") == 0) {
612  /* TODO: This is an evil exception and should not have been
613  handled this way ... likely best if we move it into
614  the directory structure with an explicit field in
615  libtiff 4.1 and assign it a FIELD_ value */
616  static uint16 dotrange[2];
617  raw_data = dotrange;
618  TIFFGetField(tif, tag, dotrange+0, dotrange+1);
619  } else if (fip->field_type == TIFF_ASCII
620  || fip->field_readcount == TIFF_VARIABLE
622  || fip->field_readcount == TIFF_SPP
623  || value_count > 1) {
624  if(TIFFGetField(tif, tag, &raw_data) != 1)
625  continue;
626  } else {
627  raw_data = _TIFFmalloc(
629  * value_count);
630  mem_alloc = 1;
631  if(TIFFGetField(tif, tag, raw_data) != 1) {
632  _TIFFfree(raw_data);
633  continue;
634  }
635  }
636  }
637 
638  /*
639  * Catch the tags which needs to be specially handled
640  * and pretty print them. If tag not handled in
641  * _TIFFPrettyPrintField() fall down and print it as
642  * any other tag.
643  */
644  if (!_TIFFPrettyPrintField(tif, fip, fd, tag, value_count, raw_data))
645  _TIFFPrintField(fd, fip, value_count, raw_data);
646 
647  if(mem_alloc)
648  _TIFFfree(raw_data);
649  }
650  }
651 
652  if (tif->tif_tagmethods.printdir)
653  (*tif->tif_tagmethods.printdir)(tif, fd, flags);
654 
655  if ((flags & TIFFPRINT_STRIPS) &&
657  uint32 s;
658 
659  fprintf(fd, " %lu %s:\n",
660  (unsigned long) td->td_nstrips,
661  isTiled(tif) ? "Tiles" : "Strips");
662  for (s = 0; s < td->td_nstrips; s++)
663 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
664  fprintf(fd, " %3lu: [%8I64u, %8I64u]\n",
665  (unsigned long) s,
666  (unsigned __int64) TIFFGetStrileOffset(tif, s),
667  (unsigned __int64) TIFFGetStrileByteCount(tif, s));
668 #else
669  fprintf(fd, " %3lu: [%8llu, %8llu]\n",
670  (unsigned long) s,
671  (unsigned long long) TIFFGetStrileOffset(tif, s),
672  (unsigned long long) TIFFGetStrileByteCount(tif, s));
673 #endif
674  }
675 }
676 
677 void
678 _TIFFprintAscii(FILE* fd, const char* cp)
679 {
681 }
682 
683 static void
684 _TIFFprintAsciiBounded(FILE* fd, const char* cp, size_t max_chars)
685 {
686  for (; max_chars > 0 && *cp != '\0'; cp++, max_chars--) {
687  const char* tp;
688 
689  if (isprint((int)*cp)) {
690  fputc(*cp, fd);
691  continue;
692  }
693  for (tp = "\tt\bb\rr\nn\vv"; *tp; tp++)
694  if (*tp++ == *cp)
695  break;
696  if (*tp)
697  fprintf(fd, "\\%c", *tp);
698  else
699  fprintf(fd, "\\%03o", *cp & 0xff);
700  }
701 }
702 
703 void
704 _TIFFprintAsciiTag(FILE* fd, const char* name, const char* value)
705 {
706  fprintf(fd, " %s: \"", name);
708  fprintf(fd, "\"\n");
709 }
710 
711 /* vim: set ts=8 sts=8 sw=8 noet: */
712 /*
713  * Local Variables:
714  * mode: c
715  * c-basic-offset: 8
716  * fill-column: 78
717  * End:
718  */
unsigned long long uint64
Definition: platform.h:18
TIFFTagMethods tif_tagmethods
Definition: tiffiop.h:219
#define TIFF_VARIABLE
Definition: tiffio.h:308
uint16 td_ycbcrpositioning
Definition: tif_dir.h:113
_Check_return_opt_ _CRTIMP int __cdecl fputc(_In_ int _Ch, _Inout_ FILE *_File)
float td_yposition
Definition: tif_dir.h:90
uint16 td_bitspersample
Definition: tif_dir.h:75
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
uint32 td_tiledepth
Definition: tif_dir.h:73
void _TIFFprintAscii(FILE *fd, const char *cp)
Definition: tif_print.c:678
#define FIELD_MINSAMPLEVALUE
Definition: tif_dir.h:156
#define FIELD_RESOLUTION
Definition: tif_dir.h:143
#define THRESHHOLD_ERRORDIFFUSE
Definition: tiff.h:212
char * td_inknames
Definition: tif_dir.h:119
#define TIFFTAG_ICCPROFILE
Definition: tiff.h:440
int td_inknameslen
Definition: tif_dir.h:118
#define FIELD_STRIPOFFSETS
Definition: tif_dir.h:162
#define THRESHHOLD_BILEVEL
Definition: tiff.h:210
#define TIFFPRINT_CURVES
Definition: tiffio.h:115
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define FIELD_IMAGEDIMENSIONS
Definition: tif_dir.h:141
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int uint32
Definition: types.h:32
#define FIELD_THRESHHOLDING
Definition: tif_dir.h:151
#define YCBCRPOSITION_COSITED
Definition: tiff.h:370
#define PHOTOMETRIC_LOGL
Definition: tiff.h:207
uint16 td_halftonehints[2]
Definition: tif_dir.h:93
#define FILLORDER_LSB2MSB
Definition: tiff.h:217
GLdouble n
Definition: glext.h:7729
#define assert(x)
Definition: debug.h:53
Definition: ecma_167.h:138
void TIFFPrintDirectory(TIFF *tif, FILE *fd, long flags)
Definition: tif_print.c:234
#define FIELD_HALFTONEHINTS
Definition: tif_dir.h:170
#define PHOTOMETRIC_LOGLUV
Definition: tiff.h:208
#define TIFFTAG_DOTRANGE
Definition: tiff.h:302
static int fd
Definition: io.c:51
uint32 td_imagedepth
Definition: tif_dir.h:72
#define TIFFPRINT_COLORMAP
Definition: tiffio.h:116
#define FIELD_RESOLUTIONUNIT
Definition: tif_dir.h:159
long long int64
Definition: platform.h:13
Definition: tiffiop.h:115
#define FIELD_YCBCRSUBSAMPLING
Definition: tif_dir.h:171
#define SAMPLEFORMAT_INT
Definition: tiff.h:310
#define FIELD_SMAXSAMPLEVALUE
Definition: tif_dir.h:167
float td_xresolution
Definition: tif_dir.h:87
#define RESUNIT_INCH
Definition: tiff.h:264
uint32 td_tilelength
Definition: tif_dir.h:73
#define FIELD_SUBIFD
Definition: tif_dir.h:176
#define FIELD_TRANSFERFUNCTION
Definition: tif_dir.h:174
#define FIELD_FILLORDER
Definition: tif_dir.h:152
#define FIELD_MAXSAMPLEVALUE
Definition: tif_dir.h:157
int TIFFGetField(TIFF *tif, uint32 tag,...)
Definition: tif_dir.c:1232
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
uint32 TIFFGetTagListEntry(TIFF *tif, int tag_index)
Definition: tif_extension.c:42
#define INKSET_CMYK
Definition: tiff.h:298
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
float td_xposition
Definition: tif_dir.h:90
#define FIELD_BITSPERSAMPLE
Definition: tif_dir.h:148
#define mem_alloc(bsize)
Definition: types.h:123
TIFFPrintMethod printdir
Definition: tiffio.h:335
void _TIFFprintAsciiTag(FILE *fd, const char *name, const char *value)
Definition: tif_print.c:704
char * field_name
Definition: tif_dir.h:293
uint32 td_subfiletype
Definition: tif_dir.h:74
uint16 * td_sampleinfo
Definition: tif_dir.h:95
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define NPHOTONAMES
Definition: tif_print.c:51
uint16 td_nsubifd
Definition: tif_dir.h:109
#define YCBCRPOSITION_CENTERED
Definition: tiff.h:369
uint16 td_resolutionunit
Definition: tif_dir.h:88
uint32 tif_flags
Definition: tiffiop.h:119
smooth NULL
Definition: ftsmooth.c:416
#define FIELD_PLANARCONFIG
Definition: tif_dir.h:158
static const char *const photoNames[]
Definition: tif_print.c:38
uint16 td_planarconfig
Definition: tif_dir.h:89
uint64 TIFFGetStrileOffset(TIFF *tif, uint32 strile)
Definition: tif_dirread.c:6290
#define SAMPLEFORMAT_VOID
Definition: tiff.h:312
uint16 * td_colormap[3]
Definition: tif_dir.h:92
double * td_sminsamplevalue
Definition: tif_dir.h:85
uint16 td_orientation
Definition: tif_dir.h:81
uint16 td_minsamplevalue
Definition: tif_dir.h:84
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2930
unsigned char field_passcount
Definition: tif_dir.h:292
r l[0]
Definition: byte_order.h:167
uint32 td_nstrips
Definition: tif_dir.h:100
#define TIFFTAG_XMLPACKET
Definition: tiff.h:373
#define SAMPLEFORMAT_COMPLEXIEEEFP
Definition: tiff.h:314
#define SAMPLEFORMAT_UINT
Definition: tiff.h:309
#define TIFF_PERSAMPLE
Definition: tiffiop.h:141
#define RESUNIT_CENTIMETER
Definition: tiff.h:265
uint16 td_extrasamples
Definition: tif_dir.h:94
uint32 td_imagelength
Definition: tif_dir.h:72
uint32 field_tag
Definition: tif_dir.h:283
#define SAMPLEFORMAT_IEEEFP
Definition: tiff.h:311
uint16 td_photometric
Definition: tif_dir.h:78
const GLubyte * c
Definition: glext.h:8905
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
unsigned char uint8
Definition: types.h:28
#define FIELD_PHOTOMETRIC
Definition: tif_dir.h:150
#define NORIENTNAMES
Definition: tif_print.c:64
double * td_smaxsamplevalue
Definition: tif_dir.h:86
#define EXTRASAMPLE_UNASSALPHA
Definition: tiff.h:307
#define TIFFFieldSet(tif, field)
Definition: tif_dir.h:196
GLbitfield flags
Definition: glext.h:7161
uint16 td_fillorder
Definition: tif_dir.h:80
#define FIELD_COMPRESSION
Definition: tif_dir.h:149
#define FIELD_SMINSAMPLEVALUE
Definition: tif_dir.h:166
#define FIELD_ROWSPERSTRIP
Definition: tif_dir.h:155
static void _TIFFPrintField(FILE *fd, const TIFFField *fip, uint32 value_count, void *raw_data)
Definition: tif_print.c:67
static int _TIFFPrettyPrintField(TIFF *tif, const TIFFField *fip, FILE *fd, uint32 tag, uint32 value_count, void *raw_data)
Definition: tif_print.c:141
static const WCHAR L[]
Definition: oid.c:1250
#define FIELD_INKNAMES
Definition: tif_dir.h:175
#define TIFFTAG_WHITEPOINT
Definition: tiff.h:282
uint64 tif_diroff
Definition: tiffiop.h:146
const TIFFCodec * TIFFFindCODEC(uint16 scheme)
Definition: tif_compress.c:186
uint32 td_tilewidth
Definition: tif_dir.h:73
#define FIELD_ORIENTATION
Definition: tif_dir.h:153
uint16 td_sampleformat
Definition: tif_dir.h:76
uint16 td_threshholding
Definition: tif_dir.h:79
#define TIFFTAG_INKSET
Definition: tiff.h:297
#define PLANARCONFIG_SEPARATE
Definition: tiff.h:241
#define FILETYPE_REDUCEDIMAGE
Definition: tiff.h:147
GLdouble s
Definition: gl.h:2039
static const char *const orientNames[]
Definition: tif_print.c:53
uint16 td_pagenumber[2]
Definition: tif_dir.h:91
const TIFFField * TIFFFieldWithTag(TIFF *tif, uint32 tag)
Definition: tif_dirinfo.c:558
#define FIELD_IMAGEDEPTH
Definition: tif_dir.h:168
#define isTiled(tif)
Definition: tiffiop.h:229
#define FILETYPE_PAGE
Definition: tiff.h:148
#define FIELD_YCBCRPOSITIONING
Definition: tif_dir.h:172
int _TIFFDataSize(TIFFDataType type)
Definition: tif_dirinfo.c:476
#define FIELD_EXTRASAMPLES
Definition: tif_dir.h:164
#define TIFF_VARIABLE2
Definition: tiffio.h:310
uint16 td_maxsamplevalue
Definition: tif_dir.h:84
#define TIFFTAG_STONITS
Definition: tiff.h:451
uint32 td_rowsperstrip
Definition: tif_dir.h:83
uint64 * td_subifd
Definition: tif_dir.h:110
TIFFDataType field_type
Definition: tif_dir.h:286
#define TIFF_SPP
Definition: tiffio.h:309
uint16 td_ycbcrsubsampling[2]
Definition: tif_dir.h:112
int TIFFGetTagListCount(TIFF *tif)
Definition: tif_extension.c:34
unsigned short uint16
Definition: types.h:30
short int16
Definition: platform.h:11
#define FIELD_POSITION
Definition: tif_dir.h:144
TIFFDirectory tif_dir
Definition: tiffiop.h:151
#define EXTRASAMPLE_UNSPECIFIED
Definition: tiff.h:305
#define FIELD_PAGENUMBER
Definition: tif_dir.h:160
#define FIELD_TILEDEPTH
Definition: tif_dir.h:169
#define FIELD_TILEDIMENSIONS
Definition: tif_dir.h:142
float * td_refblackwhite
Definition: tif_dir.h:116
uint16 * td_transferfunction[3]
Definition: tif_dir.h:115
#define TIFFTAG_RICHTIFFIPTC
Definition: tiff.h:413
#define SAMPLEFORMAT_COMPLEXINT
Definition: tiff.h:313
#define FILETYPE_MASK
Definition: tiff.h:149
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define isprint(c)
Definition: acclib.h:73
#define FIELD_COLORMAP
Definition: tif_dir.h:163
POINT cp
Definition: magnifier.c:59
#define FIELD_SAMPLESPERPIXEL
Definition: tif_dir.h:154
Definition: name.c:38
long int32
Definition: platform.h:12
float td_yresolution
Definition: tif_dir.h:87
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define RESUNIT_NONE
Definition: tiff.h:263
uint16 td_samplesperpixel
Definition: tif_dir.h:82
#define FIELD_REFBLACKWHITE
Definition: tif_dir.h:173
Definition: tiff.h:137
uint16 td_compression
Definition: tif_dir.h:77
void _TIFFfree(void *p)
Definition: tif_unix.c:326
#define TIFFPRINT_STRIPS
Definition: tiffio.h:114
#define EXTRASAMPLE_ASSOCALPHA
Definition: tiff.h:306
#define FIELD_SAMPLEFORMAT
Definition: tif_dir.h:165
uint32 td_imagewidth
Definition: tif_dir.h:72
static void _TIFFprintAsciiBounded(FILE *fd, const char *cp, size_t max_chars)
Definition: tif_print.c:684
#define THRESHHOLD_HALFTONE
Definition: tiff.h:211
uint64 TIFFGetStrileByteCount(TIFF *tif, uint32 strile)
Definition: tif_dirread.c:6305
_Check_return_opt_ _CRTIMP int __cdecl fputs(_In_z_ const char *_Str, _Inout_ FILE *_File)
#define FILLORDER_MSB2LSB
Definition: tiff.h:216
#define TIFFTAG_PHOTOSHOP
Definition: tiff.h:436
#define __int64
Definition: basetyps.h:16
#define PLANARCONFIG_CONTIG
Definition: tiff.h:240
#define FIELD_SUBFILETYPE
Definition: tif_dir.h:147
char int8
Definition: platform.h:10
short field_readcount
Definition: tif_dir.h:284