Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -636,16 +636,7 @@ set(CBF_WITH_LIBTIFF ON CACHE BOOL
mark_as_advanced(CBF_WITH_LIBTIFF)

if(CBF_WITH_LIBTIFF)
# The first LibTIFF at https://download.osgeo.org/libtiff with
# native CMake support seems to be 4.0.5. The first version that
# builds on current MSYS2 is 4.0.9.
#
# 4.0.3-rev-29Sep13 appears to have CMakeLists.txt patched in but
# fails on MSYS2: multiple definition of ua_wcsicmp.
#
# 4.0.6_rev_3Nov16 fails on MSYS2: _FILE_OFFSET_BITS not defined
#
# 4.0.8 fails on MSYS2: _FILE_OFFSET_BITS
# TIFFFieldSetGetSize() was introduced in LibTIFF 4.4.0
set(tiff-contrib OFF CACHE INTERNAL "Build TIFF contrib")
set(tiff-docs OFF CACHE INTERNAL "Build TIFF documentation")
set(tiff-tests OFF CACHE INTERNAL "Build TIFF tests")
Expand All @@ -663,7 +654,7 @@ else()
# cmake_pkg_config(), because e.g. Debian does not ship CMake config
# files in their dev packages.
find_package(PkgConfig REQUIRED)
pkg_check_modules(tiff REQUIRED IMPORTED_TARGET libtiff-4>=4.0.10)
pkg_check_modules(tiff REQUIRED IMPORTED_TARGET libtiff-4>=4.4.0)
add_library(tiff ALIAS PkgConfig::tiff)
endif()

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2291,7 +2291,7 @@ $(BIN)/sequence_match: $(LIB)/libcbf.a $(EXAMPLES)/sequence_match.c $(LIB)/libim
#
# cbf2tiff example program
#
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c $(EXAMPLES)/tif_sprint.c \
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c \
$(GOPTLIB) $(GOPTINC) $(TIFF)
mkdir -p $(BIN)
$(CC) $(CFLAGS) $(LDFLAGS) $(MISCFLAG) $(CBF_REGEXFLAG) $(INCLUDES) $(WARNINGS) \
Expand Down
2 changes: 1 addition & 1 deletion Makefile_LINUX
Original file line number Diff line number Diff line change
Expand Up @@ -2287,7 +2287,7 @@ $(BIN)/sequence_match: $(LIB)/libcbf.a $(EXAMPLES)/sequence_match.c $(LIB)/libim
#
# cbf2tiff example program
#
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c $(EXAMPLES)/tif_sprint.c \
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c \
$(GOPTLIB) $(GOPTINC) $(TIFF)
mkdir -p $(BIN)
$(CC) $(CFLAGS) $(LDFLAGS) $(MISCFLAG) $(CBF_REGEXFLAG) $(INCLUDES) $(WARNINGS) \
Expand Down
2 changes: 1 addition & 1 deletion Makefile_MINGW
Original file line number Diff line number Diff line change
Expand Up @@ -2301,7 +2301,7 @@ $(BIN)/sequence_match: $(LIB)/libcbf.a $(EXAMPLES)/sequence_match.c $(LIB)/libim
#
# cbf2tiff example program
#
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c $(EXAMPLES)/tif_sprint.c \
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c \
$(GOPTLIB) $(GOPTINC) $(TIFF)
mkdir -p $(BIN)
$(CC) $(CFLAGS) $(LDFLAGS) $(MISCFLAG) $(CBF_REGEXFLAG) $(INCLUDES) $(WARNINGS) \
Expand Down
2 changes: 1 addition & 1 deletion Makefile_MSYS2
Original file line number Diff line number Diff line change
Expand Up @@ -2286,7 +2286,7 @@ $(BIN)/sequence_match: $(LIB)/libcbf.a $(EXAMPLES)/sequence_match.c $(LIB)/libim
#
# cbf2tiff example program
#
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c $(EXAMPLES)/tif_sprint.c \
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c \
$(GOPTLIB) $(GOPTINC) $(TIFF)
mkdir -p $(BIN)
$(CC) $(CFLAGS) $(LDFLAGS) $(MISCFLAG) $(CBF_REGEXFLAG) $(INCLUDES) $(WARNINGS) \
Expand Down
2 changes: 1 addition & 1 deletion Makefile_OSX
Original file line number Diff line number Diff line change
Expand Up @@ -2283,7 +2283,7 @@ $(BIN)/sequence_match: $(LIB)/libcbf.a $(EXAMPLES)/sequence_match.c $(LIB)/libim
#
# cbf2tiff example program
#
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c $(EXAMPLES)/tif_sprint.c \
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c \
$(GOPTLIB) $(GOPTINC) $(TIFF)
mkdir -p $(BIN)
$(CC) $(CFLAGS) $(LDFLAGS) $(MISCFLAG) $(CBF_REGEXFLAG) $(INCLUDES) $(WARNINGS) \
Expand Down
68 changes: 9 additions & 59 deletions examples/tif_sprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,40 +78,6 @@ static const char *orientNames[] = {
};
#define NORIENTNAMES (sizeof (orientNames) / sizeof (orientNames[0]))

/*
* Return data size of the field datatype in bytes. LibTIFF 4.4.0 introduced
* TIFFFieldSetGetSize() for this.
*/
static int
_TIFFFieldDataSize(const TIFFField *fip)
{
switch (TIFFFieldDataType(fip))
{
case TIFF_BYTE:
case TIFF_SBYTE:
case TIFF_ASCII:
case TIFF_UNDEFINED:
return 1;
case TIFF_SHORT:
case TIFF_SSHORT:
return 2;
case TIFF_LONG:
case TIFF_SLONG:
case TIFF_FLOAT:
case TIFF_IFD:
case TIFF_RATIONAL:
case TIFF_SRATIONAL:
return 4;
case TIFF_DOUBLE:
case TIFF_LONG8:
case TIFF_SLONG8:
case TIFF_IFD8:
return 8;
default:
return 0;
}
}

static size_t
_TIFFSNPrintField(char * str, const size_t xstrlen, const TIFFField *fip,
uint32_t value_count, void *raw_data)
Expand Down Expand Up @@ -141,8 +107,8 @@ _TIFFSNPrintField(char * str, const size_t xstrlen, const TIFFField *fip,
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), "0x%" PRIx32, ((uint32_t *) raw_data)[j]);
else if(TIFFFieldDataType(fip) == TIFF_RATIONAL
|| TIFFFieldDataType(fip) == TIFF_SRATIONAL) {
if (_TIFFFieldDataSize(fip) == 8)
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), "%lf", ((double *)raw_data)[j]);
if (TIFFFieldSetGetSize(fip) == 8)
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), "%lf", ((double *) raw_data)[j]);
else
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), "%f", ((float *) raw_data)[j]);
} else if(TIFFFieldDataType(fip) == TIFF_FLOAT)
Expand Down Expand Up @@ -289,8 +255,8 @@ cbf_TIFFSNPrintDirectory(TIFF* tif, char * str, const size_t xstrlen, long flags
size_t chars_used = 0;

chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), "TIFF Directory at offset 0x%" PRIx64 " (%" PRIu64 ")\n",
TIFFCurrentDirOffset(tif),
TIFFCurrentDirOffset(tif));
TIFFCurrentDirOffset(tif),
TIFFCurrentDirOffset(tif));
if (!TIFFGetField(tif, TIFFTAG_EXTRASAMPLES, &extrasamples, &sampleinfo)) {
extrasamples = 0;
sampleinfo = NULL;
Expand All @@ -316,7 +282,7 @@ cbf_TIFFSNPrintDirectory(TIFF* tif, char * str, const size_t xstrlen, long flags
if (TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength)
&& TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imagewidth)) {
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), " Image Width: %" PRIu32 " Image Length: %" PRIu32,
imagewidth, imagelength);
imagewidth, imagelength);
if (TIFFGetField(tif, TIFFTAG_IMAGEDEPTH, &imagedepth))
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), " Image Depth: %" PRIu32,
imagedepth);
Expand Down Expand Up @@ -450,7 +416,7 @@ cbf_TIFFSNPrintDirectory(TIFF* tif, char * str, const size_t xstrlen, long flags
cp = strchr(cp,'\0')+1, i--) {
size_t max_chars =
inknameslen - (cp - inknames);
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0),sep);
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), "%s", sep);
chars_used += _TIFFsnprintAsciiBounded(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), cp, max_chars);
sep = ", ";
}
Expand Down Expand Up @@ -667,7 +633,7 @@ cbf_TIFFSNPrintDirectory(TIFF* tif, char * str, const size_t xstrlen, long flags
/*--: Rational2Double: For Rationals evaluate
* "set_field_type" to determine internal storage size. */
raw_data = _TIFFmalloc(
_TIFFFieldDataSize(fip)
TIFFFieldSetGetSize(fip)
* value_count);
mem_alloc = 1;
if(TIFFGetField(tif, tag, raw_data) != 1) {
Expand Down Expand Up @@ -698,8 +664,8 @@ cbf_TIFFSNPrintDirectory(TIFF* tif, char * str, const size_t xstrlen, long flags
/* _TIFFFillStriles( tif ); */

if ((flags & TIFFPRINT_STRIPS) &&
TIFFGetField(tif, TIFFTAG_STRIPOFFSETS, &stripoffsets) &&
TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbytecounts)) {
TIFFGetField(tif, TIFFTAG_STRIPOFFSETS, &stripoffsets) &&
TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbytecounts)) {
uint32_t s;

chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), " %" PRIu32 " %s:\n",
Expand All @@ -714,12 +680,6 @@ cbf_TIFFSNPrintDirectory(TIFF* tif, char * str, const size_t xstrlen, long flags
return chars_used;
}

size_t
_TIFFsnprintAscii(char * str, const size_t xstrlen, const char* cp)
{
return _TIFFsnprintAsciiBounded( str, xstrlen, cp, strlen(cp));
}

static size_t
_TIFFsnprintAsciiBounded(char * str, const size_t xstrlen, const char* cp, size_t max_chars)
{
Expand All @@ -742,16 +702,6 @@ _TIFFsnprintAsciiBounded(char * str, const size_t xstrlen, const char* cp, size_
return chars_used;
}

size_t
_TIFFsnprintAsciiTag(char * str, const size_t xstrlen, const char* name, const char* value)
{
size_t chars_used=0;
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), " %s: \"", name);
chars_used += _TIFFsnprintAscii(str+chars_used, xstrlen, value);
chars_used += snprintf(str+chars_used, ((xstrlen>chars_used)?xstrlen-chars_used:0), "\"\n");
return chars_used;
}

/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
Expand Down
2 changes: 1 addition & 1 deletion m4/Makefile.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2654,7 +2654,7 @@ $(BIN)/sequence_match: $(LIB)/libcbf.a $(EXAMPLES)/sequence_match.c $(LIB)/libim
#
# cbf2tiff example program
#
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c $(EXAMPLES)/tif_sprint.c \
$(BIN)/cbf2tiff: $(LIB)/libcbf.a $(EXAMPLES)/cbf2tiff.c \
$(GOPTLIB) $(GOPTINC) $(TIFF)
mkdir -p $(BIN)
$(CC) $(CFLAGS) $(LDFLAGS) $(MISCFLAG) $(CBF_REGEXFLAG) $(INCLUDES) $(WARNINGS) \
Expand Down