38
_TIFFprintAsciiBounded(FILE* fd, const char* cp, int max_chars);
37
40
static const char *photoNames[] = {
38
41
"min-is-white", /* PHOTOMETRIC_MINISWHITE */
39
42
"min-is-black", /* PHOTOMETRIC_MINISBLACK */
138
_TIFFPrettyPrintField(TIFF* tif, FILE* fd, uint32 tag,
141
_TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32 tag,
139
142
uint32 value_count, void *raw_data)
146
/* do not try to pretty print auto-defined fields */
147
if (strncmp(fip->field_name,"Tag ", 4) == 0) {
145
153
case TIFFTAG_INKSET:
146
fprintf(fd, " Ink Set: ");
147
switch (*((uint16*)raw_data)) {
154
if (value_count == 2 && fip->field_type == TIFF_SHORT) {
155
fprintf(fd, " Ink Set: ");
156
switch (*((uint16*)raw_data)) {
148
157
case INKSET_CMYK:
149
158
fprintf(fd, "CMYK\n");
152
161
fprintf(fd, "%u (0x%x)\n",
153
*((uint16*)raw_data),
154
*((uint16*)raw_data));
162
*((uint16*)raw_data),
163
*((uint16*)raw_data));
158
170
case TIFFTAG_DOTRANGE:
159
fprintf(fd, " Dot Range: %u-%u\n",
160
((uint16*)raw_data)[0], ((uint16*)raw_data)[1]);
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]);
162
178
case TIFFTAG_WHITEPOINT:
163
fprintf(fd, " White Point: %g-%g\n",
164
((float *)raw_data)[0], ((float *)raw_data)[1]);
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]);
166
186
case TIFFTAG_XMLPACKET:
182
202
" RichTIFFIPTC Data: <present>, %lu bytes\n",
183
203
(unsigned long) value_count * 4);
185
206
case TIFFTAG_PHOTOSHOP:
186
207
fprintf(fd, " Photoshop Data: <present>, %lu bytes\n",
187
208
(unsigned long) value_count);
189
211
case TIFFTAG_ICCPROFILE:
190
212
fprintf(fd, " ICC Profile: <present>, %lu bytes\n",
191
213
(unsigned long) value_count);
193
216
case TIFFTAG_STONITS:
195
" Sample to Nits conversion factor: %.4e\n",
196
*((double*)raw_data));
217
if (value_count == 1 && fip->field_type == TIFF_DOUBLE) {
219
" Sample to Nits conversion factor: %.4e\n",
220
*((double*)raw_data));
364
390
fprintf(fd, " Ink Names: ");
365
391
i = td->td_samplesperpixel;
367
for (cp = td->td_inknames; i > 0; cp = strchr(cp,'\0')+1, i--) {
393
for (cp = td->td_inknames;
394
i > 0 && cp < td->td_inknames + td->td_inknameslen;
395
cp = strchr(cp,'\0')+1, i--) {
397
td->td_inknameslen - (cp - td->td_inknames);
369
_TIFFprintAscii(fd, cp);
399
_TIFFprintAsciiBounded(fd, cp, max_chars);
449
479
if (TIFFFieldSet(tif,FIELD_MAXSAMPLEVALUE))
450
480
fprintf(fd, " Max Sample Value: %u\n", td->td_maxsamplevalue);
451
481
if (TIFFFieldSet(tif,FIELD_SMINSAMPLEVALUE)) {
482
int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1;
452
483
fprintf(fd, " SMin Sample Value:");
453
for (i = 0; i < td->td_samplesperpixel; ++i)
484
for (i = 0; i < count; ++i)
454
485
fprintf(fd, " %g", td->td_sminsamplevalue[i]);
455
486
fprintf(fd, "\n");
457
488
if (TIFFFieldSet(tif,FIELD_SMAXSAMPLEVALUE)) {
489
int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1;
458
490
fprintf(fd, " SMax Sample Value:");
459
for (i = 0; i < td->td_samplesperpixel; ++i)
491
for (i = 0; i < count; ++i)
460
492
fprintf(fd, " %g", td->td_smaxsamplevalue[i]);
461
493
fprintf(fd, "\n");
550
582
if(fip->field_passcount) {
551
if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1)
583
if (fip->field_readcount == TIFF_VARIABLE2 ) {
584
if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1)
586
} else if (fip->field_readcount == TIFF_VARIABLE2 ) {
587
uint16 small_value_count;
588
if(TIFFGetField(tif, tag, &small_value_count, &raw_data) != 1)
590
value_count = small_value_count;
592
assert (fip->field_readcount == TIFF_VARIABLE
593
|| fip->field_readcount == TIFF_VARIABLE2);
554
597
if (fip->field_readcount == TIFF_VARIABLE
555
598
|| fip->field_readcount == TIFF_VARIABLE2)
558
601
value_count = td->td_samplesperpixel;
560
603
value_count = fip->field_readcount;
561
if ((fip->field_type == TIFF_ASCII
562
|| fip->field_readcount == TIFF_VARIABLE
563
|| fip->field_readcount == TIFF_VARIABLE2
564
|| fip->field_readcount == TIFF_SPP
566
&& fip->field_tag != TIFFTAG_PAGENUMBER
567
&& fip->field_tag != TIFFTAG_HALFTONEHINTS
568
&& fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING
569
&& fip->field_tag != TIFFTAG_DOTRANGE) {
604
if (fip->field_tag == TIFFTAG_DOTRANGE
605
&& strcmp(fip->field_name,"DotRange") == 0) {
606
/* TODO: This is an evil exception and should not have been
607
handled this way ... likely best if we move it into
608
the directory structure with an explicit field in
609
libtiff 4.1 and assign it a FIELD_ value */
610
static uint16 dotrange[2];
612
TIFFGetField(tif, tag, dotrange+0, dotrange+1);
613
} else if (fip->field_type == TIFF_ASCII
614
|| fip->field_readcount == TIFF_VARIABLE
615
|| fip->field_readcount == TIFF_VARIABLE2
616
|| fip->field_readcount == TIFF_SPP
617
|| value_count > 1) {
570
618
if(TIFFGetField(tif, tag, &raw_data) != 1)
572
} else if (fip->field_tag != TIFFTAG_PAGENUMBER
573
&& fip->field_tag != TIFFTAG_HALFTONEHINTS
574
&& fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING
575
&& fip->field_tag != TIFFTAG_DOTRANGE) {
576
621
raw_data = _TIFFmalloc(
577
622
_TIFFDataSize(fip->field_type)
581
626
_TIFFfree(raw_data);
586
* XXX: Should be fixed and removed,
587
* see the notes related to
588
* TIFFTAG_PAGENUMBER,
589
* TIFFTAG_HALFTONEHINTS,
590
* TIFFTAG_YCBCRSUBSAMPLING and
591
* TIFFTAG_DOTRANGE tags in tif_dir.c.
594
raw_data = _TIFFmalloc(
595
_TIFFDataSize(fip->field_type)
599
if(TIFFGetField(tif, tag, tmp,
600
tmp + _TIFFDataSize(fip->field_type)) != 1) {
610
635
* _TIFFPrettyPrintField() fall down and print it as
613
if (!_TIFFPrettyPrintField(tif, fd, tag, value_count, raw_data))
638
if (!_TIFFPrettyPrintField(tif, fip, fd, tag, value_count, raw_data))
614
639
_TIFFPrintField(fd, fip, value_count, raw_data);
649
674
_TIFFprintAscii(FILE* fd, const char* cp)
651
for (; *cp != '\0'; cp++) {
676
_TIFFprintAsciiBounded( fd, cp, strlen(cp));
680
_TIFFprintAsciiBounded(FILE* fd, const char* cp, int max_chars)
682
for (; max_chars > 0 && *cp != '\0'; cp++, max_chars--) {
654
685
if (isprint((int)*cp)) {