Codebase list libgeotiff / cc54e3b
New upstream version 1.7.1~rc1 Bas Couwenberg 2 years ago
15 changed file(s) with 289 addition(s) and 230 deletion(s). Raw diff Collapse all Expand all
1111
1212 ##############################################################################
1313 # CMake settings
14 CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
14 CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)
1515
1616 SET(CMAKE_COLOR_MAKEFILE ON)
1717
1818 # Version information
1919 set(PROJECT_VERSION_MAJOR 1)
2020 set(PROJECT_VERSION_MINOR 7)
21 set(PROJECT_VERSION_PATCH 0)
21 set(PROJECT_VERSION_PATCH 1)
2222 set(PROJECT_VERSION
2323 "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
2424 set(GeoTIFF_VERSION ${PROJECT_VERSION})
2828 # libgeotiff.so.2 -> libgeotiff.so.2.2.0
2929 # libgeotiff.so.2.2.0
3030 set(LINK_SOVERSION "5")
31 set(LINK_VERSION "5.1.0")
31 set(LINK_VERSION "5.2.0")
3232
3333 string (TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
3434 string (TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPER)
5252 IF(CMAKE_BUILD_TYPE MATCHES Debug)
5353 SET(GEOTIFF_BUILD_PEDANTIC TRUE)
5454 ENDIF()
55
56 if (CMAKE_MAJOR_VERSION GREATER 2)
57 cmake_policy(SET CMP0022 OLD) # interface link libraries
58 cmake_policy(SET CMP0042 OLD) # osx rpath
59 endif()
60
6155
6256 # TODO: Still testing the output paths --mloskot
6357 SET(GEOTIFF_BUILD_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
10296
10397 # Check required standard headers
10498 INCLUDE(CheckIncludeFiles)
105 CHECK_INCLUDE_FILES(stdio.h HAVE_STDIO_H)
106 CHECK_INCLUDE_FILES(stdlib.h HAVE_STDLIB_H)
107 CHECK_INCLUDE_FILES(string.h HAVE_STRING_H)
108 CHECK_INCLUDE_FILES(strings.h HAVE_STRINGS_H)
99 CHECK_INCLUDE_FILES(strings.h GEOTIFF_HAVE_STRINGS_H)
109100
110101 ###############################################################################
111102 # User-defined build settings
245236
246237 # ${PROJECT_BINARY_DIR}/geotiff_version.h
247238
248 IF(WIN32)
249 SET(DEFAULT_LIB_SUBDIR lib)
250 SET(DEFAULT_DATA_SUBDIR .)
251 SET(DEFAULT_INCLUDE_SUBDIR include)
252
253 IF(MSVC)
254 SET(DEFAULT_BIN_SUBDIR bin)
255 ELSE()
256 SET(DEFAULT_BIN_SUBDIR .)
257 ENDIF()
258 ELSE()
259 # Common locatoins for Unix and Mac OS X
260 SET(DEFAULT_BIN_SUBDIR bin)
261 SET(DEFAULT_LIB_SUBDIR lib)
262 SET(DEFAULT_DATA_SUBDIR share)
263 SET(DEFAULT_INCLUDE_SUBDIR include)
264 ENDIF()
239 SET(DEFAULT_BIN_SUBDIR bin)
240 SET(DEFAULT_LIB_SUBDIR lib)
241 SET(DEFAULT_INCLUDE_SUBDIR include)
265242
266243 # Locations are changeable by user to customize layout of GeoTIFF installation
267244 # (default values are platform-specIFic)
271248 "Subdirectory where libraries will be installed")
272249 SET(GEOTIFF_INCLUDE_SUBDIR ${DEFAULT_INCLUDE_SUBDIR} CACHE STRING
273250 "Subdirectory where header files will be installed")
274 SET(GEOTIFF_DATA_SUBDIR ${DEFAULT_DATA_SUBDIR} CACHE STRING
275 "Subdirectory where data will be installed")
276251
277252 # Mark *_SUBDIR variables as advanced and dedicated to use by power-users only.
278 MARK_AS_ADVANCED(GEOTIFF_BIN_SUBDIR GEOTIFF_LIB_SUBDIR GEOTIFF_INCLUDE_SUBDIR GEOTIFF_DATA_SUBDIR)
253 MARK_AS_ADVANCED(GEOTIFF_BIN_SUBDIR GEOTIFF_LIB_SUBDIR GEOTIFF_INCLUDE_SUBDIR)
279254
280255 # Full paths for the installation
281256 SET(GEOTIFF_BIN_DIR ${GEOTIFF_BIN_SUBDIR})
282257 SET(GEOTIFF_LIB_DIR ${GEOTIFF_LIB_SUBDIR})
283258 SET(GEOTIFF_INCLUDE_DIR ${GEOTIFF_INCLUDE_SUBDIR})
284 SET(GEOTIFF_DATA_DIR ${GEOTIFF_DATA_SUBDIR})
285259
286260 # Install doc files
287261 INSTALL(FILES
288262 AUTHORS ChangeLog COPYING INSTALL LICENSE README README_BIN README.WIN
289263 DESTINATION doc)
290 # DESTINATION ${GEOTIFF_DATA_DIR}/doc)
291264
292265 # Install man pages
293266 INSTALL(FILES ${GEOTIFF_MAN_PAGES} DESTINATION share/man/man1)
294267
295268
296269 # Install header files for development distribution
297 # INSTALL(FILES ${GEOTIFF_LIB_HEADERS} DESTINATION ${GEOTIFF_INCLUDE_DIR})
298 INSTALL(FILES ${GEOTIFF_LIB_HEADERS} DESTINATION include)
270 INSTALL(FILES ${GEOTIFF_LIB_HEADERS} DESTINATION ${GEOTIFF_INCLUDE_DIR})
299271
300272 ###############################################################################
301273 # Build libxtiff library
337309 ENDIF(WIN32 AND MSVC)
338310
339311 # Unix, linux:
340 IF(UNIX)
312 if(UNIX)
341313 SET_TARGET_PROPERTIES(
342314 ${GEOTIFF_LIBRARY_TARGET}
343315 PROPERTIES
344 OUTPUT_NAME ${GEOTIFF_LIB_NAME}
345316 VERSION ${LINK_VERSION}
346317 SOVERSION ${LINK_SOVERSION}
347318 CLEAN_DIRECT_OUTPUT 1 )
349320 set_target_properties(
350321 ${GEOTIFF_LIBRARY_TARGET}
351322 PROPERTIES
352 INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
323 INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${GEOTIFF_LIB_DIR}")
353324 endif()
354
355 ELSE(UNIX)
356 # Default:
357 SET_TARGET_PROPERTIES(${GEOTIFF_LIBRARY_TARGET} PROPERTIES
358 OUTPUT_NAME ${GEOTIFF_LIB_NAME})
359 ENDIF(UNIX)
325 endif()
360326
361327 SET_TARGET_PROPERTIES(${GEOTIFF_LIBRARY_TARGET} PROPERTIES
362328 OUTPUT_NAME ${GEOTIFF_LIB_NAME})
363329
364 TARGET_LINK_LIBRARIES(${GEOTIFF_LIBRARY_TARGET}
365 ${TIFF_LIBRARIES}
366 ${PROJ_LIBRARIES}
367 ${ZLIB_LIBRARIES}
368 ${JPEG_LIBRARIES})
369
370 # INSTALL(TARGETS ${GEOTIFF_ARCHIVE_TARGET} ${GEOTIFF_LIBRARY_TARGET}
371 # RUNTIME DESTINATION ${GEOTIFF_BIN_DIR}
372 # LIBRARY DESTINATION ${GEOTIFF_LIB_DIR}
373 # ARCHIVE DESTINATION ${GEOTIFF_LIB_DIR})
330 if(TARGET TIFF::TIFF)
331 target_link_libraries(${GEOTIFF_LIBRARY_TARGET} PUBLIC TIFF::TIFF)
332 else()
333 target_link_libraries(${GEOTIFF_LIBRARY_TARGET} PUBLIC
334 ${TIFF_LIBRARIES})
335 endif()
336
337 if(TARGET PROJ::proj)
338 target_link_libraries(${GEOTIFF_LIBRARY_TARGET} PRIVATE PROJ::proj)
339 else()
340 target_link_libraries(${GEOTIFF_LIBRARY_TARGET} PRIVATE
341 ${PROJ_LIBRARIES})
342 endif()
343
344 target_include_directories(
345 ${GEOTIFF_LIBRARY_TARGET}
346 PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
347 $<INSTALL_INTERFACE:${GEOTIFF_INCLUDE_DIR}>)
374348
375349 INSTALL( TARGETS ${GEOTIFF_LIBRARY_TARGET}
376 EXPORT depends
377 RUNTIME DESTINATION bin
378 LIBRARY DESTINATION lib
379 ARCHIVE DESTINATION lib )
350 EXPORT depends
351 RUNTIME DESTINATION ${GEOTIFF_BIN_DIR}
352 LIBRARY DESTINATION ${GEOTIFF_LIB_DIR}
353 PUBLIC_HEADER DESTINATION ${GEOTIFF_INCLUDE_DIR}
354 ARCHIVE DESTINATION ${GEOTIFF_LIB_DIR} )
380355
381356 # Define grouping of source files in PROJECT file (e.g. Visual Studio)
382357 SOURCE_GROUP("CMake Files" FILES CMakeLists.txt)
22 ====================
33
44 All the source code in this toolkit are either in the public domain, or under
5 an X style license. In any event it is all considered to be free to use
5 the MIT License. In any event it is all considered to be free to use
66 for any purpose (including commercial software). No credit is required
77 though some of the code requires that the specific source code modules
88 retain their existing copyright statements. In
5252 geo_strtod.c \
5353 geotiff_proj4.c
5454
55 libgeotiff_la_LDFLAGS = -version-info 7:0:2 ${NOUNDEFINED}
55 libgeotiff_la_LDFLAGS = -version-info 7:1:2 ${NOUNDEFINED}
5656
5757 libgeotiff_la_LIBADD = libxtiff/libxtiff.la
5858
0 libgeotiff 1.7.1
1 ----------------
2
3 * geotiff.h: more precise signature for GTIFDirectoryInfo()
4 * applygeo.c/geotifcp.c: use uint16/32_t instead of old libtiff non _t custom types
5 * Bump CMake min to 3.0.0 and remove apparently unneeded cmake_policy() declarations
6 * CMake: remove libjpeg and libz from linking of libgeotiff itself.
7 * geo_config.h: prefix HAVE_xxx and restrict it to GEOTIFF_HAVE_STRINGS_H (fixes #61)
8 * GTIFPrintDefn(): avoid potential nullptr deref. CID 1469240
9 * CMake: use variable for installation subdirectories, and make sure INTERFACE_INCLUDE_DIRECTORIES is exported (fixes #67)
10 * ReadKey(): only allow reading a key with TIFFTagLocation=0 that has a count of 1 to avoid reading an illegal address (and crashing) when using GTIFKeyGet() or PrintKey() (fixes #66)
11 * ReadKey(): add extra warning messages
12 * CMake: avoid INTERFACE_LINK_LIBRARIES vs LINK_INTERFACE_LIBRARIES_DEBUG warning about TIFF
13
014 libgeotiff 1.7.0
115 ----------------
216
2121
2222 FOREACH(utility ${GEOTIFF_UTILITIES})
2323 ADD_EXECUTABLE(${utility} ${utility}.c ${GETOPT_SOURCE})
24 TARGET_LINK_LIBRARIES(${utility} xtiff ${GEOTIFF_LIBRARY_TARGET})
24 TARGET_LINK_LIBRARIES(${utility} PRIVATE xtiff ${GEOTIFF_LIBRARY_TARGET})
2525 ENDFOREACH()
2626
2727 ADD_EXECUTABLE(geotifcp geotifcp.c ${GETOPT_SOURCE})
2828 TARGET_LINK_LIBRARIES(geotifcp
29 PRIVATE
2930 xtiff
3031 ${GEOTIFF_LIBRARY_TARGET}
3132 ${JPEG_LIBRARIES}
00 /* applygeo.c */
1 #include <stdint.h>
12 #include <stdlib.h>
23 #include "geotiff.h"
34 #include "xtiffio.h"
910 GTIF *gtif; /* GeoKey-level descriptor */
1011 FILE *fp;
1112
12 uint16 *panVI = NULL;
13 uint16 nKeyCount;
13 uint16_t *panVI = NULL;
14 uint16_t nKeyCount;
1415
1516 tif = XTIFFOpen(tiffile, "r+");
1617 if (!tif)
2728 if( TIFFGetField( tif, TIFFTAG_GEOKEYDIRECTORY,
2829 &nKeyCount, &panVI ) )
2930 {
30 uint16 anGKVersionInfo[4] = { 1, 1, 0, 0 };
31 uint16_t anGKVersionInfo[4] = { 1, 1, 0, 0 };
3132 double adfDummyDoubleParams[1] = { 0.0 };
3233
3334 TIFFSetField( tif, TIFFTAG_GEOKEYDIRECTORY,
88 * and a lot of legal stuff denying liability for anything.
99 */
1010
11 #include <stdint.h>
1112 #include <stdio.h>
1213 #include <stdlib.h>
1314 #include <string.h>
3839 int getopt();
3940
4041 static int outtiled = -1;
41 static uint32 tilewidth;
42 static uint32 tilelength;
42 static uint32_t tilewidth;
43 static uint32_t tilelength;
4344 static int convert_8_to_4 = 0;
4445
45 static uint16 config;
46 static uint16 compression;
47 static uint16 predictor;
48 static uint16 fillorder;
49 static uint32 rowsperstrip;
50 static uint32 g3opts;
46 static uint16_t config;
47 static uint16_t compression;
48 static uint16_t predictor;
49 static uint16_t fillorder;
50 static uint32_t rowsperstrip;
51 static uint32_t g3opts;
5152 static int ignore = FALSE; /* if true, ignore read errors */
52 static uint32 defg3opts = (uint32) -1;
53 static uint32_t defg3opts = (uint32_t) -1;
5354 static int quality = 75; /* JPEG quality */
5455 static int jpegcolormode = JPEGCOLORMODE_RGB;
55 static uint16 defcompression = (uint16) -1;
56 static uint16 defpredictor = (uint16) -1;
56 static uint16_t defcompression = (uint16_t) -1;
57 static uint16_t defpredictor = (uint16_t) -1;
5758 static char *geofile=(char *)0;
5859 static char *proj4_string = (char *) 0;
5960 static char *worldfile=(char *)0;
9697 int
9798 main(int argc, char* argv[])
9899 {
99 uint16 defconfig = (uint16) -1;
100 uint16 deffillorder = 0;
101 uint32 deftilewidth = (uint32) -1;
102 uint32 deftilelength = (uint32) -1;
103 uint32 defrowsperstrip = (uint32) -1;
104 uint32 diroff = 0;
100 uint16_t defconfig = (uint16_t) -1;
101 uint16_t deffillorder = 0;
102 uint32_t deftilewidth = (uint32_t) -1;
103 uint32_t deftilelength = (uint32_t) -1;
104 uint32_t defrowsperstrip = (uint32_t) -1;
105 uint32_t diroff = 0;
105106 TIFF* in;
106107 TIFF* out;
107108 char mode[10];
344345 {
345346 GTIF *gtif; /* GeoKey-level descriptor */
346347 double *d_list = NULL;
347 int16 d_list_count;
348 int16_t d_list_count;
348349
349350 /* read definition from source file. */
350351 gtif = GTIFNew(in);
375376 processG3Options(char* cp)
376377 {
377378 if( (cp = strchr(cp, ':')) != NULL ) {
378 if (defg3opts == (uint32) -1)
379 if (defg3opts == (uint32_t) -1)
379380 defg3opts = 0;
380381 do {
381382 cp++;
487488 }
488489
489490 static void
490 CheckAndCorrectColormap(TIFF* tif, int n, uint16* r, uint16* g, uint16* b)
491 CheckAndCorrectColormap(TIFF* tif, int n, uint16_t* r, uint16_t* g, uint16_t* b)
491492 {
492493 int i;
493494
514515 if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) TIFFSetField(out, tag, v1, v2, v3, v4)
515516
516517 static struct cpTag {
517 uint16 tag;
518 uint16 count;
518 uint16_t tag;
519 uint16_t count;
519520 TIFFDataType type;
520521 } tags[] = {
521522 { TIFFTAG_SUBFILETYPE, 1, TIFF_LONG },
539540 { TIFFTAG_DATETIME, 1, TIFF_ASCII },
540541 { TIFFTAG_ARTIST, 1, TIFF_ASCII },
541542 { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII },
542 { TIFFTAG_WHITEPOINT, (uint16) -1,TIFF_RATIONAL },
543 { TIFFTAG_PRIMARYCHROMATICITIES,(uint16) -1,TIFF_RATIONAL },
543 { TIFFTAG_WHITEPOINT, (uint16_t) -1,TIFF_RATIONAL },
544 { TIFFTAG_PRIMARYCHROMATICITIES,(uint16_t) -1,TIFF_RATIONAL },
544545 { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT },
545546 { TIFFTAG_BADFAXLINES, 1, TIFF_LONG },
546547 { TIFFTAG_CLEANFAXDATA, 1, TIFF_SHORT },
550551 { TIFFTAG_DOTRANGE, 2, TIFF_SHORT },
551552 { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII },
552553 { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT },
553 { TIFFTAG_YCBCRCOEFFICIENTS, (uint16) -1,TIFF_RATIONAL },
554 { TIFFTAG_YCBCRCOEFFICIENTS, (uint16_t) -1,TIFF_RATIONAL },
554555 { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT },
555556 { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT },
556 { TIFFTAG_REFERENCEBLACKWHITE, (uint16) -1,TIFF_RATIONAL },
557 { TIFFTAG_EXTRASAMPLES, (uint16) -1, TIFF_SHORT },
557 { TIFFTAG_REFERENCEBLACKWHITE, (uint16_t) -1,TIFF_RATIONAL },
558 { TIFFTAG_EXTRASAMPLES, (uint16_t) -1, TIFF_SHORT },
558559 { TIFFTAG_SMINSAMPLEVALUE, 1, TIFF_DOUBLE },
559560 { TIFFTAG_SMAXSAMPLEVALUE, 1, TIFF_DOUBLE },
560561 };
569570 switch (p->type) {
570571 case TIFF_SHORT:
571572 if (p->count == 1) {
572 uint16 shortv;
573 uint16_t shortv;
573574 CopyField(p->tag, shortv);
574575 } else if (p->count == 2) {
575 uint16 shortv1, shortv2;
576 uint16_t shortv1, shortv2;
576577 CopyField2(p->tag, shortv1, shortv2);
577 } else if (p->count == (uint16) -1) {
578 uint16 shortv1;
579 uint16* shortav;
578 } else if (p->count == (uint16_t) -1) {
579 uint16_t shortv1;
580 uint16_t* shortav;
580581 CopyField2(p->tag, shortv1, shortav);
581582 }
582583 break;
583584 case TIFF_LONG:
584 { uint32 longv;
585 { uint32_t longv;
585586 CopyField(p->tag, longv);
586587 }
587588 break;
589590 if (p->count == 1) {
590591 float floatv;
591592 CopyField(p->tag, floatv);
592 } else if (p->count == (uint16) -1) {
593 } else if (p->count == (uint16_t) -1) {
593594 float* floatav;
594595 CopyField(p->tag, floatav);
595596 }
603604 if (p->count == 1) {
604605 double doublev;
605606 CopyField(p->tag, doublev);
606 } else if (p->count == (uint16) -1) {
607 } else if (p->count == (uint16_t) -1) {
607608 double* doubleav;
608609 CopyField(p->tag, doubleav);
609610 }
614615 }
615616
616617 typedef int (*copyFunc)
617 (TIFF* in, TIFF* out, uint32 l, uint32 w, uint16 samplesperpixel);
618 static copyFunc pickCopyFunc(TIFF*, TIFF*, uint16, uint16);
618 (TIFF* in, TIFF* out, uint32_t l, uint32_t w, uint16_t samplesperpixel);
619 static copyFunc pickCopyFunc(TIFF*, TIFF*, uint16_t, uint16_t);
619620
620621 static int
621622 tiffcp(TIFF* in, TIFF* out)
622623 {
623 uint16 bitspersample = 0, samplesperpixel, shortv;
624 uint16_t bitspersample = 0, samplesperpixel, shortv;
624625 copyFunc cf;
625 uint32 w, l;
626 uint32_t w, l;
626627
627628 CopyField(TIFFTAG_IMAGEWIDTH, w);
628629 CopyField(TIFFTAG_IMAGELENGTH, l);
634635 {
635636 CopyField(TIFFTAG_BITSPERSAMPLE, bitspersample);
636637 }
637 if (compression != (uint16)-1)
638 if (compression != (uint16_t)-1)
638639 TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
639640 else
640641 CopyField(TIFFTAG_COMPRESSION, compression);
661662 * input image or, if nothing is defined, use the
662663 * library default.
663664 */
664 if (tilewidth == (uint32) -1)
665 if (tilewidth == (uint32_t) -1)
665666 TIFFGetField(in, TIFFTAG_TILEWIDTH, &tilewidth);
666 if (tilelength == (uint32) -1)
667 if (tilelength == (uint32_t) -1)
667668 TIFFGetField(in, TIFFTAG_TILELENGTH, &tilelength);
668669 TIFFDefaultTileSize(out, &tilewidth, &tilelength);
669670 TIFFSetField(out, TIFFTAG_TILEWIDTH, tilewidth);
674675 * value from the input image or, if nothing is defined,
675676 * use the library default.
676677 */
677 if (rowsperstrip == (uint32) -1)
678 if (rowsperstrip == (uint32_t) -1)
678679 TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
679680 rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip);
680681 TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
681682 }
682 if (config != (uint16) -1)
683 if (config != (uint16_t) -1)
683684 TIFFSetField(out, TIFFTAG_PLANARCONFIG, config);
684685 else
685686 CopyField(TIFFTAG_PLANARCONFIG, config);
686 if (g3opts != (uint32) -1)
687 if (g3opts != (uint32_t) -1)
687688 TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, g3opts);
688689 else
689690 CopyField(TIFFTAG_GROUP3OPTIONS, g3opts);
690691 if (samplesperpixel <= 4) {
691 uint16 *tr, *tg, *tb, *ta;
692 uint16_t *tr, *tg, *tb, *ta;
692693 CopyField4(TIFFTAG_TRANSFERFUNCTION, tr, tg, tb, ta);
693694 }
694 { uint16 *red, *green, *blue;
695 { uint16_t *red, *green, *blue;
695696 if (TIFFGetField(in, TIFFTAG_COLORMAP, &red, &green, &blue)) {
696697 CheckAndCorrectColormap(in, 1<<bitspersample, red, green, blue);
697698 TIFFSetField(out, TIFFTAG_COLORMAP, red, green, blue);
705706 break;
706707 case COMPRESSION_LZW:
707708 case COMPRESSION_DEFLATE:
708 if (predictor != (uint16)-1)
709 if (predictor != (uint16_t)-1)
709710 TIFFSetField(out, TIFFTAG_PREDICTOR, predictor);
710711 else
711712 CopyField(TIFFTAG_PREDICTOR, predictor);
730731 */
731732 #define DECLAREcpFunc(x) \
732733 static int x(TIFF* in, TIFF* out, \
733 uint32 imagelength, uint32 imagewidth, tsample_t spp)
734 uint32_t imagelength, uint32_t imagewidth, tsample_t spp)
734735
735736 #define DECLAREreadFunc(x) \
736737 static void x(TIFF* in, \
737 unsigned char* buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)
738 typedef void (*readFunc)(TIFF*, unsigned char*, uint32, uint32, tsample_t);
738 unsigned char* buf, uint32_t imagelength, uint32_t imagewidth, tsample_t spp)
739 typedef void (*readFunc)(TIFF*, unsigned char*, uint32_t, uint32_t, tsample_t);
739740
740741 #define DECLAREwriteFunc(x) \
741742 static int x(TIFF* out, \
742 unsigned char* buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)
743 typedef int (*writeFunc)(TIFF*, unsigned char*, uint32, uint32, tsample_t);
743 unsigned char* buf, uint32_t imagelength, uint32_t imagewidth, tsample_t spp)
744 typedef int (*writeFunc)(TIFF*, unsigned char*, uint32_t, uint32_t, tsample_t);
744745
745746 /*
746747 * Contig -> contig by scanline for rows/strip change.
748749 DECLAREcpFunc(cpContig2ContigByRow)
749750 {
750751 unsigned char *buf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in));
751 uint32 row;
752 uint32_t row;
752753
753754 (void) imagewidth; (void) spp;
754755 for (row = 0; row < imagelength; row++) {
772773 {
773774 unsigned char *buf_in = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in));
774775 unsigned char *buf_out = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out));
775 uint32 row;
776 uint32_t row;
776777
777778 printf( "Downsample\n" );
778779
815816 (void) imagewidth; (void) spp;
816817 if (buf) {
817818 tstrip_t s, ns = TIFFNumberOfStrips(in);
818 uint32 row = 0;
819 uint32_t row = 0;
819820 for (s = 0; s < ns; s++) {
820821 tsize_t cc = (row + rowsperstrip > imagelength) ?
821822 TIFFVStripSize(in, imagelength - row) : stripsize;
839840 DECLAREcpFunc(cpSeparate2SeparateByRow)
840841 {
841842 unsigned char *buf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in));
842 uint32 row;
843 uint32_t row;
843844 tsample_t s;
844845
845846 (void) imagewidth;
867868 unsigned char *inbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in));
868869 unsigned char *outbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out));
869870 register unsigned char *inp, *outp;
870 register uint32 n;
871 uint32 row;
871 register uint32_t n;
872 uint32_t row;
872873 tsample_t s;
873874
874875 /* unpack channels */
904905 unsigned char *inbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in));
905906 unsigned char *outbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out));
906907 register unsigned char *inp, *outp;
907 register uint32 n;
908 uint32 row;
908 register uint32_t n;
909 uint32_t row;
909910 tsample_t s;
910911
911912 for (row = 0; row < imagelength; row++) {
935936
936937 static void
937938 cpStripToTile(unsigned char* out, unsigned char* in,
938 uint32 rows, uint32 cols, int outskew, int inskew)
939 uint32_t rows, uint32_t cols, int outskew, int inskew)
939940 {
940941 while (rows-- > 0) {
941 uint32 j = cols;
942 uint32_t j = cols;
942943 while (j-- > 0)
943944 *out++ = *in++;
944945 out += outskew;
948949
949950 static void
950951 cpContigBufToSeparateBuf(unsigned char* out, unsigned char* in,
951 uint32 rows, uint32 cols, int outskew, int inskew, tsample_t spp)
952 uint32_t rows, uint32_t cols, int outskew, int inskew, tsample_t spp)
952953 {
953954 while (rows-- > 0) {
954 uint32 j = cols;
955 uint32_t j = cols;
955956 while (j-- > 0)
956957 *out++ = *in, in += spp;
957958 out += outskew;
961962
962963 static void
963964 cpSeparateBufToContigBuf(unsigned char* out, unsigned char* in,
964 uint32 rows, uint32 cols, int outskew, int inskew, tsample_t spp)
965 uint32_t rows, uint32_t cols, int outskew, int inskew, tsample_t spp)
965966 {
966967 while (rows-- > 0) {
967 uint32 j = cols;
968 uint32_t j = cols;
968969 while (j-- > 0)
969970 *out = *in++, out += spp;
970971 out += outskew;
974975
975976 static int
976977 cpImage(TIFF* in, TIFF* out, readFunc fin, writeFunc fout,
977 uint32 imagelength, uint32 imagewidth, tsample_t spp)
978 uint32_t imagelength, uint32_t imagewidth, tsample_t spp)
978979 {
979980 int status = FALSE;
980981 unsigned char* buf = (unsigned char *)
991992 {
992993 tsize_t scanlinesize = TIFFScanlineSize(in);
993994 unsigned char *bufp = buf;
994 uint32 row;
995 uint32_t row;
995996
996997 (void) imagewidth; (void) spp;
997998 for (row = 0; row < imagelength; row++) {
10091010 (void) imagewidth;
10101011 if (scanline) {
10111012 unsigned char *bufp = buf;
1012 uint32 row;
1013 uint32_t row;
10131014 tsample_t s;
10141015
10151016 for (row = 0; row < imagelength; row++) {
10341035 DECLAREreadFunc(readContigTilesIntoBuffer)
10351036 {
10361037 unsigned char* tilebuf = (unsigned char *) _TIFFmalloc(TIFFTileSize(in));
1037 uint32 imagew = TIFFScanlineSize(in);
1038 uint32 tilew = TIFFTileRowSize(in);
1038 uint32_t imagew = TIFFScanlineSize(in);
1039 uint32_t tilew = TIFFTileRowSize(in);
10391040 int iskew = imagew - tilew;
10401041 unsigned char *bufp = buf;
1041 uint32 tw, tl;
1042 uint32 row;
1042 uint32_t tw, tl;
1043 uint32_t row;
10431044
10441045 (void) spp;
10451046 if (tilebuf == 0)
10471048 (void) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw);
10481049 (void) TIFFGetField(in, TIFFTAG_TILELENGTH, &tl);
10491050 for (row = 0; row < imagelength; row += tl) {
1050 uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl;
1051 uint32 colb = 0;
1052 uint32 col;
1051 uint32_t nrow = (row+tl > imagelength) ? imagelength-row : tl;
1052 uint32_t colb = 0;
1053 uint32_t col;
10531054
10541055 for (col = 0; col < imagewidth; col += tw) {
10551056 if (TIFFReadTile(in, tilebuf, col, row, 0, 0) < 0 &&
10561057 !ignore)
10571058 goto done;
10581059 if (colb + tilew > imagew) {
1059 uint32 width = imagew - colb;
1060 uint32 oskew = tilew - width;
1060 uint32_t width = imagew - colb;
1061 uint32_t oskew = tilew - width;
10611062 cpStripToTile(bufp + colb,
10621063 tilebuf, nrow, width,
10631064 oskew + iskew, oskew);
10751076
10761077 DECLAREreadFunc(readSeparateTilesIntoBuffer)
10771078 {
1078 uint32 imagew = TIFFScanlineSize(in);
1079 uint32 tilew = TIFFTileRowSize(in);
1079 uint32_t imagew = TIFFScanlineSize(in);
1080 uint32_t tilew = TIFFTileRowSize(in);
10801081 int iskew = imagew - tilew;
10811082 unsigned char* tilebuf = (unsigned char *) _TIFFmalloc(TIFFTileSize(in));
10821083 unsigned char *bufp = buf;
1083 uint32 tw, tl;
1084 uint32 row;
1084 uint32_t tw, tl;
1085 uint32_t row;
10851086
10861087 if (tilebuf == 0)
10871088 return;
10881089 (void) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw);
10891090 (void) TIFFGetField(in, TIFFTAG_TILELENGTH, &tl);
10901091 for (row = 0; row < imagelength; row += tl) {
1091 uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl;
1092 uint32 colb = 0;
1093 uint32 col;
1092 uint32_t nrow = (row+tl > imagelength) ? imagelength-row : tl;
1093 uint32_t colb = 0;
1094 uint32_t col;
10941095
10951096 for (col = 0; col < imagewidth; col += tw) {
10961097 tsample_t s;
11031104 * visible portion and skewing factors.
11041105 */
11051106 if (colb + tilew > imagew) {
1106 uint32 width = imagew - colb;
1107 uint32_t width = imagew - colb;
11071108 int oskew = tilew - width;
11081109 cpSeparateBufToContigBuf(bufp+colb+s,
11091110 tilebuf, nrow, width,
11241125 DECLAREwriteFunc(writeBufferToContigStrips)
11251126 {
11261127 tsize_t scanline = TIFFScanlineSize(out);
1127 uint32 row;
1128 uint32_t row;
11281129
11291130 (void) imagewidth; (void) spp;
11301131 for (row = 0; row < imagelength; row++) {
11431144 if (obuf == NULL)
11441145 return (0);
11451146 for (s = 0; s < spp; s++) {
1146 uint32 row;
1147 uint32_t row;
11471148 for (row = 0; row < imagelength; row++) {
11481149 unsigned char* inp = buf + s;
11491150 unsigned char* outp = obuf;
1150 uint32 n = imagewidth;
1151 uint32_t n = imagewidth;
11511152
11521153 while (n-- > 0)
11531154 *outp++ = *inp, inp += spp;
11641165
11651166 DECLAREwriteFunc(writeBufferToContigTiles)
11661167 {
1167 uint32 imagew = TIFFScanlineSize(out);
1168 uint32 tilew = TIFFTileRowSize(out);
1168 uint32_t imagew = TIFFScanlineSize(out);
1169 uint32_t tilew = TIFFTileRowSize(out);
11691170 int iskew = imagew - tilew;
11701171 unsigned char* obuf = (unsigned char *) _TIFFmalloc(TIFFTileSize(out));
11711172 unsigned char* bufp = buf;
1172 uint32 tl, tw;
1173 uint32 row;
1173 uint32_t tl, tw;
1174 uint32_t row;
11741175
11751176 (void) spp;
11761177 if (obuf == NULL)
11781179 (void) TIFFGetField(out, TIFFTAG_TILELENGTH, &tl);
11791180 (void) TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw);
11801181 for (row = 0; row < imagelength; row += tilelength) {
1181 uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl;
1182 uint32 colb = 0;
1183 uint32 col;
1182 uint32_t nrow = (row+tl > imagelength) ? imagelength-row : tl;
1183 uint32_t colb = 0;
1184 uint32_t col;
11841185
11851186 for (col = 0; col < imagewidth; col += tw) {
11861187 /*
11881189 * visible portion and skewing factors.
11891190 */
11901191 if (colb + tilew > imagew) {
1191 uint32 width = imagew - colb;
1192 uint32_t width = imagew - colb;
11921193 int oskew = tilew - width;
11931194 cpStripToTile(obuf, bufp + colb, nrow, width,
11941195 oskew, oskew + iskew);
12091210
12101211 DECLAREwriteFunc(writeBufferToSeparateTiles)
12111212 {
1212 uint32 imagew = TIFFScanlineSize(out);
1213 uint32_t imagew = TIFFScanlineSize(out);
12131214 tsize_t tilew = TIFFTileRowSize(out);
12141215 int iskew = imagew - tilew;
12151216 unsigned char *obuf = (unsigned char*) _TIFFmalloc(TIFFTileSize(out));
12161217 unsigned char *bufp = buf;
1217 uint32 tl, tw;
1218 uint32 row;
1218 uint32_t tl, tw;
1219 uint32_t row;
12191220
12201221 if (obuf == NULL)
12211222 return (FALSE);
12221223 (void) TIFFGetField(out, TIFFTAG_TILELENGTH, &tl);
12231224 (void) TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw);
12241225 for (row = 0; row < imagelength; row += tl) {
1225 uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl;
1226 uint32 colb = 0;
1227 uint32 col;
1226 uint32_t nrow = (row+tl > imagelength) ? imagelength-row : tl;
1227 uint32_t colb = 0;
1228 uint32_t col;
12281229
12291230 for (col = 0; col < imagewidth; col += tw) {
12301231 tsample_t s;
12341235 * visible portion and skewing factors.
12351236 */
12361237 if (colb + tilew > imagew) {
1237 uint32 width = imagew - colb;
1238 uint32_t width = imagew - colb;
12381239 int oskew = tilew - width;
12391240
12401241 cpContigBufToSeparateBuf(obuf,
13951396 * Select the appropriate copy function to use.
13961397 */
13971398 static copyFunc
1398 pickCopyFunc(TIFF* in, TIFF* out, uint16 bitspersample, uint16 samplesperpixel)
1399 {
1400 uint16 shortv;
1401 uint32 w, l, tw, tl;
1399 pickCopyFunc(TIFF* in, TIFF* out, uint16_t bitspersample, uint16_t samplesperpixel)
1400 {
1401 uint16_t shortv;
1402 uint32_t w, l, tw, tl;
14021403 int bychunk;
14031404
14041405 (void) TIFFGetField(in, TIFFTAG_PLANARCONFIG, &shortv);
14211422 TIFFGetField(in, TIFFTAG_TILELENGTH, &tl);
14221423 bychunk = (tw == w && tl == rowsperstrip);
14231424 } else {
1424 uint32 irps = (uint32) -1L;
1425 uint32_t irps = (uint32_t) -1L;
14251426 TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &irps);
14261427 bychunk = (rowsperstrip == irps);
14271428 }
00 #ifndef GEO_CONFIG_H
11 #define GEO_CONFIG_H
22
3 /* Define if you have the <stdlib.h> header file. */
4 #cmakedefine HAVE_STDLIB_H
5
6 /* Define if you have the <string.h> header file. */
7 #cmakedefine HAVE_STRING_H
8
93 /* Define if you have the <strings.h> header file. */
10 #cmakedefine HAVE_STRINGS_H
4 #cmakedefine GEOTIFF_HAVE_STRINGS_H 1
115
126 #cmakedefine GEO_NORMALIZE_DISABLE_TOWGS84
137
00 #! /bin/sh
11 # Guess values for system-dependent variables and create Makefiles.
2 # Generated by GNU Autoconf 2.69 for libgeotiff 1.7.0.
2 # Generated by GNU Autoconf 2.69 for libgeotiff 1.7.1.
33 #
44 # Report bugs to <warmerdam@pobox.com>.
55 #
589589 # Identity of this package.
590590 PACKAGE_NAME='libgeotiff'
591591 PACKAGE_TARNAME='libgeotiff'
592 PACKAGE_VERSION='1.7.0'
593 PACKAGE_STRING='libgeotiff 1.7.0'
592 PACKAGE_VERSION='1.7.1'
593 PACKAGE_STRING='libgeotiff 1.7.1'
594594 PACKAGE_BUGREPORT='warmerdam@pobox.com'
595595 PACKAGE_URL=''
596596
14211421 # Omit some internal or obsolete options to make the list less imposing.
14221422 # This message is too long to be a string in the A/UX 3.1 sh.
14231423 cat <<_ACEOF
1424 \`configure' configures libgeotiff 1.7.0 to adapt to many kinds of systems.
1424 \`configure' configures libgeotiff 1.7.1 to adapt to many kinds of systems.
14251425
14261426 Usage: $0 [OPTION]... [VAR=VALUE]...
14271427
14921492
14931493 if test -n "$ac_init_help"; then
14941494 case $ac_init_help in
1495 short | recursive ) echo "Configuration of libgeotiff 1.7.0:";;
1495 short | recursive ) echo "Configuration of libgeotiff 1.7.1:";;
14961496 esac
14971497 cat <<\_ACEOF
14981498
16381638 test -n "$ac_init_help" && exit $ac_status
16391639 if $ac_init_version; then
16401640 cat <<\_ACEOF
1641 libgeotiff configure 1.7.0
1641 libgeotiff configure 1.7.1
16421642 generated by GNU Autoconf 2.69
16431643
16441644 Copyright (C) 2012 Free Software Foundation, Inc.
20072007 This file contains any messages produced by compilers while
20082008 running configure, to aid debugging if configure makes a mistake.
20092009
2010 It was created by libgeotiff $as_me 1.7.0, which was
2010 It was created by libgeotiff $as_me 1.7.1, which was
20112011 generated by GNU Autoconf 2.69. Invocation command line was
20122012
20132013 $ $0 $@
24252425
24262426
24272427
2428 RELEASE_VERSION=1.7.0
2428 RELEASE_VERSION=1.7.1
24292429
24302430 ac_config_headers="$ac_config_headers geo_config.h"
24312431
29172917
29182918 # Define the identity of the package.
29192919 PACKAGE='libgeotiff'
2920 VERSION='1.7.0'
2920 VERSION='1.7.1'
29212921
29222922
29232923 cat >>confdefs.h <<_ACEOF
1216312163 LIBS="$LDFLAGS $LIBS"
1216412164
1216512165
12166 for ac_header in string.h
12166 for ac_header in strings.h
1216712167 do :
12168 ac_fn_c_check_header_mongrel "$LINENO" "string.h" "ac_cv_header_string_h" "$ac_includes_default"
12169 if test "x$ac_cv_header_string_h" = xyes; then :
12168 ac_fn_c_check_header_mongrel "$LINENO" "strings.h" "ac_cv_header_strings_h" "$ac_includes_default"
12169 if test "x$ac_cv_header_strings_h" = xyes; then :
1217012170 cat >>confdefs.h <<_ACEOF
12171 #define HAVE_STRING_H 1
12171 #define HAVE_STRINGS_H 1
1217212172 _ACEOF
12173 HAVE_STRING_H=1
12174 else
12175 as_fn_error $? "cannot find string.h, bailing out" "$LINENO" 5
12173 GEOTIFF_HAVE_STRINGS_H=1
1217612174 fi
1217712175
1217812176 done
12177
12178
12179 cat >>confdefs.h <<_ACEOF
12180 #define GEOTIFF_HAVE_STRINGS_H 1
12181 _ACEOF
12182
1217912183
1218012184 for ac_header in stdio.h
1218112185 do :
1617916183 # report actual input values of CONFIG_FILES etc. instead of their
1618016184 # values after options handling.
1618116185 ac_log="
16182 This file was extended by libgeotiff $as_me 1.7.0, which was
16186 This file was extended by libgeotiff $as_me 1.7.1, which was
1618316187 generated by GNU Autoconf 2.69. Invocation command line was
1618416188
1618516189 CONFIG_FILES = $CONFIG_FILES
1624516249 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
1624616250 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
1624716251 ac_cs_version="\\
16248 libgeotiff config.status 1.7.0
16252 libgeotiff config.status 1.7.1
1624916253 configured by $0, generated by GNU Autoconf 2.69,
1625016254 with options \\"\$ac_cs_config\\"
1625116255
11
22 m4_define([VERSION_MAJOR], [1])
33 m4_define([VERSION_MINOR], [7])
4 m4_define([VERSION_POINT], [0])
4 m4_define([VERSION_POINT], [1])
55 m4_define([GEOTIFF_VERSION],
66 [VERSION_MAJOR.VERSION_MINOR.VERSION_POINT])
77
4444 dnl Checks for header files.
4545 dnl #########################################################################
4646
47 AC_CHECK_HEADERS([string.h],[HAVE_STRING_H=1], [AC_MSG_ERROR([cannot find string.h, bailing out])])
47 dnl AC_CHECK_HEADERS([string.h],[HAVE_STRING_H=1], [AC_MSG_ERROR([cannot find string.h, bailing out])])
48 AC_CHECK_HEADERS([strings.h],[GEOTIFF_HAVE_STRINGS_H=1])
49 AC_DEFINE_UNQUOTED(GEOTIFF_HAVE_STRINGS_H, 1,
50 [Define if you have the <strings.h> header file.])
51
4852 AC_CHECK_HEADERS([stdio.h],, [AC_MSG_ERROR([cannot find stdio.h, bailing out])])
4953 AC_CHECK_HEADERS([stdlib.h],, [AC_MSG_ERROR([cannot find stdlib.h, bailing out])])
5054
3737
3838 #include <math.h>
3939
40 #ifdef HAVE_STRING_H
41 # include <string.h>
42 #endif
43 #if defined(HAVE_STRINGS_H) && !defined(_WIN32)
40 #include <string.h>
41 #if defined(GEOTIFF_HAVE_STRINGS_H) && !defined(_WIN32)
4442 # include <strings.h>
4543 #endif
46 #ifdef HAVE_STDLIB_H
47 # include <stdlib.h>
48 #endif
44 #include <stdlib.h>
4945
5046 /**********************************************************************
5147 * Do we want to build as a DLL on windows?
00 #ifndef GEO_CONFIG_H
11 #define GEO_CONFIG_H
22
3 /* Define if you have the ANSI C header files. */
4 #undef STDC_HEADERS
5
6 /* Define if you have the <stdlib.h> header file. */
7 #undef HAVE_STDLIB_H
8
9 /* Define if you have the <string.h> header file. */
10 #undef HAVE_STRING_H
11
123 /* Define if you have the <strings.h> header file. */
13 #undef HAVE_STRINGS_H
14
15 #undef HAVE_LIBPROJ
16 #undef HAVE_PROJECTS_H
4 #undef GEOTIFF_HAVE_STRINGS_H
175
186 #undef GEO_NORMALIZE_DISABLE_TOWGS84
197
3232
3333 va_start(list, msg);
3434 if( level == LIBGEOTIFF_WARNING )
35 fprintf(stderr, "Warning :");
35 fprintf(stderr, "Warning: ");
3636 else if( level == LIBGEOTIFF_ERROR )
37 fprintf(stderr, "Error :");
37 fprintf(stderr, "Error: ");
3838 vfprintf(stderr, msg, list);
3939 fprintf(stderr, "\n");
4040 va_end(list);
266266 {
267267 case GTIFF_LOCAL:
268268 /* store value into data value */
269 if (count != 1 )
270 {
271 if( gt->gt_error_callback )
272 {
273 gt->gt_error_callback(
274 gt,
275 LIBGEOTIFF_ERROR,
276 "Key %s of TIFFTagLocation=0 has count=%d, "
277 "whereas only 1 is legal.",
278 GTIFKeyName(keyptr->gk_key), count);
279 }
280 return 0;
281 }
269282 memcpy(&keyptr->gk_data, &(entptr->ent_val_offset), sizeof(pinfo_t));
270283 break;
271284 case GTIFF_GEOKEYDIRECTORY:
272285 keyptr->gk_data = (char *)(gt->gt_short+offset);
273286 if (gt->gt_nshorts < offset+count)
287 {
288 if( gt->gt_error_callback )
289 {
290 gt->gt_error_callback(
291 gt,
292 LIBGEOTIFF_ERROR,
293 "Key %s of type SHORT has offset=%d and count=%d, "
294 "but the GeoKeyDirectory tag has only %d values.",
295 GTIFKeyName(keyptr->gk_key),
296 offset, count, gt->gt_nshorts);
297 }
274298 return 0;
299 }
275300 break;
276301 case GTIFF_DOUBLEPARAMS:
277302 keyptr->gk_data = (char *)(gt->gt_double+offset);
278303 if (gt->gt_ndoubles < offset+count)
304 {
305 if( gt->gt_error_callback )
306 {
307 gt->gt_error_callback(
308 gt,
309 LIBGEOTIFF_ERROR,
310 "Key %s of type SHORT has offset=%d and count=%d, "
311 "but the GeoDoubleParams tag has only %d values.",
312 GTIFKeyName(keyptr->gk_key),
313 offset, count, gt->gt_ndoubles);
314 }
279315 return 0;
316 }
280317 break;
281318 case GTIFF_ASCIIPARAMS:
282319 if( tempData->tk_asciiParams == NULL )
320 {
321 if( gt->gt_error_callback )
322 {
323 gt->gt_error_callback(
324 gt,
325 LIBGEOTIFF_ERROR,
326 "Key %s is of type ASCII but GeoAsciiParams is "
327 "missing or corrupted.",
328 GTIFKeyName(keyptr->gk_key));
329 }
283330 return 0;
331 }
284332 if( offset + count == tempData->tk_asciiParamsLength + 1
285333 && count > 0 )
286334 {
293341 else if (offset < tempData->tk_asciiParamsLength
294342 && offset + count > tempData->tk_asciiParamsLength )
295343 {
344 if( gt->gt_error_callback )
345 {
346 gt->gt_error_callback(
347 gt,
348 LIBGEOTIFF_WARNING,
349 "Key %s of type ASCII has offset=%d and count=%d, but "
350 "the GeoAsciiParams tag has only %d bytes. "
351 "Truncating the value of the key.",
352 GTIFKeyName(keyptr->gk_key), offset, count,
353 tempData->tk_asciiParamsLength);
354 }
296355 count = tempData->tk_asciiParamsLength - offset;
297 /* issue warning... if we could */
298356 }
299357 else if (offset + count > tempData->tk_asciiParamsLength)
358 {
359 if( gt->gt_error_callback )
360 {
361 gt->gt_error_callback(
362 gt,
363 LIBGEOTIFF_ERROR,
364 "Key %s of type ASCII has offset=%d and count=%d, "
365 "but the GeoAsciiParams tag has only %d values.",
366 GTIFKeyName(keyptr->gk_key), offset, count,
367 tempData->tk_asciiParamsLength);
368 }
300369 return 0;
370 }
301371
302372 keyptr->gk_count = MAX(1,count+1);
303373 keyptr->gk_data = (char *) _GTIFcalloc (keyptr->gk_count);
313383 keyptr->gk_data[MAX(0,count)] = '\0';
314384 break;
315385 default:
386 if( gt->gt_error_callback )
387 {
388 gt->gt_error_callback(
389 gt,
390 LIBGEOTIFF_ERROR,
391 "Key %d of unknown type.",
392 keyptr->gk_key);
393 }
316394 return 0; /* failure */
317395 }
318396 keyptr->gk_size = _gtiff_size[keyptr->gk_type];
29892989 void GTIFPrintDefn( GTIFDefn * psDefn, FILE * fp )
29902990 {
29912991 GTIF *psGTIF = GTIFNew(NULL);
2992 GTIFPrintDefnEx(psGTIF, psDefn, fp);
2993 GTIFFree(psGTIF);
2992 if( psGTIF )
2993 {
2994 GTIFPrintDefnEx(psGTIF, psDefn, fp);
2995 GTIFFree(psGTIF);
2996 }
29942997 }
29952998
29962999 /************************************************************************/
4646 #define GEOTIFF_SPEC_1_1_MINOR_REVISION 1
4747
4848 /* Library version */
49 #define LIBGEOTIFF_VERSION 1700
49 #define LIBGEOTIFF_VERSION 1710
5050
5151 #include "geo_config.h"
5252 #include "geokeys.h"
130130 void GTIF_DLL GTIFFree(GTIF *gtif);
131131 int GTIF_DLL GTIFWriteKeys(GTIF *gtif);
132132 /* versions must be an array of 3 int */
133 void GTIF_DLL GTIFDirectoryInfo(GTIF *gtif, int *versions, int *keycount);
133 void GTIF_DLL GTIFDirectoryInfo(GTIF *gtif, int versions[3], int *keycount);
134134 void GTIF_DLL *GTIFGetUserData(GTIF *gtif);
135135 int GTIF_DLL GTIFSetVersionNumbers(GTIF* gtif,
136136 unsigned short version,