@@ -78,40 +78,6 @@ static const char *orientNames[] = {
7878};
7979#define NORIENTNAMES (sizeof (orientNames) / sizeof (orientNames[0]))
8080
81- /*
82- * Return data size of the field datatype in bytes. LibTIFF 4.4.0 introduced
83- * TIFFFieldSetGetSize() for this.
84- */
85- static int
86- _TIFFFieldDataSize (const TIFFField * fip )
87- {
88- switch (TIFFFieldDataType (fip ))
89- {
90- case TIFF_BYTE :
91- case TIFF_SBYTE :
92- case TIFF_ASCII :
93- case TIFF_UNDEFINED :
94- return 1 ;
95- case TIFF_SHORT :
96- case TIFF_SSHORT :
97- return 2 ;
98- case TIFF_LONG :
99- case TIFF_SLONG :
100- case TIFF_FLOAT :
101- case TIFF_IFD :
102- case TIFF_RATIONAL :
103- case TIFF_SRATIONAL :
104- return 4 ;
105- case TIFF_DOUBLE :
106- case TIFF_LONG8 :
107- case TIFF_SLONG8 :
108- case TIFF_IFD8 :
109- return 8 ;
110- default :
111- return 0 ;
112- }
113- }
114-
11581static size_t
11682_TIFFSNPrintField (char * str , const size_t xstrlen , const TIFFField * fip ,
11783 uint32_t value_count , void * raw_data )
@@ -141,8 +107,8 @@ _TIFFSNPrintField(char * str, const size_t xstrlen, const TIFFField *fip,
141107 chars_used += snprintf (str + chars_used , ((xstrlen > chars_used )?xstrlen - chars_used :0 ), "0x%" PRIx32 , ((uint32_t * ) raw_data )[j ]);
142108 else if (TIFFFieldDataType (fip ) == TIFF_RATIONAL
143109 || TIFFFieldDataType (fip ) == TIFF_SRATIONAL ) {
144- if (_TIFFFieldDataSize (fip ) == 8 )
145- chars_used += snprintf (str + chars_used , ((xstrlen > chars_used )?xstrlen - chars_used :0 ), "%lf" , ((double * )raw_data )[j ]);
110+ if (TIFFFieldSetGetSize (fip ) == 8 )
111+ chars_used += snprintf (str + chars_used , ((xstrlen > chars_used )?xstrlen - chars_used :0 ), "%lf" , ((double * ) raw_data )[j ]);
146112 else
147113 chars_used += snprintf (str + chars_used , ((xstrlen > chars_used )?xstrlen - chars_used :0 ), "%f" , ((float * ) raw_data )[j ]);
148114 } else if (TIFFFieldDataType (fip ) == TIFF_FLOAT )
@@ -289,8 +255,8 @@ cbf_TIFFSNPrintDirectory(TIFF* tif, char * str, const size_t xstrlen, long flags
289255 size_t chars_used = 0 ;
290256
291257 chars_used += snprintf (str + chars_used , ((xstrlen > chars_used )?xstrlen - chars_used :0 ), "TIFF Directory at offset 0x%" PRIx64 " (%" PRIu64 ")\n" ,
292- TIFFCurrentDirOffset (tif ),
293- TIFFCurrentDirOffset (tif ));
258+ TIFFCurrentDirOffset (tif ),
259+ TIFFCurrentDirOffset (tif ));
294260 if (!TIFFGetField (tif , TIFFTAG_EXTRASAMPLES , & extrasamples , & sampleinfo )) {
295261 extrasamples = 0 ;
296262 sampleinfo = NULL ;
@@ -316,7 +282,7 @@ cbf_TIFFSNPrintDirectory(TIFF* tif, char * str, const size_t xstrlen, long flags
316282 if (TIFFGetField (tif , TIFFTAG_IMAGELENGTH , & imagelength )
317283 && TIFFGetField (tif , TIFFTAG_IMAGEWIDTH , & imagewidth )) {
318284 chars_used += snprintf (str + chars_used , ((xstrlen > chars_used )?xstrlen - chars_used :0 ), " Image Width: %" PRIu32 " Image Length: %" PRIu32 ,
319- imagewidth , imagelength );
285+ imagewidth , imagelength );
320286 if (TIFFGetField (tif , TIFFTAG_IMAGEDEPTH , & imagedepth ))
321287 chars_used += snprintf (str + chars_used , ((xstrlen > chars_used )?xstrlen - chars_used :0 ), " Image Depth: %" PRIu32 ,
322288 imagedepth );
@@ -450,7 +416,7 @@ cbf_TIFFSNPrintDirectory(TIFF* tif, char * str, const size_t xstrlen, long flags
450416 cp = strchr (cp ,'\0' )+ 1 , i -- ) {
451417 size_t max_chars =
452418 inknameslen - (cp - inknames );
453- chars_used += snprintf (str + chars_used , ((xstrlen > chars_used )?xstrlen - chars_used :0 ),sep );
419+ chars_used += snprintf (str + chars_used , ((xstrlen > chars_used )?xstrlen - chars_used :0 ), "%s" , sep );
454420 chars_used += _TIFFsnprintAsciiBounded (str + chars_used , ((xstrlen > chars_used )?xstrlen - chars_used :0 ), cp , max_chars );
455421 sep = ", " ;
456422 }
@@ -667,7 +633,7 @@ cbf_TIFFSNPrintDirectory(TIFF* tif, char * str, const size_t xstrlen, long flags
667633 /*--: Rational2Double: For Rationals evaluate
668634 * "set_field_type" to determine internal storage size. */
669635 raw_data = _TIFFmalloc (
670- _TIFFFieldDataSize (fip )
636+ TIFFFieldSetGetSize (fip )
671637 * value_count );
672638 mem_alloc = 1 ;
673639 if (TIFFGetField (tif , tag , raw_data ) != 1 ) {
@@ -698,8 +664,8 @@ cbf_TIFFSNPrintDirectory(TIFF* tif, char * str, const size_t xstrlen, long flags
698664 /* _TIFFFillStriles( tif ); */
699665
700666 if ((flags & TIFFPRINT_STRIPS ) &&
701- TIFFGetField (tif , TIFFTAG_STRIPOFFSETS , & stripoffsets ) &&
702- TIFFGetField (tif , TIFFTAG_STRIPBYTECOUNTS , & stripbytecounts )) {
667+ TIFFGetField (tif , TIFFTAG_STRIPOFFSETS , & stripoffsets ) &&
668+ TIFFGetField (tif , TIFFTAG_STRIPBYTECOUNTS , & stripbytecounts )) {
703669 uint32_t s ;
704670
705671 chars_used += snprintf (str + chars_used , ((xstrlen > chars_used )?xstrlen - chars_used :0 ), " %" PRIu32 " %s:\n" ,
@@ -714,12 +680,6 @@ cbf_TIFFSNPrintDirectory(TIFF* tif, char * str, const size_t xstrlen, long flags
714680 return chars_used ;
715681}
716682
717- size_t
718- _TIFFsnprintAscii (char * str , const size_t xstrlen , const char * cp )
719- {
720- return _TIFFsnprintAsciiBounded ( str , xstrlen , cp , strlen (cp ));
721- }
722-
723683static size_t
724684_TIFFsnprintAsciiBounded (char * str , const size_t xstrlen , const char * cp , size_t max_chars )
725685{
@@ -742,16 +702,6 @@ _TIFFsnprintAsciiBounded(char * str, const size_t xstrlen, const char* cp, size_
742702 return chars_used ;
743703}
744704
745- size_t
746- _TIFFsnprintAsciiTag (char * str , const size_t xstrlen , const char * name , const char * value )
747- {
748- size_t chars_used = 0 ;
749- chars_used += snprintf (str + chars_used , ((xstrlen > chars_used )?xstrlen - chars_used :0 ), " %s: \"" , name );
750- chars_used += _TIFFsnprintAscii (str + chars_used , xstrlen , value );
751- chars_used += snprintf (str + chars_used , ((xstrlen > chars_used )?xstrlen - chars_used :0 ), "\"\n" );
752- return chars_used ;
753- }
754-
755705/* vim: set ts=8 sts=8 sw=8 noet: */
756706/*
757707 * Local Variables:
0 commit comments