"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "bin/geotifcp.c" between
libgeotiff-1.5.1.tar.gz and libgeotiff-1.6.0.tar.gz

About: libgeotiff is a library (built on top of libtiff) for reading and writing coordinate system information from and to GeoTIFF files (GeoTIFF establishes a TIFF based interchange format for georeferenced raster imagery).

geotifcp.c  (libgeotiff-1.5.1):geotifcp.c  (libgeotiff-1.6.0)
skipping to change at line 67 skipping to change at line 67
static uint16 defpredictor = (uint16) -1; static uint16 defpredictor = (uint16) -1;
static char *geofile=(char *)0; static char *geofile=(char *)0;
static char *proj4_string = (char *) 0; static char *proj4_string = (char *) 0;
static char *worldfile=(char *)0; static char *worldfile=(char *)0;
static void ApplyWorldFile(const char *worldfile, TIFF *out); static void ApplyWorldFile(const char *worldfile, TIFF *out);
static int tiffcp(TIFF*, TIFF*); static int tiffcp(TIFF*, TIFF*);
static int processCompressOptions(char*); static int processCompressOptions(char*);
static void usage(void); static void usage(void);
static int forced_version = 0;
static unsigned short version = 0;
static unsigned short key_version = 0;
static unsigned short minor_revision = 0;
static int parseVersion(const char* str)
{
if( strlen(str) != 5 || str[1] != ':' || str[3] != ':' )
return 0;
if( str[0] < '0' || str[0] > '9' )
return 0;
if( str[2] < '0' || str[2] > '9' )
return 0;
if( str[4] < '0' || str[4] > '9' )
return 0;
forced_version = 1;
version = str[0] - '0';
key_version = str[2] - '0';
minor_revision = str[4] - '0';
return 1;
}
static void SetVersionNumbers(GTIF* gtif)
{
if( forced_version )
{
GTIFSetVersionNumbers(gtif, version, key_version, minor_revision);
}
}
int int
main(int argc, char* argv[]) main(int argc, char* argv[])
{ {
uint16 defconfig = (uint16) -1; uint16 defconfig = (uint16) -1;
uint16 deffillorder = 0; uint16 deffillorder = 0;
uint32 deftilewidth = (uint32) -1; uint32 deftilewidth = (uint32) -1;
uint32 deftilelength = (uint32) -1; uint32 deftilelength = (uint32) -1;
uint32 defrowsperstrip = (uint32) -1; uint32 defrowsperstrip = (uint32) -1;
uint32 diroff = 0; uint32 diroff = 0;
TIFF* in; TIFF* in;
TIFF* out; TIFF* out;
char mode[10]; char mode[10];
char* mp = mode; char* mp = mode;
int c; int c;
extern int optind; extern int optind;
extern char* optarg; extern char* optarg;
*mp++ = 'w'; *mp++ = 'w';
*mp = '\0'; *mp = '\0';
while ((c = getopt(argc, argv, "c:f:l:o:p:r:w:e:g:4:aistd8BLMC")) != -1) while ((c = getopt(argc, argv, "c:f:l:o:p:r:w:e:g:4:v:aistd8BLMC")) != -1 )
switch (c) { switch (c) {
case 'a': /* append to output */ case 'a': /* append to output */
mode[0] = 'a'; mode[0] = 'a';
break; break;
case 'd': /* down cast 8bit to 4bit */ case 'd': /* down cast 8bit to 4bit */
convert_8_to_4 = 1; convert_8_to_4 = 1;
break; break;
case 'c': /* compression scheme */ case 'c': /* compression scheme */
if (!processCompressOptions(optarg)) if (!processCompressOptions(optarg))
usage(); usage();
skipping to change at line 161 skipping to change at line 191
break; break;
case 'M': case 'M':
*mp++ = 'm'; *mp = '\0'; *mp++ = 'm'; *mp = '\0';
break; break;
case 'C': case 'C':
*mp++ = 'c'; *mp = '\0'; *mp++ = 'c'; *mp = '\0';
break; break;
case '8': case '8':
*mp++ = '8'; *mp = '\0'; *mp++ = '8'; *mp = '\0';
break; break;
case 'v':
if (!parseVersion(optarg))
usage();
break;
case '?': case '?':
usage(); usage();
/*NOTREACHED*/ /*NOTREACHED*/
} }
if (argc - optind < 2) if (argc - optind < 2)
usage(); usage();
printf( "mode=%s\n", mode); printf( "mode=%s\n", mode);
out = TIFFOpen(argv[argc-1], mode); out = TIFFOpen(argv[argc-1], mode);
if (out == NULL) if (out == NULL)
return (-2); return (-2);
skipping to change at line 304 skipping to change at line 338
fclose(fd); fclose(fd);
} }
else if( proj4_string ) else if( proj4_string )
{ {
if( !GTIFSetFromProj4(gtif,proj4_string) ) if( !GTIFSetFromProj4(gtif,proj4_string) )
{ {
fprintf(stderr,"Failure in GTIFSetFromProj4\n"); fprintf(stderr,"Failure in GTIFSetFromProj4\n");
exit (-1); exit (-1);
} }
} }
SetVersionNumbers(gtif);
GTIFWriteKeys(gtif); GTIFWriteKeys(gtif);
GTIFFree(gtif); GTIFFree(gtif);
return; return;
} }
static void CopyGeoTIFF(TIFF * in, TIFF *out) static void CopyGeoTIFF(TIFF * in, TIFF *out)
{ {
GTIF *gtif; /* GeoKey-level descriptor */ GTIF *gtif; /* GeoKey-level descriptor */
double *d_list = NULL; double *d_list = NULL;
int16 d_list_count; int16 d_list_count;
skipping to change at line 334 skipping to change at line 369
if (TIFFGetField(in, GTIFF_TRANSMATRIX, &d_list_count, &d_list)) if (TIFFGetField(in, GTIFF_TRANSMATRIX, &d_list_count, &d_list))
TIFFSetField(out, GTIFF_TRANSMATRIX, d_list_count, d_list); TIFFSetField(out, GTIFF_TRANSMATRIX, d_list_count, d_list);
/* Here we violate the GTIF abstraction to retarget on another file. /* Here we violate the GTIF abstraction to retarget on another file.
We should just have a function for copying tags from one GTIF object We should just have a function for copying tags from one GTIF object
to another. */ to another. */
gtif->gt_tif = out; gtif->gt_tif = out;
gtif->gt_flags |= FLAG_FILE_MODIFIED; gtif->gt_flags |= FLAG_FILE_MODIFIED;
/* Install keys and tags */ /* Install keys and tags */
SetVersionNumbers(gtif);
GTIFWriteKeys(gtif); GTIFWriteKeys(gtif);
GTIFFree(gtif); GTIFFree(gtif);
return; return;
} }
static void static void
processG3Options(char* cp) processG3Options(char* cp)
{ {
if( (cp = strchr(cp, ':')) != NULL ) { if( (cp = strchr(cp, ':')) != NULL ) {
if (defg3opts == (uint32) -1) if (defg3opts == (uint32) -1)
skipping to change at line 399 skipping to change at line 435
return (0); return (0);
return (1); return (1);
} }
char* stuff[] = { char* stuff[] = {
"usage: gtiffcp [options] input... output", "usage: gtiffcp [options] input... output",
"where options are:", "where options are:",
" -g file install GeoTIFF metadata from <file>", " -g file install GeoTIFF metadata from <file>",
" -4 proj4_str install GeoTIFF metadata from proj4 string", " -4 proj4_str install GeoTIFF metadata from proj4 string",
" -e file install positioning info from ESRI Worldfile <file>", " -e file install positioning info from ESRI Worldfile <file>",
" -v v:k:m force the GeoTIFF version numbers (v=version, k=key_major, m=min or_rev)",
" -a append to output instead of overwriting", " -a append to output instead of overwriting",
" -8 write BigTIFF instead of default ClassicTIFF", " -8 write BigTIFF instead of default ClassicTIFF",
" -o offset set initial directory offset", " -o offset set initial directory offset",
" -p contig pack samples contiguously (e.g. RGBRGB...)", " -p contig pack samples contiguously (e.g. RGBRGB...)",
" -p separate store samples separately (e.g. RRR...GGG...BBB...)", " -p separate store samples separately (e.g. RRR...GGG...BBB...)",
" -s write output in strips", " -s write output in strips",
" -t write output in tiles", " -t write output in tiles",
" -i ignore read errors", " -i ignore read errors",
" -d truncate 8 bitspersample to 4bitspersample", " -d truncate 8 bitspersample to 4bitspersample",
"", "",
skipping to change at line 587 skipping to change at line 624
} }
} }
typedef int (*copyFunc) typedef int (*copyFunc)
(TIFF* in, TIFF* out, uint32 l, uint32 w, uint16 samplesperpixel); (TIFF* in, TIFF* out, uint32 l, uint32 w, uint16 samplesperpixel);
static copyFunc pickCopyFunc(TIFF*, TIFF*, uint16, uint16); static copyFunc pickCopyFunc(TIFF*, TIFF*, uint16, uint16);
static int static int
tiffcp(TIFF* in, TIFF* out) tiffcp(TIFF* in, TIFF* out)
{ {
uint16 bitspersample, samplesperpixel, shortv; uint16 bitspersample = 0, samplesperpixel, shortv;
copyFunc cf; copyFunc cf;
uint32 w, l; uint32 w, l;
CopyField(TIFFTAG_IMAGEWIDTH, w); CopyField(TIFFTAG_IMAGEWIDTH, w);
CopyField(TIFFTAG_IMAGELENGTH, l); CopyField(TIFFTAG_IMAGELENGTH, l);
if( convert_8_to_4 ) if( convert_8_to_4 )
{ {
TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 4); TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 4);
} }
else else
 End of changes. 7 change blocks. 
2 lines changed or deleted 39 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)