3 * Copyright (c) 1988-1997 Sam Leffler
4 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
6 * Permission to use, copy, modify, distribute, and sell this software and
7 * its documentation for any purpose is hereby granted without fee, provided
8 * that (i) the above copyright notices and this permission notice appear in
9 * all copies of the software and related documentation, and (ii) the names of
10 * Sam Leffler and Silicon Graphics may not be used in any advertising or
11 * publicity relating to the software without the specific, prior written
12 * permission of Sam Leffler and Silicon Graphics.
14 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
16 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
18 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
19 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
20 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
21 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
22 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
29 * Directory Printing Support
37 _TIFFprintAsciiBounded(FILE* fd
, const char* cp
, int max_chars
);
39 static const char *photoNames
[] = {
40 "min-is-white", /* PHOTOMETRIC_MINISWHITE */
41 "min-is-black", /* PHOTOMETRIC_MINISBLACK */
42 "RGB color", /* PHOTOMETRIC_RGB */
43 "palette color (RGB from colormap)", /* PHOTOMETRIC_PALETTE */
44 "transparency mask", /* PHOTOMETRIC_MASK */
45 "separated", /* PHOTOMETRIC_SEPARATED */
46 "YCbCr", /* PHOTOMETRIC_YCBCR */
48 "CIE L*a*b*", /* PHOTOMETRIC_CIELAB */
49 "ICC L*a*b*", /* PHOTOMETRIC_ICCLAB */
50 "ITU L*a*b*" /* PHOTOMETRIC_ITULAB */
52 #define NPHOTONAMES (sizeof (photoNames) / sizeof (photoNames[0]))
54 static const char *orientNames
[] = {
56 "row 0 top, col 0 lhs", /* ORIENTATION_TOPLEFT */
57 "row 0 top, col 0 rhs", /* ORIENTATION_TOPRIGHT */
58 "row 0 bottom, col 0 rhs", /* ORIENTATION_BOTRIGHT */
59 "row 0 bottom, col 0 lhs", /* ORIENTATION_BOTLEFT */
60 "row 0 lhs, col 0 top", /* ORIENTATION_LEFTTOP */
61 "row 0 rhs, col 0 top", /* ORIENTATION_RIGHTTOP */
62 "row 0 rhs, col 0 bottom", /* ORIENTATION_RIGHTBOT */
63 "row 0 lhs, col 0 bottom", /* ORIENTATION_LEFTBOT */
65 #define NORIENTNAMES (sizeof (orientNames) / sizeof (orientNames[0]))
68 _TIFFPrintField(FILE* fd
, const TIFFField
*fip
,
69 uint32 value_count
, void *raw_data
)
73 fprintf(fd
, " %s: ", fip
->field_name
);
75 for(j
= 0; j
< value_count
; j
++) {
76 if(fip
->field_type
== TIFF_BYTE
)
77 fprintf(fd
, "%u", ((uint8
*) raw_data
)[j
]);
78 else if(fip
->field_type
== TIFF_UNDEFINED
)
80 (unsigned int) ((unsigned char *) raw_data
)[j
]);
81 else if(fip
->field_type
== TIFF_SBYTE
)
82 fprintf(fd
, "%d", ((int8
*) raw_data
)[j
]);
83 else if(fip
->field_type
== TIFF_SHORT
)
84 fprintf(fd
, "%u", ((uint16
*) raw_data
)[j
]);
85 else if(fip
->field_type
== TIFF_SSHORT
)
86 fprintf(fd
, "%d", ((int16
*) raw_data
)[j
]);
87 else if(fip
->field_type
== TIFF_LONG
)
89 (unsigned long)((uint32
*) raw_data
)[j
]);
90 else if(fip
->field_type
== TIFF_SLONG
)
91 fprintf(fd
, "%ld", (long)((int32
*) raw_data
)[j
]);
92 else if(fip
->field_type
== TIFF_IFD
)
94 (unsigned long)((uint32
*) raw_data
)[j
]);
95 else if(fip
->field_type
== TIFF_RATIONAL
96 || fip
->field_type
== TIFF_SRATIONAL
97 || fip
->field_type
== TIFF_FLOAT
)
98 fprintf(fd
, "%f", ((float *) raw_data
)[j
]);
99 else if(fip
->field_type
== TIFF_LONG8
)
100 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
102 (unsigned __int64
)((uint64
*) raw_data
)[j
]);
105 (unsigned long long)((uint64
*) raw_data
)[j
]);
107 else if(fip
->field_type
== TIFF_SLONG8
)
108 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
109 fprintf(fd
, "%I64d", (__int64
)((int64
*) raw_data
)[j
]);
111 fprintf(fd
, "%lld", (long long)((int64
*) raw_data
)[j
]);
113 else if(fip
->field_type
== TIFF_IFD8
)
114 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
115 fprintf(fd
, "0x%I64x",
116 (unsigned __int64
)((uint64
*) raw_data
)[j
]);
118 fprintf(fd
, "0x%llx",
119 (unsigned long long)((uint64
*) raw_data
)[j
]);
121 else if(fip
->field_type
== TIFF_FLOAT
)
122 fprintf(fd
, "%f", ((float *)raw_data
)[j
]);
123 else if(fip
->field_type
== TIFF_DOUBLE
)
124 fprintf(fd
, "%f", ((double *) raw_data
)[j
]);
125 else if(fip
->field_type
== TIFF_ASCII
) {
126 fprintf(fd
, "%s", (char *) raw_data
);
130 fprintf(fd
, "<unsupported data type in TIFFPrint>");
134 if(j
< value_count
- 1)
142 _TIFFPrettyPrintField(TIFF
* tif
, const TIFFField
*fip
, FILE* fd
, uint32 tag
,
143 uint32 value_count
, void *raw_data
)
147 /* do not try to pretty print auto-defined fields */
148 if (strncmp(fip
->field_name
,"Tag ", 4) == 0) {
155 if (value_count
== 2 && fip
->field_type
== TIFF_SHORT
) {
156 fprintf(fd
, " Ink Set: ");
157 switch (*((uint16
*)raw_data
)) {
159 fprintf(fd
, "CMYK\n");
162 fprintf(fd
, "%u (0x%x)\n",
163 *((uint16
*)raw_data
),
164 *((uint16
*)raw_data
));
171 case TIFFTAG_DOTRANGE
:
172 if (value_count
== 2 && fip
->field_type
== TIFF_SHORT
) {
173 fprintf(fd
, " Dot Range: %u-%u\n",
174 ((uint16
*)raw_data
)[0], ((uint16
*)raw_data
)[1]);
179 case TIFFTAG_WHITEPOINT
:
180 if (value_count
== 2 && fip
->field_type
== TIFF_RATIONAL
) {
181 fprintf(fd
, " White Point: %g-%g\n",
182 ((float *)raw_data
)[0], ((float *)raw_data
)[1]);
187 case TIFFTAG_XMLPACKET
:
191 fprintf(fd
, " XMLPacket (XMP Metadata):\n" );
192 for(i
= 0; i
< value_count
; i
++)
193 fputc(((char *)raw_data
)[i
], fd
);
197 case TIFFTAG_RICHTIFFIPTC
:
199 * XXX: for some weird reason RichTIFFIPTC tag
200 * defined as array of LONG values.
203 " RichTIFFIPTC Data: <present>, %lu bytes\n",
204 (unsigned long) value_count
* 4);
207 case TIFFTAG_PHOTOSHOP
:
208 fprintf(fd
, " Photoshop Data: <present>, %lu bytes\n",
209 (unsigned long) value_count
);
212 case TIFFTAG_ICCPROFILE
:
213 fprintf(fd
, " ICC Profile: <present>, %lu bytes\n",
214 (unsigned long) value_count
);
217 case TIFFTAG_STONITS
:
218 if (value_count
== 1 && fip
->field_type
== TIFF_DOUBLE
) {
220 " Sample to Nits conversion factor: %.4e\n",
221 *((double*)raw_data
));
231 * Print the contents of the current directory
232 * to the specified stdio file stream.
235 TIFFPrintDirectory(TIFF
* tif
, FILE* fd
, long flags
)
237 TIFFDirectory
*td
= &tif
->tif_dir
;
242 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
243 fprintf(fd
, "TIFF Directory at offset 0x%I64x (%I64u)\n",
244 (unsigned __int64
) tif
->tif_diroff
,
245 (unsigned __int64
) tif
->tif_diroff
);
247 fprintf(fd
, "TIFF Directory at offset 0x%llx (%llu)\n",
248 (unsigned long long) tif
->tif_diroff
,
249 (unsigned long long) tif
->tif_diroff
);
251 if (TIFFFieldSet(tif
,FIELD_SUBFILETYPE
)) {
252 fprintf(fd
, " Subfile Type:");
254 if (td
->td_subfiletype
& FILETYPE_REDUCEDIMAGE
) {
255 fprintf(fd
, "%sreduced-resolution image", sep
);
258 if (td
->td_subfiletype
& FILETYPE_PAGE
) {
259 fprintf(fd
, "%smulti-page document", sep
);
262 if (td
->td_subfiletype
& FILETYPE_MASK
)
263 fprintf(fd
, "%stransparency mask", sep
);
264 fprintf(fd
, " (%lu = 0x%lx)\n",
265 (long) td
->td_subfiletype
, (long) td
->td_subfiletype
);
267 if (TIFFFieldSet(tif
,FIELD_IMAGEDIMENSIONS
)) {
268 fprintf(fd
, " Image Width: %lu Image Length: %lu",
269 (unsigned long) td
->td_imagewidth
, (unsigned long) td
->td_imagelength
);
270 if (TIFFFieldSet(tif
,FIELD_IMAGEDEPTH
))
271 fprintf(fd
, " Image Depth: %lu",
272 (unsigned long) td
->td_imagedepth
);
275 if (TIFFFieldSet(tif
,FIELD_TILEDIMENSIONS
)) {
276 fprintf(fd
, " Tile Width: %lu Tile Length: %lu",
277 (unsigned long) td
->td_tilewidth
, (unsigned long) td
->td_tilelength
);
278 if (TIFFFieldSet(tif
,FIELD_TILEDEPTH
))
279 fprintf(fd
, " Tile Depth: %lu",
280 (unsigned long) td
->td_tiledepth
);
283 if (TIFFFieldSet(tif
,FIELD_RESOLUTION
)) {
284 fprintf(fd
, " Resolution: %g, %g",
285 td
->td_xresolution
, td
->td_yresolution
);
286 if (TIFFFieldSet(tif
,FIELD_RESOLUTIONUNIT
)) {
287 switch (td
->td_resolutionunit
) {
289 fprintf(fd
, " (unitless)");
292 fprintf(fd
, " pixels/inch");
294 case RESUNIT_CENTIMETER
:
295 fprintf(fd
, " pixels/cm");
298 fprintf(fd
, " (unit %u = 0x%x)",
299 td
->td_resolutionunit
,
300 td
->td_resolutionunit
);
306 if (TIFFFieldSet(tif
,FIELD_POSITION
))
307 fprintf(fd
, " Position: %g, %g\n",
308 td
->td_xposition
, td
->td_yposition
);
309 if (TIFFFieldSet(tif
,FIELD_BITSPERSAMPLE
))
310 fprintf(fd
, " Bits/Sample: %u\n", td
->td_bitspersample
);
311 if (TIFFFieldSet(tif
,FIELD_SAMPLEFORMAT
)) {
312 fprintf(fd
, " Sample Format: ");
313 switch (td
->td_sampleformat
) {
314 case SAMPLEFORMAT_VOID
:
315 fprintf(fd
, "void\n");
317 case SAMPLEFORMAT_INT
:
318 fprintf(fd
, "signed integer\n");
320 case SAMPLEFORMAT_UINT
:
321 fprintf(fd
, "unsigned integer\n");
323 case SAMPLEFORMAT_IEEEFP
:
324 fprintf(fd
, "IEEE floating point\n");
326 case SAMPLEFORMAT_COMPLEXINT
:
327 fprintf(fd
, "complex signed integer\n");
329 case SAMPLEFORMAT_COMPLEXIEEEFP
:
330 fprintf(fd
, "complex IEEE floating point\n");
333 fprintf(fd
, "%u (0x%x)\n",
334 td
->td_sampleformat
, td
->td_sampleformat
);
338 if (TIFFFieldSet(tif
,FIELD_COMPRESSION
)) {
339 const TIFFCodec
* c
= TIFFFindCODEC(td
->td_compression
);
340 fprintf(fd
, " Compression Scheme: ");
342 fprintf(fd
, "%s\n", c
->name
);
344 fprintf(fd
, "%u (0x%x)\n",
345 td
->td_compression
, td
->td_compression
);
347 if (TIFFFieldSet(tif
,FIELD_PHOTOMETRIC
)) {
348 fprintf(fd
, " Photometric Interpretation: ");
349 if (td
->td_photometric
< NPHOTONAMES
)
350 fprintf(fd
, "%s\n", photoNames
[td
->td_photometric
]);
352 switch (td
->td_photometric
) {
353 case PHOTOMETRIC_LOGL
:
354 fprintf(fd
, "CIE Log2(L)\n");
356 case PHOTOMETRIC_LOGLUV
:
357 fprintf(fd
, "CIE Log2(L) (u',v')\n");
360 fprintf(fd
, "%u (0x%x)\n",
361 td
->td_photometric
, td
->td_photometric
);
366 if (TIFFFieldSet(tif
,FIELD_EXTRASAMPLES
) && td
->td_extrasamples
) {
367 fprintf(fd
, " Extra Samples: %u<", td
->td_extrasamples
);
369 for (i
= 0; i
< td
->td_extrasamples
; i
++) {
370 switch (td
->td_sampleinfo
[i
]) {
371 case EXTRASAMPLE_UNSPECIFIED
:
372 fprintf(fd
, "%sunspecified", sep
);
374 case EXTRASAMPLE_ASSOCALPHA
:
375 fprintf(fd
, "%sassoc-alpha", sep
);
377 case EXTRASAMPLE_UNASSALPHA
:
378 fprintf(fd
, "%sunassoc-alpha", sep
);
381 fprintf(fd
, "%s%u (0x%x)", sep
,
382 td
->td_sampleinfo
[i
], td
->td_sampleinfo
[i
]);
389 if (TIFFFieldSet(tif
,FIELD_INKNAMES
)) {
391 fprintf(fd
, " Ink Names: ");
392 i
= td
->td_samplesperpixel
;
394 for (cp
= td
->td_inknames
;
395 i
> 0 && cp
< td
->td_inknames
+ td
->td_inknameslen
;
396 cp
= strchr(cp
,'\0')+1, i
--) {
398 td
->td_inknameslen
- (cp
- td
->td_inknames
);
400 _TIFFprintAsciiBounded(fd
, cp
, max_chars
);
405 if (TIFFFieldSet(tif
,FIELD_THRESHHOLDING
)) {
406 fprintf(fd
, " Thresholding: ");
407 switch (td
->td_threshholding
) {
408 case THRESHHOLD_BILEVEL
:
409 fprintf(fd
, "bilevel art scan\n");
411 case THRESHHOLD_HALFTONE
:
412 fprintf(fd
, "halftone or dithered scan\n");
414 case THRESHHOLD_ERRORDIFFUSE
:
415 fprintf(fd
, "error diffused\n");
418 fprintf(fd
, "%u (0x%x)\n",
419 td
->td_threshholding
, td
->td_threshholding
);
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");
429 case FILLORDER_LSB2MSB
:
430 fprintf(fd
, "lsb-to-msb\n");
433 fprintf(fd
, "%u (0x%x)\n",
434 td
->td_fillorder
, td
->td_fillorder
);
438 if (TIFFFieldSet(tif
,FIELD_YCBCRSUBSAMPLING
))
440 fprintf(fd
, " YCbCr Subsampling: %u, %u\n",
441 td
->td_ycbcrsubsampling
[0], td
->td_ycbcrsubsampling
[1] );
443 if (TIFFFieldSet(tif
,FIELD_YCBCRPOSITIONING
)) {
444 fprintf(fd
, " YCbCr Positioning: ");
445 switch (td
->td_ycbcrpositioning
) {
446 case YCBCRPOSITION_CENTERED
:
447 fprintf(fd
, "centered\n");
449 case YCBCRPOSITION_COSITED
:
450 fprintf(fd
, "cosited\n");
453 fprintf(fd
, "%u (0x%x)\n",
454 td
->td_ycbcrpositioning
, td
->td_ycbcrpositioning
);
458 if (TIFFFieldSet(tif
,FIELD_HALFTONEHINTS
))
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
]);
466 fprintf(fd
, "%u (0x%x)\n",
467 td
->td_orientation
, td
->td_orientation
);
469 if (TIFFFieldSet(tif
,FIELD_SAMPLESPERPIXEL
))
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");
476 fprintf(fd
, "%lu\n", (unsigned long) td
->td_rowsperstrip
);
478 if (TIFFFieldSet(tif
,FIELD_MINSAMPLEVALUE
))
479 fprintf(fd
, " Min Sample Value: %u\n", td
->td_minsamplevalue
);
480 if (TIFFFieldSet(tif
,FIELD_MAXSAMPLEVALUE
))
481 fprintf(fd
, " Max Sample Value: %u\n", td
->td_maxsamplevalue
);
482 if (TIFFFieldSet(tif
,FIELD_SMINSAMPLEVALUE
)) {
483 int count
= (tif
->tif_flags
& TIFF_PERSAMPLE
) ? td
->td_samplesperpixel
: 1;
484 fprintf(fd
, " SMin Sample Value:");
485 for (i
= 0; i
< count
; ++i
)
486 fprintf(fd
, " %g", td
->td_sminsamplevalue
[i
]);
489 if (TIFFFieldSet(tif
,FIELD_SMAXSAMPLEVALUE
)) {
490 int count
= (tif
->tif_flags
& TIFF_PERSAMPLE
) ? td
->td_samplesperpixel
: 1;
491 fprintf(fd
, " SMax Sample Value:");
492 for (i
= 0; i
< count
; ++i
)
493 fprintf(fd
, " %g", td
->td_smaxsamplevalue
[i
]);
496 if (TIFFFieldSet(tif
,FIELD_PLANARCONFIG
)) {
497 fprintf(fd
, " Planar Configuration: ");
498 switch (td
->td_planarconfig
) {
499 case PLANARCONFIG_CONTIG
:
500 fprintf(fd
, "single image plane\n");
502 case PLANARCONFIG_SEPARATE
:
503 fprintf(fd
, "separate image planes\n");
506 fprintf(fd
, "%u (0x%x)\n",
507 td
->td_planarconfig
, td
->td_planarconfig
);
511 if (TIFFFieldSet(tif
,FIELD_PAGENUMBER
))
512 fprintf(fd
, " Page Number: %u-%u\n",
513 td
->td_pagenumber
[0], td
->td_pagenumber
[1]);
514 if (TIFFFieldSet(tif
,FIELD_COLORMAP
)) {
515 fprintf(fd
, " Color Map: ");
516 if (flags
& TIFFPRINT_COLORMAP
) {
518 n
= 1L<<td
->td_bitspersample
;
519 for (l
= 0; l
< n
; l
++)
520 fprintf(fd
, " %5lu: %5u %5u %5u\n",
522 td
->td_colormap
[0][l
],
523 td
->td_colormap
[1][l
],
524 td
->td_colormap
[2][l
]);
526 fprintf(fd
, "(present)\n");
528 if (TIFFFieldSet(tif
,FIELD_REFBLACKWHITE
)) {
529 fprintf(fd
, " Reference Black/White:\n");
530 for (i
= 0; i
< 3; i
++)
531 fprintf(fd
, " %2d: %5g %5g\n", i
,
532 td
->td_refblackwhite
[2*i
+0],
533 td
->td_refblackwhite
[2*i
+1]);
535 if (TIFFFieldSet(tif
,FIELD_TRANSFERFUNCTION
)) {
536 fprintf(fd
, " Transfer Function: ");
537 if (flags
& TIFFPRINT_CURVES
) {
539 n
= 1L<<td
->td_bitspersample
;
540 for (l
= 0; l
< n
; l
++) {
541 fprintf(fd
, " %2lu: %5u",
542 l
, td
->td_transferfunction
[0][l
]);
543 for (i
= 1; i
< td
->td_samplesperpixel
; i
++)
545 td
->td_transferfunction
[i
][l
]);
549 fprintf(fd
, "(present)\n");
551 if (TIFFFieldSet(tif
, FIELD_SUBIFD
) && (td
->td_subifd
)) {
552 fprintf(fd
, " SubIFD Offsets:");
553 for (i
= 0; i
< td
->td_nsubifd
; i
++)
554 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
555 fprintf(fd
, " %5I64u",
556 (unsigned __int64
) td
->td_subifd
[i
]);
558 fprintf(fd
, " %5llu",
559 (unsigned long long) td
->td_subifd
[i
]);
565 ** Custom tag support.
571 count
= (short) TIFFGetTagListCount(tif
);
572 for(i
= 0; i
< count
; i
++) {
573 uint32 tag
= TIFFGetTagListEntry(tif
, i
);
574 const TIFFField
*fip
;
579 fip
= TIFFFieldWithTag(tif
, tag
);
583 if(fip
->field_passcount
) {
584 if (fip
->field_readcount
== TIFF_VARIABLE
) {
585 if(TIFFGetField(tif
, tag
, &value_count
, &raw_data
) != 1)
587 } else if (fip
->field_readcount
== TIFF_VARIABLE2
) {
588 uint16 small_value_count
;
589 if(TIFFGetField(tif
, tag
, &small_value_count
, &raw_data
) != 1)
591 value_count
= small_value_count
;
593 assert (fip
->field_readcount
== TIFF_VARIABLE
594 || fip
->field_readcount
== TIFF_VARIABLE2
);
598 if (fip
->field_readcount
== TIFF_VARIABLE
599 || fip
->field_readcount
== TIFF_VARIABLE2
)
601 else if (fip
->field_readcount
== TIFF_SPP
)
602 value_count
= td
->td_samplesperpixel
;
604 value_count
= fip
->field_readcount
;
605 if (fip
->field_tag
== TIFFTAG_DOTRANGE
606 && strcmp(fip
->field_name
,"DotRange") == 0) {
607 /* TODO: This is an evil exception and should not have been
608 handled this way ... likely best if we move it into
609 the directory structure with an explicit field in
610 libtiff 4.1 and assign it a FIELD_ value */
611 static uint16 dotrange
[2];
613 TIFFGetField(tif
, tag
, dotrange
+0, dotrange
+1);
614 } else if (fip
->field_type
== TIFF_ASCII
615 || fip
->field_readcount
== TIFF_VARIABLE
616 || fip
->field_readcount
== TIFF_VARIABLE2
617 || fip
->field_readcount
== TIFF_SPP
618 || value_count
> 1) {
619 if(TIFFGetField(tif
, tag
, &raw_data
) != 1)
622 raw_data
= _TIFFmalloc(
623 _TIFFDataSize(fip
->field_type
)
626 if(TIFFGetField(tif
, tag
, raw_data
) != 1) {
634 * Catch the tags which needs to be specially handled
635 * and pretty print them. If tag not handled in
636 * _TIFFPrettyPrintField() fall down and print it as
639 if (!_TIFFPrettyPrintField(tif
, fip
, fd
, tag
, value_count
, raw_data
))
640 _TIFFPrintField(fd
, fip
, value_count
, raw_data
);
647 if (tif
->tif_tagmethods
.printdir
)
648 (*tif
->tif_tagmethods
.printdir
)(tif
, fd
, flags
);
650 _TIFFFillStriles( tif
);
652 if ((flags
& TIFFPRINT_STRIPS
) &&
653 TIFFFieldSet(tif
,FIELD_STRIPOFFSETS
)) {
656 fprintf(fd
, " %lu %s:\n",
657 (long) td
->td_nstrips
,
658 isTiled(tif
) ? "Tiles" : "Strips");
659 for (s
= 0; s
< td
->td_nstrips
; s
++)
660 #if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
661 fprintf(fd
, " %3lu: [%8I64u, %8I64u]\n",
663 (unsigned __int64
) td
->td_stripoffset
[s
],
664 (unsigned __int64
) td
->td_stripbytecount
[s
]);
666 fprintf(fd
, " %3lu: [%8llu, %8llu]\n",
668 (unsigned long long) td
->td_stripoffset
[s
],
669 (unsigned long long) td
->td_stripbytecount
[s
]);
675 _TIFFprintAscii(FILE* fd
, const char* cp
)
677 _TIFFprintAsciiBounded( fd
, cp
, strlen(cp
));
681 _TIFFprintAsciiBounded(FILE* fd
, const char* cp
, int max_chars
)
683 for (; max_chars
> 0 && *cp
!= '\0'; cp
++, max_chars
--) {
686 if (isprint((int)*cp
)) {
690 for (tp
= "\tt\bb\rr\nn\vv"; *tp
; tp
++)
694 fprintf(fd
, "\\%c", *tp
);
696 fprintf(fd
, "\\%03o", *cp
& 0xff);
701 _TIFFprintAsciiTag(FILE* fd
, const char* name
, const char* value
)
703 fprintf(fd
, " %s: \"", name
);
704 _TIFFprintAscii(fd
, value
);
708 /* vim: set ts=8 sts=8 sw=8 noet: */