libgeotiff  1.6.0
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).
  Fossies Dox: libgeotiff-1.6.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

geotifcp.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "geotiff.h"
#include "geo_normalize.h"
#include "geo_tiffp.h"
#include "geo_keyp.h"
#include "xtiffio.h"
#include "cpl_serv.h"
Include dependency graph for geotifcp.c:

Go to the source code of this file.

Data Structures

struct  cpTag
 

Macros

#define TIFFOpen   XTIFFOpen
 
#define TIFFClose   XTIFFClose
 
#define streq(a, b)   (strcmp(a,b) == 0)
 
#define strneq(a, b, n)   (strncmp(a,b,n) == 0)
 
#define TRUE   1
 
#define FALSE   0
 
#define CVT(x)   (((x) * ((1L<<16)-1)) / 255)
 
#define CopyField(tag, v)   if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v)
 
#define CopyField2(tag, v1, v2)   if (TIFFGetField(in, tag, &v1, &v2)) TIFFSetField(out, tag, v1, v2)
 
#define CopyField3(tag, v1, v2, v3)   if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3)
 
#define CopyField4(tag, v1, v2, v3, v4)   if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) TIFFSetField(out, tag, v1, v2, v3, v4)
 
#define NTAGS   (sizeof (tags) / sizeof (tags[0]))
 
#define DECLAREcpFunc(x)
 
#define DECLAREreadFunc(x)
 
#define DECLAREwriteFunc(x)
 
#define T   1
 
#define F   0
 
#define pack(a, b, c, d, e)   ((long)(((a)<<11)|((b)<<3)|((c)<<2)|((d)<<1)|(e)))
 

Typedefs

typedef int(* copyFunc) (TIFF *in, TIFF *out, uint32 l, uint32 w, uint16 samplesperpixel)
 
typedef void(* readFunc) (TIFF *, unsigned char *, uint32, uint32, tsample_t)
 
typedef int(* writeFunc) (TIFF *, unsigned char *, uint32, uint32, tsample_t)
 

Functions

int getopt ()
 
static void ApplyWorldFile (const char *worldfile, TIFF *out)
 
static int tiffcp (TIFF *, TIFF *)
 
static int processCompressOptions (char *)
 
static void usage (void)
 
static int parseVersion (const char *str)
 
static void SetVersionNumbers (GTIF *gtif)
 
int main (int argc, char *argv[])
 
static void InstallGeoTIFF (TIFF *out)
 
static void CopyGeoTIFF (TIFF *in, TIFF *out)
 
static void processG3Options (char *cp)
 
static void CheckAndCorrectColormap (TIFF *tif, int n, uint16 *r, uint16 *g, uint16 *b)
 
static void cpOtherTags (TIFF *in, TIFF *out)
 
static copyFunc pickCopyFunc (TIFF *, TIFF *, uint16, uint16)
 
static int cpContig2ContigByRow (TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int cpContig2ContigByRow_8_to_4 (TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int cpDecodedStrips (TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int cpSeparate2SeparateByRow (TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int cpContig2SeparateByRow (TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int cpSeparate2ContigByRow (TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static void cpStripToTile (unsigned char *out, unsigned char *in, uint32 rows, uint32 cols, int outskew, int inskew)
 
static void cpContigBufToSeparateBuf (unsigned char *out, unsigned char *in, uint32 rows, uint32 cols, int outskew, int inskew, tsample_t spp)
 
static void cpSeparateBufToContigBuf (unsigned char *out, unsigned char *in, uint32 rows, uint32 cols, int outskew, int inskew, tsample_t spp)
 
static int cpImage (TIFF *in, TIFF *out, readFunc fin, writeFunc fout, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static void readContigStripsIntoBuffer (TIFF *in, unsigned char *buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static void readSeparateStripsIntoBuffer (TIFF *in, unsigned char *buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static void readContigTilesIntoBuffer (TIFF *in, unsigned char *buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static void readSeparateTilesIntoBuffer (TIFF *in, unsigned char *buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int writeBufferToContigStrips (TIFF *out, unsigned char *buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int writeBufferToSeparateStrips (TIFF *out, unsigned char *buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int writeBufferToContigTiles (TIFF *out, unsigned char *buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int writeBufferToSeparateTiles (TIFF *out, unsigned char *buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int cpContigStrips2ContigTiles (TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int cpContigStrips2SeparateTiles (TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int cpSeparateStrips2ContigTiles (TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int cpSeparateStrips2SeparateTiles (TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int cpContigTiles2ContigTiles (TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int cpContigTiles2SeparateTiles (TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int cpSeparateTiles2ContigTiles (TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int cpSeparateTiles2SeparateTiles (TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int cpContigTiles2ContigStrips (TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int cpContigTiles2SeparateStrips (TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int cpSeparateTiles2ContigStrips (TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 
static int cpSeparateTiles2SeparateStrips (TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
 

Variables

static int outtiled = -1
 
static uint32 tilewidth
 
static uint32 tilelength
 
static int convert_8_to_4 = 0
 
static uint16 config
 
static uint16 compression
 
static uint16 predictor
 
static uint16 fillorder
 
static uint32 rowsperstrip
 
static uint32 g3opts
 
static int ignore = 0
 
static uint32 defg3opts = (uint32) -1
 
static int quality = 75
 
static int jpegcolormode = JPEGCOLORMODE_RGB
 
static uint16 defcompression = (uint16) -1
 
static uint16 defpredictor = (uint16) -1
 
static char * geofile =(char *)0
 
static char * proj4_string = (char *) 0
 
static char * worldfile =(char *)0
 
static int forced_version = 0
 
static unsigned short version = 0
 
static unsigned short key_version = 0
 
static unsigned short minor_revision = 0
 
char * stuff []
 
static struct cpTag tags []
 

Macro Definition Documentation

◆ CopyField

#define CopyField (   tag,
 
)    if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v)

Definition at line 509 of file geotifcp.c.

◆ CopyField2

#define CopyField2 (   tag,
  v1,
  v2 
)    if (TIFFGetField(in, tag, &v1, &v2)) TIFFSetField(out, tag, v1, v2)

Definition at line 511 of file geotifcp.c.

◆ CopyField3

#define CopyField3 (   tag,
  v1,
  v2,
  v3 
)    if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3)

Definition at line 513 of file geotifcp.c.

◆ CopyField4

#define CopyField4 (   tag,
  v1,
  v2,
  v3,
  v4 
)    if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) TIFFSetField(out, tag, v1, v2, v3, v4)

Definition at line 515 of file geotifcp.c.

◆ CVT

#define CVT (   x)    (((x) * ((1L<<16)-1)) / 255)

◆ DECLAREcpFunc

#define DECLAREcpFunc (   x)
Value:
static int x(TIFF* in, TIFF* out, \
uint32 imagelength, uint32 imagewidth, tsample_t spp)

Definition at line 733 of file geotifcp.c.

◆ DECLAREreadFunc

#define DECLAREreadFunc (   x)
Value:
static void x(TIFF* in, \
unsigned char* buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)

Definition at line 737 of file geotifcp.c.

◆ DECLAREwriteFunc

#define DECLAREwriteFunc (   x)
Value:
static int x(TIFF* out, \
unsigned char* buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)

Definition at line 742 of file geotifcp.c.

◆ F

#define F   0

◆ FALSE

#define FALSE   0

Definition at line 38 of file geotifcp.c.

◆ NTAGS

#define NTAGS   (sizeof (tags) / sizeof (tags[0]))

Definition at line 563 of file geotifcp.c.

◆ pack

#define pack (   a,
  b,
  c,
  d,
 
)    ((long)(((a)<<11)|((b)<<3)|((c)<<2)|((d)<<1)|(e)))

◆ streq

#define streq (   a,
 
)    (strcmp(a,b) == 0)

Definition at line 34 of file geotifcp.c.

◆ strneq

#define strneq (   a,
  b,
 
)    (strncmp(a,b,n) == 0)

Definition at line 35 of file geotifcp.c.

◆ T

#define T   1

◆ TIFFClose

#define TIFFClose   XTIFFClose

Definition at line 28 of file geotifcp.c.

◆ TIFFOpen

#define TIFFOpen   XTIFFOpen

Definition at line 27 of file geotifcp.c.

◆ TRUE

#define TRUE   1

Definition at line 37 of file geotifcp.c.

Typedef Documentation

◆ copyFunc

typedef int(* copyFunc) (TIFF *in, TIFF *out, uint32 l, uint32 w, uint16 samplesperpixel)

Definition at line 617 of file geotifcp.c.

◆ readFunc

typedef void(* readFunc) (TIFF *, unsigned char *, uint32, uint32, tsample_t)

Definition at line 739 of file geotifcp.c.

◆ writeFunc

typedef int(* writeFunc) (TIFF *, unsigned char *, uint32, uint32, tsample_t)

Definition at line 744 of file geotifcp.c.

Function Documentation

◆ ApplyWorldFile()

static void ApplyWorldFile ( const char *  worldfile,
TIFF *  out 
)
static

Definition at line 235 of file geotifcp.c.

237 {
238  FILE *tfw;
239  double pixsize[3], xoff, yoff, tiepoint[6], x_rot, y_rot;
240  int success;
241 
242  /*
243  * Read the world file. Note we currently ignore rotational coefficients!
244  */
245  tfw = fopen( worldfilename, "rt" );
246  if( tfw == NULL )
247  {
248  perror( worldfilename );
249  return;
250  }
251 
252  success = fscanf( tfw, "%lf", pixsize + 0 );
253  success &= fscanf( tfw, "%lf", &y_rot );
254  success &= fscanf( tfw, "%lf", &x_rot );
255  success &= fscanf( tfw, "%lf", pixsize + 1 );
256  success &= fscanf( tfw, "%lf", &xoff );
257  success &= fscanf( tfw, "%lf", &yoff );
258 
259  fclose( tfw );
260 
261  if( success != 1 )
262  {
263  fprintf( stderr, "Failure parsing one or more lines of world file.\n");
264  return;
265  }
266 
267  /*
268  * Write out pixel scale, and tiepoint information.
269  */
270  if( x_rot == 0.0 && y_rot == 0.0 )
271  {
272  pixsize[1] = ABS(pixsize[1]);
273  pixsize[2] = 0.0;
274  TIFFSetField(out, GTIFF_PIXELSCALE, 3, pixsize);
275 
276  tiepoint[0] = 0.5;
277  tiepoint[1] = 0.5;
278  tiepoint[2] = 0.0;
279  tiepoint[3] = xoff;
280  tiepoint[4] = yoff;
281  tiepoint[5] = 0.0;
282  TIFFSetField(out, GTIFF_TIEPOINTS, 6, tiepoint);
283  }
284  else
285  {
286  double adfMatrix[16];
287 
288  memset(adfMatrix,0,sizeof(double) * 16);
289 
290  adfMatrix[0] = pixsize[0];
291  adfMatrix[1] = x_rot;
292  adfMatrix[3] = xoff - (pixsize[0]+x_rot) * 0.5;
293  adfMatrix[4] = y_rot;
294  adfMatrix[5] = pixsize[1];
295  adfMatrix[7] = yoff - (pixsize[1]+y_rot) * 0.5;
296  adfMatrix[15] = 1.0;
297 
298  TIFFSetField( out, TIFFTAG_GEOTRANSMATRIX, 16, adfMatrix );
299  }
300 }

References ABS, GTIFF_PIXELSCALE, GTIFF_TIEPOINTS, NULL, and TIFFTAG_GEOTRANSMATRIX.

Referenced by tiffcp().

◆ CheckAndCorrectColormap()

static void CheckAndCorrectColormap ( TIFF *  tif,
int  n,
uint16 *  r,
uint16 *  g,
uint16 *  b 
)
static

Definition at line 491 of file geotifcp.c.

492 {
493  int i;
494 
495  for (i = 0; i < n; i++)
496  if (r[i] >= 256 || g[i] >= 256 || b[i] >= 256)
497  return;
498  TIFFWarning(TIFFFileName(tif), "Scaling 8-bit colormap");
499 #define CVT(x) (((x) * ((1L<<16)-1)) / 255)
500  for (i = 0; i < n; i++) {
501  r[i] = CVT(r[i]);
502  g[i] = CVT(g[i]);
503  b[i] = CVT(b[i]);
504  }
505 #undef CVT
506 }

References CVT.

Referenced by tiffcp().

◆ CopyGeoTIFF()

static void CopyGeoTIFF ( TIFF *  in,
TIFF *  out 
)
static

Definition at line 344 of file geotifcp.c.

345 {
346  GTIF *gtif; /* GeoKey-level descriptor */
347  double *d_list = NULL;
348  int16 d_list_count;
349 
350  /* read definition from source file. */
351  gtif = GTIFNew(in);
352  if (!gtif)
353  return;
354 
355  if (TIFFGetField(in, GTIFF_TIEPOINTS, &d_list_count, &d_list))
356  TIFFSetField(out, GTIFF_TIEPOINTS, d_list_count, d_list);
357  if (TIFFGetField(in, GTIFF_PIXELSCALE, &d_list_count, &d_list))
358  TIFFSetField(out, GTIFF_PIXELSCALE, d_list_count, d_list);
359  if (TIFFGetField(in, GTIFF_TRANSMATRIX, &d_list_count, &d_list))
360  TIFFSetField(out, GTIFF_TRANSMATRIX, d_list_count, d_list);
361 
362  /* Here we violate the GTIF abstraction to retarget on another file.
363  We should just have a function for copying tags from one GTIF object
364  to another. */
365  gtif->gt_tif = out;
366  gtif->gt_flags |= FLAG_FILE_MODIFIED;
367 
368  /* Install keys and tags */
369  SetVersionNumbers(gtif);
370  GTIFWriteKeys(gtif);
371  GTIFFree(gtif);
372  return;
373 }

References FLAG_FILE_MODIFIED, gtiff::gt_flags, gtiff::gt_tif, GTIFF_PIXELSCALE, GTIFF_TIEPOINTS, GTIFF_TRANSMATRIX, GTIFFree(), GTIFNew(), GTIFWriteKeys(), NULL, and SetVersionNumbers().

Referenced by tiffcp().

◆ cpContig2ContigByRow()

static int cpContig2ContigByRow ( TIFF *  in,
TIFF *  out,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 749 of file geotifcp.c.

750 {
751  unsigned char *buf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in));
752  uint32 row;
753 
754  (void) imagewidth; (void) spp;
755  for (row = 0; row < imagelength; row++) {
756  if (TIFFReadScanline(in, buf, row, 0) < 0 && !ignore)
757  goto done;
758  if (TIFFWriteScanline(out, buf, row, 0) < 0)
759  goto bad;
760  }
761 done:
762  _TIFFfree(buf);
763  return (TRUE);
764 bad:
765  _TIFFfree(buf);
766  return (FALSE);
767 }

References FALSE, ignore, and TRUE.

Referenced by pickCopyFunc().

◆ cpContig2ContigByRow_8_to_4()

static int cpContig2ContigByRow_8_to_4 ( TIFF *  in,
TIFF *  out,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 772 of file geotifcp.c.

773 {
774  unsigned char *buf_in = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in));
775  unsigned char *buf_out = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out));
776  uint32 row;
777 
778  printf( "Downsample\n" );
779 
780  (void) spp;
781  for (row = 0; row < imagelength; row++) {
782  int i_in, i_out_byte;
783 
784  if (TIFFReadScanline(in, buf_in, row, 0) < 0 && !ignore)
785  goto done;
786 
787  for( i_in = 0, i_out_byte = 0;
788  (unsigned)i_in < imagewidth;
789  i_in += 2, i_out_byte++ )
790  {
791  buf_out[i_out_byte] =
792  (buf_in[i_in] & 0xf)*16 + (buf_in[i_in+1] & 0xf);
793  }
794 
795  if (TIFFWriteScanline(out, buf_out, row, 0) < 0)
796  goto bad;
797  }
798  done:
799  _TIFFfree(buf_in);
800  _TIFFfree(buf_out);
801  return (TRUE);
802  bad:
803  _TIFFfree(buf_in);
804  _TIFFfree(buf_out);
805  return (FALSE);
806 }

References FALSE, ignore, and TRUE.

Referenced by pickCopyFunc().

◆ cpContig2SeparateByRow()

static int cpContig2SeparateByRow ( TIFF *  in,
TIFF *  out,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 866 of file geotifcp.c.

867 {
868  unsigned char *inbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in));
869  unsigned char *outbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out));
870  register unsigned char *inp, *outp;
871  register uint32 n;
872  uint32 row;
873  tsample_t s;
874 
875  /* unpack channels */
876  for (s = 0; s < spp; s++) {
877  for (row = 0; row < imagelength; row++) {
878  if (TIFFReadScanline(in, inbuf, row, 0) < 0 && !ignore)
879  goto done;
880  inp = inbuf + s;
881  outp = outbuf;
882  for (n = imagewidth; n-- > 0;) {
883  *outp++ = *inp;
884  inp += spp;
885  }
886  if (TIFFWriteScanline(out, outbuf, row, s) < 0)
887  goto bad;
888  }
889  }
890 done:
891  if (inbuf) _TIFFfree(inbuf);
892  if (outbuf) _TIFFfree(outbuf);
893  return (TRUE);
894 bad:
895  if (inbuf) _TIFFfree(inbuf);
896  if (outbuf) _TIFFfree(outbuf);
897  return (FALSE);
898 }

References FALSE, ignore, and TRUE.

Referenced by pickCopyFunc().

◆ cpContigBufToSeparateBuf()

static void cpContigBufToSeparateBuf ( unsigned char *  out,
unsigned char *  in,
uint32  rows,
uint32  cols,
int  outskew,
int  inskew,
tsample_t  spp 
)
static

Definition at line 951 of file geotifcp.c.

953 {
954  while (rows-- > 0) {
955  uint32 j = cols;
956  while (j-- > 0)
957  *out++ = *in, in += spp;
958  out += outskew;
959  in += inskew;
960  }
961 }

Referenced by writeBufferToSeparateTiles().

◆ cpContigStrips2ContigTiles()

static int cpContigStrips2ContigTiles ( TIFF *  in,
TIFF *  out,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 1266 of file geotifcp.c.

1267 {
1268  return cpImage(in, out,
1271  imagelength, imagewidth, spp);
1272 }

References cpImage(), readContigStripsIntoBuffer(), and writeBufferToContigTiles().

Referenced by pickCopyFunc().

◆ cpContigStrips2SeparateTiles()

static int cpContigStrips2SeparateTiles ( TIFF *  in,
TIFF *  out,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 1277 of file geotifcp.c.

1278 {
1279  return cpImage(in, out,
1282  imagelength, imagewidth, spp);
1283 }

References cpImage(), readContigStripsIntoBuffer(), and writeBufferToSeparateTiles().

Referenced by pickCopyFunc().

◆ cpContigTiles2ContigStrips()

static int cpContigTiles2ContigStrips ( TIFF *  in,
TIFF *  out,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 1354 of file geotifcp.c.

1355 {
1356  return cpImage(in, out,
1359  imagelength, imagewidth, spp);
1360 }

References cpImage(), readContigTilesIntoBuffer(), and writeBufferToContigStrips().

Referenced by pickCopyFunc().

◆ cpContigTiles2ContigTiles()

static int cpContigTiles2ContigTiles ( TIFF *  in,
TIFF *  out,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 1310 of file geotifcp.c.

1311 {
1312  return cpImage(in, out,
1315  imagelength, imagewidth, spp);
1316 }

References cpImage(), readContigTilesIntoBuffer(), and writeBufferToContigTiles().

Referenced by pickCopyFunc().

◆ cpContigTiles2SeparateStrips()

static int cpContigTiles2SeparateStrips ( TIFF *  in,
TIFF *  out,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 1365 of file geotifcp.c.

1366 {
1367  return cpImage(in, out,
1370  imagelength, imagewidth, spp);
1371 }

References cpImage(), readContigTilesIntoBuffer(), and writeBufferToSeparateStrips().

Referenced by pickCopyFunc().

◆ cpContigTiles2SeparateTiles()

static int cpContigTiles2SeparateTiles ( TIFF *  in,
TIFF *  out,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 1321 of file geotifcp.c.

1322 {
1323  return cpImage(in, out,
1326  imagelength, imagewidth, spp);
1327 }

References cpImage(), readContigTilesIntoBuffer(), and writeBufferToSeparateTiles().

Referenced by pickCopyFunc().

◆ cpDecodedStrips()

static int cpDecodedStrips ( TIFF *  in,
TIFF *  out,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 811 of file geotifcp.c.

812 {
813  tsize_t stripsize = TIFFStripSize(in);
814  unsigned char *buf = (unsigned char *)_TIFFmalloc(stripsize);
815 
816  (void) imagewidth; (void) spp;
817  if (buf) {
818  tstrip_t s, ns = TIFFNumberOfStrips(in);
819  uint32 row = 0;
820  for (s = 0; s < ns; s++) {
821  tsize_t cc = (row + rowsperstrip > imagelength) ?
822  TIFFVStripSize(in, imagelength - row) : stripsize;
823  if (TIFFReadEncodedStrip(in, s, buf, cc) < 0 && !ignore)
824  break;
825  if (TIFFWriteEncodedStrip(out, s, buf, cc) < 0) {
826  _TIFFfree(buf);
827  return (FALSE);
828  }
829  row += rowsperstrip;
830  }
831  _TIFFfree(buf);
832  return (TRUE);
833  }
834  return (FALSE);
835 }

References FALSE, ignore, rowsperstrip, and TRUE.

Referenced by pickCopyFunc().

◆ cpImage()

static int cpImage ( TIFF *  in,
TIFF *  out,
readFunc  fin,
writeFunc  fout,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 977 of file geotifcp.c.

979 {
980  int status = FALSE;
981  unsigned char* buf = (unsigned char *)
982  _TIFFmalloc(TIFFRasterScanlineSize(in) * imagelength);
983  if (buf) {
984  (*fin)(in, buf, imagelength, imagewidth, spp);
985  status = (fout)(out, buf, imagelength, imagewidth, spp);
986  _TIFFfree(buf);
987  }
988  return (status);
989 }

References FALSE.

Referenced by cpContigStrips2ContigTiles(), cpContigStrips2SeparateTiles(), cpContigTiles2ContigStrips(), cpContigTiles2ContigTiles(), cpContigTiles2SeparateStrips(), cpContigTiles2SeparateTiles(), cpSeparateStrips2ContigTiles(), cpSeparateStrips2SeparateTiles(), cpSeparateTiles2ContigStrips(), cpSeparateTiles2ContigTiles(), cpSeparateTiles2SeparateStrips(), and cpSeparateTiles2SeparateTiles().

◆ cpOtherTags()

static void cpOtherTags ( TIFF *  in,
TIFF *  out 
)
static

Definition at line 565 of file geotifcp.c.

566 {
567  struct cpTag *p;
568 
569  for (p = tags; p < &tags[NTAGS]; p++)
570  switch (p->type) {
571  case TIFF_SHORT:
572  if (p->count == 1) {
573  uint16 shortv;
574  CopyField(p->tag, shortv);
575  } else if (p->count == 2) {
576  uint16 shortv1, shortv2;
577  CopyField2(p->tag, shortv1, shortv2);
578  } else if (p->count == (uint16) -1) {
579  uint16 shortv1;
580  uint16* shortav;
581  CopyField2(p->tag, shortv1, shortav);
582  }
583  break;
584  case TIFF_LONG:
585  { uint32 longv;
586  CopyField(p->tag, longv);
587  }
588  break;
589  case TIFF_RATIONAL:
590  if (p->count == 1) {
591  float floatv;
592  CopyField(p->tag, floatv);
593  } else if (p->count == (uint16) -1) {
594  float* floatav;
595  CopyField(p->tag, floatav);
596  }
597  break;
598  case TIFF_ASCII:
599  { char* stringv;
600  CopyField(p->tag, stringv);
601  }
602  break;
603  case TIFF_DOUBLE:
604  if (p->count == 1) {
605  double doublev;
606  CopyField(p->tag, doublev);
607  } else if (p->count == (uint16) -1) {
608  double* doubleav;
609  CopyField(p->tag, doubleav);
610  }
611  break;
612  default:
613  break;
614  }
615 }

References CopyField, CopyField2, cpTag::count, NTAGS, cpTag::tag, tags, and cpTag::type.

Referenced by tiffcp().

◆ cpSeparate2ContigByRow()

static int cpSeparate2ContigByRow ( TIFF *  in,
TIFF *  out,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 903 of file geotifcp.c.

904 {
905  unsigned char *inbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in));
906  unsigned char *outbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out));
907  register unsigned char *inp, *outp;
908  register uint32 n;
909  uint32 row;
910  tsample_t s;
911 
912  for (row = 0; row < imagelength; row++) {
913  /* merge channels */
914  for (s = 0; s < spp; s++) {
915  if (TIFFReadScanline(in, inbuf, row, s) < 0 && !ignore)
916  goto done;
917  inp = inbuf;
918  outp = outbuf + s;
919  for (n = imagewidth; n-- > 0;) {
920  *outp = *inp++;
921  outp += spp;
922  }
923  }
924  if (TIFFWriteScanline(out, outbuf, row, 0) < 0)
925  goto bad;
926  }
927 done:
928  if (inbuf) _TIFFfree(inbuf);
929  if (outbuf) _TIFFfree(outbuf);
930  return (TRUE);
931 bad:
932  if (inbuf) _TIFFfree(inbuf);
933  if (outbuf) _TIFFfree(outbuf);
934  return (FALSE);
935 }

References FALSE, ignore, and TRUE.

Referenced by pickCopyFunc().

◆ cpSeparate2SeparateByRow()

static int cpSeparate2SeparateByRow ( TIFF *  in,
TIFF *  out,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 840 of file geotifcp.c.

841 {
842  unsigned char *buf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in));
843  uint32 row;
844  tsample_t s;
845 
846  (void) imagewidth;
847  for (s = 0; s < spp; s++) {
848  for (row = 0; row < imagelength; row++) {
849  if (TIFFReadScanline(in, buf, row, s) < 0 && !ignore)
850  goto done;
851  if (TIFFWriteScanline(out, buf, row, s) < 0)
852  goto bad;
853  }
854  }
855 done:
856  _TIFFfree(buf);
857  return (TRUE);
858 bad:
859  _TIFFfree(buf);
860  return (FALSE);
861 }

References FALSE, ignore, and TRUE.

Referenced by pickCopyFunc().

◆ cpSeparateBufToContigBuf()

static void cpSeparateBufToContigBuf ( unsigned char *  out,
unsigned char *  in,
uint32  rows,
uint32  cols,
int  outskew,
int  inskew,
tsample_t  spp 
)
static

Definition at line 964 of file geotifcp.c.

966 {
967  while (rows-- > 0) {
968  uint32 j = cols;
969  while (j-- > 0)
970  *out = *in++, out += spp;
971  out += outskew;
972  in += inskew;
973  }
974 }

Referenced by readSeparateTilesIntoBuffer().

◆ cpSeparateStrips2ContigTiles()

static int cpSeparateStrips2ContigTiles ( TIFF *  in,
TIFF *  out,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 1288 of file geotifcp.c.

1289 {
1290  return cpImage(in, out,
1293  imagelength, imagewidth, spp);
1294 }

References cpImage(), readSeparateStripsIntoBuffer(), and writeBufferToContigTiles().

Referenced by pickCopyFunc().

◆ cpSeparateStrips2SeparateTiles()

static int cpSeparateStrips2SeparateTiles ( TIFF *  in,
TIFF *  out,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 1299 of file geotifcp.c.

1300 {
1301  return cpImage(in, out,
1304  imagelength, imagewidth, spp);
1305 }

References cpImage(), readSeparateStripsIntoBuffer(), and writeBufferToSeparateTiles().

Referenced by pickCopyFunc().

◆ cpSeparateTiles2ContigStrips()

static int cpSeparateTiles2ContigStrips ( TIFF *  in,
TIFF *  out,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 1376 of file geotifcp.c.

1377 {
1378  return cpImage(in, out,
1381  imagelength, imagewidth, spp);
1382 }

References cpImage(), readSeparateTilesIntoBuffer(), and writeBufferToContigStrips().

Referenced by pickCopyFunc().

◆ cpSeparateTiles2ContigTiles()

static int cpSeparateTiles2ContigTiles ( TIFF *  in,
TIFF *  out,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 1332 of file geotifcp.c.

1333 {
1334  return cpImage(in, out,
1337  imagelength, imagewidth, spp);
1338 }

References cpImage(), readSeparateTilesIntoBuffer(), and writeBufferToContigTiles().

Referenced by pickCopyFunc().

◆ cpSeparateTiles2SeparateStrips()

static int cpSeparateTiles2SeparateStrips ( TIFF *  in,
TIFF *  out,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 1387 of file geotifcp.c.

1388 {
1389  return cpImage(in, out,
1392  imagelength, imagewidth, spp);
1393 }

References cpImage(), readSeparateTilesIntoBuffer(), and writeBufferToSeparateStrips().

Referenced by pickCopyFunc().

◆ cpSeparateTiles2SeparateTiles()

static int cpSeparateTiles2SeparateTiles ( TIFF *  in,
TIFF *  out,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 1343 of file geotifcp.c.

1344 {
1345  return cpImage(in, out,
1348  imagelength, imagewidth, spp);
1349 }

References cpImage(), readSeparateTilesIntoBuffer(), and writeBufferToSeparateTiles().

Referenced by pickCopyFunc().

◆ cpStripToTile()

static void cpStripToTile ( unsigned char *  out,
unsigned char *  in,
uint32  rows,
uint32  cols,
int  outskew,
int  inskew 
)
static

Definition at line 938 of file geotifcp.c.

940 {
941  while (rows-- > 0) {
942  uint32 j = cols;
943  while (j-- > 0)
944  *out++ = *in++;
945  out += outskew;
946  in += inskew;
947  }
948 }

Referenced by readContigTilesIntoBuffer(), and writeBufferToContigTiles().

◆ getopt()

int getopt ( )

Referenced by main().

◆ InstallGeoTIFF()

static void InstallGeoTIFF ( TIFF *  out)
static

Definition at line 302 of file geotifcp.c.

303 {
304  GTIF *gtif; /* GeoKey-level descriptor */
305  FILE *fd;
306 
307  gtif = GTIFNew(out);
308  if (!gtif)
309  {
310  printf("failed in GTIFNew\n");
311  return;
312  }
313 
314  if( geofile )
315  {
316  /* Install keys and tags */
317  fd = fopen(geofile,"r");
318  if( fd == NULL )
319  {
320  perror( geofile );
321  exit( -1 );
322  }
323  if (!GTIFImport(gtif,0,fd))
324  {
325  fprintf(stderr,"Failure in GTIFImport\n");
326  exit (-1);
327  }
328  fclose(fd);
329  }
330  else if( proj4_string )
331  {
332  if( !GTIFSetFromProj4(gtif,proj4_string) )
333  {
334  fprintf(stderr,"Failure in GTIFSetFromProj4\n");
335  exit (-1);
336  }
337  }
338  SetVersionNumbers(gtif);
339  GTIFWriteKeys(gtif);
340  GTIFFree(gtif);
341  return;
342 }

References geofile, GTIFFree(), GTIFImport(), GTIFNew(), GTIFSetFromProj4(), GTIFWriteKeys(), NULL, proj4_string, and SetVersionNumbers().

Referenced by tiffcp().

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 98 of file geotifcp.c.

99 {
100  uint16 defconfig = (uint16) -1;
101  uint16 deffillorder = 0;
102  uint32 deftilewidth = (uint32) -1;
103  uint32 deftilelength = (uint32) -1;
104  uint32 defrowsperstrip = (uint32) -1;
105  uint32 diroff = 0;
106  TIFF* in;
107  TIFF* out;
108  char mode[10];
109  char* mp = mode;
110  int c;
111  extern int optind;
112  extern char* optarg;
113 
114  *mp++ = 'w';
115  *mp = '\0';
116  while ((c = getopt(argc, argv, "c:f:l:o:p:r:w:e:g:4:v:aistd8BLMC")) != -1)
117  switch (c) {
118  case 'a': /* append to output */
119  mode[0] = 'a';
120  break;
121  case 'd': /* down cast 8bit to 4bit */
122  convert_8_to_4 = 1;
123  break;
124  case 'c': /* compression scheme */
126  usage();
127  break;
128  case 'e':
129  worldfile = optarg;
130  break;
131  case 'f': /* fill order */
132  if (streq(optarg, "lsb2msb"))
133  deffillorder = FILLORDER_LSB2MSB;
134  else if (streq(optarg, "msb2lsb"))
135  deffillorder = FILLORDER_MSB2LSB;
136  else
137  usage();
138  break;
139  case 'i': /* ignore errors */
140  ignore = TRUE;
141  break;
142  case 'g': /* GeoTIFF metadata file */
143  geofile = optarg;
144  break;
145  case '4':
147  break;
148  case 'l': /* tile length */
149  outtiled = TRUE;
150  deftilelength = atoi(optarg);
151  break;
152  case 'o': /* initial directory offset */
153  diroff = strtoul(optarg, NULL, 0);
154  break;
155  case 'p': /* planar configuration */
156  if (streq(optarg, "separate"))
157  defconfig = PLANARCONFIG_SEPARATE;
158  else if (streq(optarg, "contig"))
159  defconfig = PLANARCONFIG_CONTIG;
160  else
161  usage();
162  break;
163  case 'r': /* rows/strip */
164  defrowsperstrip = atoi(optarg);
165  break;
166  case 's': /* generate stripped output */
167  outtiled = FALSE;
168  break;
169  case 't': /* generate tiled output */
170  outtiled = TRUE;
171  break;
172  case 'w': /* tile width */
173  outtiled = TRUE;
174  deftilewidth = atoi(optarg);
175  break;
176  case 'B':
177  *mp++ = 'b'; *mp = '\0';
178  break;
179  case 'L':
180  *mp++ = 'l'; *mp = '\0';
181  break;
182  case 'M':
183  *mp++ = 'm'; *mp = '\0';
184  break;
185  case 'C':
186  *mp++ = 'c'; *mp = '\0';
187  break;
188  case '8':
189  *mp++ = '8'; *mp = '\0';
190  break;
191  case 'v':
192  if (!parseVersion(optarg))
193  usage();
194  break;
195  case '?':
196  usage();
197  /*NOTREACHED*/
198  }
199  if (argc - optind < 2)
200  usage();
201  printf( "mode=%s\n", mode);
202  out = TIFFOpen(argv[argc-1], mode);
203  if (out == NULL)
204  return (-2);
205  for (; optind < argc-1 ; optind++) {
206  in = TIFFOpen(argv[optind], "r");
207  if (in == NULL)
208  return (-3);
209  if (diroff != 0 && !TIFFSetSubDirectory(in, diroff)) {
210  TIFFError(TIFFFileName(in),
211  "Error, setting subdirectory at %#x", diroff);
212  (void) TIFFClose(out);
213  return (1);
214  }
215  do {
216  config = defconfig;
219  fillorder = deffillorder;
220  rowsperstrip = defrowsperstrip;
221  tilewidth = deftilewidth;
222  tilelength = deftilelength;
223  g3opts = defg3opts;
224  if (!tiffcp(in, out) || !TIFFWriteDirectory(out)) {
225  (void) TIFFClose(out);
226  return (1);
227  }
228  } while (TIFFReadDirectory(in));
229  (void) TIFFClose(in);
230  }
231  (void) TIFFClose(out);
232  return (0);
233 }

References compression, config, convert_8_to_4, defcompression, defg3opts, defpredictor, FALSE, fillorder, g3opts, geofile, getopt(), ignore, NULL, optarg, optind, outtiled, parseVersion(), predictor, processCompressOptions(), proj4_string, rowsperstrip, streq, TIFFClose, tiffcp(), TIFFOpen, tilelength, tilewidth, TRUE, usage(), and worldfile.

◆ parseVersion()

static int parseVersion ( const char *  str)
static

Definition at line 72 of file geotifcp.c.

73 {
74  if( strlen(str) != 5 || str[1] != ':' || str[3] != ':' )
75  return 0;
76  if( str[0] < '0' || str[0] > '9' )
77  return 0;
78  if( str[2] < '0' || str[2] > '9' )
79  return 0;
80  if( str[4] < '0' || str[4] > '9' )
81  return 0;
82  forced_version = 1;
83  version = str[0] - '0';
84  key_version = str[2] - '0';
85  minor_revision = str[4] - '0';
86  return 1;
87 }

References forced_version, key_version, minor_revision, and version.

Referenced by main().

◆ pickCopyFunc()

static copyFunc pickCopyFunc ( TIFF *  in,
TIFF *  out,
uint16  bitspersample,
uint16  samplesperpixel 
)
static

Definition at line 1399 of file geotifcp.c.

1400 {
1401  uint16 shortv;
1402  uint32 w, l, tw, tl;
1403  int bychunk;
1404 
1405  (void) TIFFGetField(in, TIFFTAG_PLANARCONFIG, &shortv);
1406  if (shortv != config && bitspersample != 8 && samplesperpixel > 1) {
1407  fprintf(stderr,
1408 "%s: Can not handle different planar configuration w/ bits/sample != 8\n",
1409  TIFFFileName(in));
1410  return (NULL);
1411  }
1412  TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &w);
1413  TIFFGetField(in, TIFFTAG_IMAGELENGTH, &l);
1414  if (TIFFIsTiled(out)) {
1415  if (!TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw))
1416  tw = w;
1417  if (!TIFFGetField(in, TIFFTAG_TILELENGTH, &tl))
1418  tl = l;
1419  bychunk = (tw == tilewidth && tl == tilelength);
1420  } else if (TIFFIsTiled(in)) {
1421  TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw);
1422  TIFFGetField(in, TIFFTAG_TILELENGTH, &tl);
1423  bychunk = (tw == w && tl == rowsperstrip);
1424  } else {
1425  uint32 irps = (uint32) -1L;
1426  TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &irps);
1427  bychunk = (rowsperstrip == irps);
1428  }
1429 #define T 1
1430 #define F 0
1431 #define pack(a,b,c,d,e) ((long)(((a)<<11)|((b)<<3)|((c)<<2)|((d)<<1)|(e)))
1432  switch(pack(shortv,config,TIFFIsTiled(in),TIFFIsTiled(out),bychunk)) {
1433 /* Strips -> Tiles */
1434  case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,T,F):
1435  case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,T,T):
1437  case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,T,F):
1438  case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,T,T):
1440  case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,T,F):
1441  case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,T,T):
1443  case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,T,F):
1444  case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,T,T):
1446 /* Tiles -> Tiles */
1447  case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,T,F):
1448  case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,T,T):
1450  case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,T,F):
1451  case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,T,T):
1453  case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,T,F):
1454  case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,T,T):
1456  case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,T,F):
1457  case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,T,T):
1459 /* Tiles -> Strips */
1460  case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,F,F):
1461  case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,F,T):
1463  case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,F,F):
1464  case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,F,T):
1466  case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,F,F):
1467  case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,F,T):
1469  case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,F,F):
1470  case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,F,T):
1472 /* Strips -> Strips */
1473  case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,F,F):
1474  if( convert_8_to_4 )
1476  else
1477  return cpContig2ContigByRow;
1478 
1479  case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,F,T):
1480  if( convert_8_to_4 )
1482  else
1483  return cpDecodedStrips;
1484  case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,F,F):
1485  case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,F,T):
1486  return cpContig2SeparateByRow;
1487  case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,F,F):
1488  case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,F,T):
1489  return cpSeparate2ContigByRow;
1490  case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,F,F):
1491  case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,F,T):
1492  return cpSeparate2SeparateByRow;
1493  }
1494 #undef pack
1495 #undef F
1496 #undef T
1497  fprintf(stderr, "tiffcp: %s: Don't know how to copy/convert image.\n",
1498  TIFFFileName(in));
1499  return (NULL);
1500 }

References config, convert_8_to_4, cpContig2ContigByRow(), cpContig2ContigByRow_8_to_4(), cpContig2SeparateByRow(), cpContigStrips2ContigTiles(), cpContigStrips2SeparateTiles(), cpContigTiles2ContigStrips(), cpContigTiles2ContigTiles(), cpContigTiles2SeparateStrips(), cpContigTiles2SeparateTiles(), cpDecodedStrips(), cpSeparate2ContigByRow(), cpSeparate2SeparateByRow(), cpSeparateStrips2ContigTiles(), cpSeparateStrips2SeparateTiles(), cpSeparateTiles2ContigStrips(), cpSeparateTiles2ContigTiles(), cpSeparateTiles2SeparateStrips(), cpSeparateTiles2SeparateTiles(), F, NULL, pack, rowsperstrip, T, tilelength, and tilewidth.

Referenced by tiffcp().

◆ processCompressOptions()

static int processCompressOptions ( char *  opt)
static

Definition at line 396 of file geotifcp.c.

397 {
398  if (streq(opt, "none"))
399  defcompression = COMPRESSION_NONE;
400  else if (streq(opt, "packbits"))
401  defcompression = COMPRESSION_PACKBITS;
402  else if (strneq(opt, "jpeg", 4)) {
403  char* cp = strchr(opt, ':');
404  if (cp && isdigit(cp[1]))
405  quality = atoi(cp+1);
406  if (cp && strchr(cp, 'r'))
407  jpegcolormode = JPEGCOLORMODE_RAW;
408  defcompression = COMPRESSION_JPEG;
409  } else if (strneq(opt, "g3", 2)) {
410  processG3Options(opt);
411  defcompression = COMPRESSION_CCITTFAX3;
412  } else if (streq(opt, "g4"))
413  defcompression = COMPRESSION_CCITTFAX4;
414  else if (strneq(opt, "lzw", 3)) {
415  char* cp = strchr(opt, ':');
416  if (cp)
417  defpredictor = atoi(cp+1);
418  defcompression = COMPRESSION_LZW;
419  } else if (strneq(opt, "zip", 3)) {
420  char* cp = strchr(opt, ':');
421  if (cp)
422  defpredictor = atoi(cp+1);
423  defcompression = COMPRESSION_DEFLATE;
424  } else
425  return (0);
426  return (1);
427 }

References defcompression, defpredictor, jpegcolormode, processG3Options(), quality, streq, and strneq.

Referenced by main().

◆ processG3Options()

static void processG3Options ( char *  cp)
static

Definition at line 376 of file geotifcp.c.

377 {
378  if( (cp = strchr(cp, ':')) != NULL ) {
379  if (defg3opts == (uint32) -1)
380  defg3opts = 0;
381  do {
382  cp++;
383  if (strneq(cp, "1d", 2))
384  defg3opts &= ~GROUP3OPT_2DENCODING;
385  else if (strneq(cp, "2d", 2))
386  defg3opts |= GROUP3OPT_2DENCODING;
387  else if (strneq(cp, "fill", 4))
388  defg3opts |= GROUP3OPT_FILLBITS;
389  else
390  usage();
391  } while( (cp = strchr(cp, ':')) != NULL );
392  }
393 }

References defg3opts, NULL, strneq, and usage().

Referenced by processCompressOptions().

◆ readContigStripsIntoBuffer()

static void readContigStripsIntoBuffer ( TIFF *  in,
unsigned char *  buf,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 991 of file geotifcp.c.

992 {
993  tsize_t scanlinesize = TIFFScanlineSize(in);
994  unsigned char *bufp = buf;
995  uint32 row;
996 
997  (void) imagewidth; (void) spp;
998  for (row = 0; row < imagelength; row++) {
999  if (TIFFReadScanline(in, bufp, row, 0) < 0 && !ignore)
1000  break;
1001  bufp += scanlinesize;
1002  }
1003 }

References ignore.

Referenced by cpContigStrips2ContigTiles(), and cpContigStrips2SeparateTiles().

◆ readContigTilesIntoBuffer()

static void readContigTilesIntoBuffer ( TIFF *  in,
unsigned char *  buf,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 1035 of file geotifcp.c.

1036 {
1037  unsigned char* tilebuf = (unsigned char *) _TIFFmalloc(TIFFTileSize(in));
1038  uint32 imagew = TIFFScanlineSize(in);
1039  uint32 tilew = TIFFTileRowSize(in);
1040  int iskew = imagew - tilew;
1041  unsigned char *bufp = buf;
1042  uint32 tw, tl;
1043  uint32 row;
1044 
1045  (void) spp;
1046  if (tilebuf == 0)
1047  return;
1048  (void) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw);
1049  (void) TIFFGetField(in, TIFFTAG_TILELENGTH, &tl);
1050  for (row = 0; row < imagelength; row += tl) {
1051  uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl;
1052  uint32 colb = 0;
1053  uint32 col;
1054 
1055  for (col = 0; col < imagewidth; col += tw) {
1056  if (TIFFReadTile(in, tilebuf, col, row, 0, 0) < 0 &&
1057  !ignore)
1058  goto done;
1059  if (colb + tilew > imagew) {
1060  uint32 width = imagew - colb;
1061  uint32 oskew = tilew - width;
1062  cpStripToTile(bufp + colb,
1063  tilebuf, nrow, width,
1064  oskew + iskew, oskew);
1065  } else
1066  cpStripToTile(bufp + colb,
1067  tilebuf, nrow, tilew,
1068  iskew, 0);
1069  colb += tilew;
1070  }
1071  bufp += imagew * nrow;
1072  }
1073 done:
1074  _TIFFfree(tilebuf);
1075 }

References cpStripToTile(), and ignore.

Referenced by cpContigTiles2ContigStrips(), cpContigTiles2ContigTiles(), cpContigTiles2SeparateStrips(), and cpContigTiles2SeparateTiles().

◆ readSeparateStripsIntoBuffer()

static void readSeparateStripsIntoBuffer ( TIFF *  in,
unsigned char *  buf,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 1005 of file geotifcp.c.

1006 {
1007  tsize_t scanlinesize = TIFFScanlineSize(in);
1008  unsigned char* scanline = (unsigned char *) _TIFFmalloc(scanlinesize);
1009 
1010  (void) imagewidth;
1011  if (scanline) {
1012  unsigned char *bufp = buf;
1013  uint32 row;
1014  tsample_t s;
1015 
1016  for (row = 0; row < imagelength; row++) {
1017  /* merge channels */
1018  for (s = 0; s < spp; s++) {
1019  unsigned char* sp = scanline;
1020  unsigned char* bp = bufp + s;
1021  tsize_t n = scanlinesize;
1022 
1023  if (TIFFReadScanline(in, sp, row, s) < 0 && !ignore)
1024  goto done;
1025  while (n-- > 0)
1026  *bp = *bufp++, bp += spp;
1027  }
1028  bufp += scanlinesize;
1029  }
1030 done:
1031  _TIFFfree(scanline);
1032  }
1033 }

References ignore.

Referenced by cpSeparateStrips2ContigTiles(), and cpSeparateStrips2SeparateTiles().

◆ readSeparateTilesIntoBuffer()

static void readSeparateTilesIntoBuffer ( TIFF *  in,
unsigned char *  buf,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 1077 of file geotifcp.c.

1078 {
1079  uint32 imagew = TIFFScanlineSize(in);
1080  uint32 tilew = TIFFTileRowSize(in);
1081  int iskew = imagew - tilew;
1082  unsigned char* tilebuf = (unsigned char *) _TIFFmalloc(TIFFTileSize(in));
1083  unsigned char *bufp = buf;
1084  uint32 tw, tl;
1085  uint32 row;
1086 
1087  if (tilebuf == 0)
1088  return;
1089  (void) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw);
1090  (void) TIFFGetField(in, TIFFTAG_TILELENGTH, &tl);
1091  for (row = 0; row < imagelength; row += tl) {
1092  uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl;
1093  uint32 colb = 0;
1094  uint32 col;
1095 
1096  for (col = 0; col < imagewidth; col += tw) {
1097  tsample_t s;
1098 
1099  for (s = 0; s < spp; s++) {
1100  if (TIFFReadTile(in, tilebuf, col, row, 0, s) < 0 && !ignore)
1101  goto done;
1102  /*
1103  * Tile is clipped horizontally. Calculate
1104  * visible portion and skewing factors.
1105  */
1106  if (colb + tilew > imagew) {
1107  uint32 width = imagew - colb;
1108  int oskew = tilew - width;
1109  cpSeparateBufToContigBuf(bufp+colb+s,
1110  tilebuf, nrow, width,
1111  oskew + iskew, oskew, spp);
1112  } else
1113  cpSeparateBufToContigBuf(bufp+colb+s,
1114  tilebuf, nrow, tw,
1115  iskew, 0, spp);
1116  }
1117  colb += tilew;
1118  }
1119  bufp += imagew * nrow;
1120  }
1121 done:
1122  _TIFFfree(tilebuf);
1123 }

References cpSeparateBufToContigBuf(), and ignore.

Referenced by cpSeparateTiles2ContigStrips(), cpSeparateTiles2ContigTiles(), cpSeparateTiles2SeparateStrips(), and cpSeparateTiles2SeparateTiles().

◆ SetVersionNumbers()

static void SetVersionNumbers ( GTIF gtif)
static

Definition at line 89 of file geotifcp.c.

90 {
91  if( forced_version )
92  {
94  }
95 }

References forced_version, GTIFSetVersionNumbers(), key_version, minor_revision, and version.

Referenced by CopyGeoTIFF(), and InstallGeoTIFF().

◆ tiffcp()

static int tiffcp ( TIFF *  in,
TIFF *  out 
)
static

Definition at line 622 of file geotifcp.c.

623 {
624  uint16 bitspersample = 0, samplesperpixel, shortv;
625  copyFunc cf;
626  uint32 w, l;
627 
628  CopyField(TIFFTAG_IMAGEWIDTH, w);
629  CopyField(TIFFTAG_IMAGELENGTH, l);
630  if( convert_8_to_4 )
631  {
632  TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 4);
633  }
634  else
635  {
636  CopyField(TIFFTAG_BITSPERSAMPLE, bitspersample);
637  }
638  if (compression != (uint16)-1)
639  TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
640  else
641  CopyField(TIFFTAG_COMPRESSION, compression);
642  if (compression == COMPRESSION_JPEG && jpegcolormode == JPEGCOLORMODE_RGB)
643  TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR);
644  else
645  CopyField(TIFFTAG_PHOTOMETRIC, shortv);
646  if (fillorder != 0)
647  TIFFSetField(out, TIFFTAG_FILLORDER, fillorder);
648  else
649  CopyField(TIFFTAG_FILLORDER, shortv);
650  CopyField(TIFFTAG_SAMPLESPERPIXEL, samplesperpixel);
651  /*
652  * Choose tiles/strip for the output image according to
653  * the command line arguments (-tiles, -strips) and the
654  * structure of the input image.
655  */
656  if (outtiled == -1)
657  outtiled = TIFFIsTiled(in);
658  if (outtiled) {
659  /*
660  * Setup output file's tile width&height. If either
661  * is not specified, use either the value from the
662  * input image or, if nothing is defined, use the
663  * library default.
664  */
665  if (tilewidth == (uint32) -1)
666  TIFFGetField(in, TIFFTAG_TILEWIDTH, &tilewidth);
667  if (tilelength == (uint32) -1)
668  TIFFGetField(in, TIFFTAG_TILELENGTH, &tilelength);
669  TIFFDefaultTileSize(out, &tilewidth, &tilelength);
670  TIFFSetField(out, TIFFTAG_TILEWIDTH, tilewidth);
671  TIFFSetField(out, TIFFTAG_TILELENGTH, tilelength);
672  } else {
673  /*
674  * RowsPerStrip is left unspecified: use either the
675  * value from the input image or, if nothing is defined,
676  * use the library default.
677  */
678  if (rowsperstrip == (uint32) -1)
679  TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
680  rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip);
681  TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
682  }
683  if (config != (uint16) -1)
684  TIFFSetField(out, TIFFTAG_PLANARCONFIG, config);
685  else
686  CopyField(TIFFTAG_PLANARCONFIG, config);
687  if (g3opts != (uint32) -1)
688  TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, g3opts);
689  else
690  CopyField(TIFFTAG_GROUP3OPTIONS, g3opts);
691  if (samplesperpixel <= 4) {
692  uint16 *tr, *tg, *tb, *ta;
693  CopyField4(TIFFTAG_TRANSFERFUNCTION, tr, tg, tb, ta);
694  }
695  { uint16 *red, *green, *blue;
696  if (TIFFGetField(in, TIFFTAG_COLORMAP, &red, &green, &blue)) {
697  CheckAndCorrectColormap(in, 1<<bitspersample, red, green, blue);
698  TIFFSetField(out, TIFFTAG_COLORMAP, red, green, blue);
699  }
700  }
701 /* SMinSampleValue & SMaxSampleValue */
702  switch (compression) {
703  case COMPRESSION_JPEG:
704  TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality);
705  TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode);
706  break;
707  case COMPRESSION_LZW:
708  case COMPRESSION_DEFLATE:
709  if (predictor != (uint16)-1)
710  TIFFSetField(out, TIFFTAG_PREDICTOR, predictor);
711  else
712  CopyField(TIFFTAG_PREDICTOR, predictor);
713  break;
714  }
715  cpOtherTags(in, out);
716 
717  if (geofile || proj4_string )
718  InstallGeoTIFF(out);
719  else
720  CopyGeoTIFF(in,out);
721 
722  if( worldfile )
723  ApplyWorldFile( worldfile, out);
724 
725  cf = pickCopyFunc(in, out, bitspersample, samplesperpixel);
726  return (cf ? (*cf)(in, out, l, w, samplesperpixel) : FALSE);
727 }

References ApplyWorldFile(), CheckAndCorrectColormap(), compression, config, convert_8_to_4, CopyField, CopyField4, CopyGeoTIFF(), cpOtherTags(), FALSE, fillorder, g3opts, geofile, InstallGeoTIFF(), jpegcolormode, outtiled, pickCopyFunc(), predictor, proj4_string, quality, rowsperstrip, tilelength, tilewidth, and worldfile.

Referenced by main().

◆ usage()

static void usage ( void  )
static

Definition at line 479 of file geotifcp.c.

480 {
481  char buf[BUFSIZ];
482  int i;
483 
484  setbuf(stderr, buf);
485  for (i = 0; stuff[i] != NULL; i++)
486  fprintf(stderr, "%s\n", stuff[i]);
487  exit(-1);
488 }

References NULL, and stuff.

Referenced by main(), and processG3Options().

◆ writeBufferToContigStrips()

static int writeBufferToContigStrips ( TIFF *  out,
unsigned char *  buf,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 1125 of file geotifcp.c.

1126 {
1127  tsize_t scanline = TIFFScanlineSize(out);
1128  uint32 row;
1129 
1130  (void) imagewidth; (void) spp;
1131  for (row = 0; row < imagelength; row++) {
1132  if (TIFFWriteScanline(out, buf, row, 0) < 0)
1133  return (FALSE);
1134  buf += scanline;
1135  }
1136  return (TRUE);
1137 }

References FALSE, and TRUE.

Referenced by cpContigTiles2ContigStrips(), and cpSeparateTiles2ContigStrips().

◆ writeBufferToContigTiles()

static int writeBufferToContigTiles ( TIFF *  out,
unsigned char *  buf,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 1166 of file geotifcp.c.

1167 {
1168  uint32 imagew = TIFFScanlineSize(out);
1169  uint32 tilew = TIFFTileRowSize(out);
1170  int iskew = imagew - tilew;
1171  unsigned char* obuf = (unsigned char *) _TIFFmalloc(TIFFTileSize(out));
1172  unsigned char* bufp = buf;
1173  uint32 tl, tw;
1174  uint32 row;
1175 
1176  (void) spp;
1177  if (obuf == NULL)
1178  return (FALSE);
1179  (void) TIFFGetField(out, TIFFTAG_TILELENGTH, &tl);
1180  (void) TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw);
1181  for (row = 0; row < imagelength; row += tilelength) {
1182  uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl;
1183  uint32 colb = 0;
1184  uint32 col;
1185 
1186  for (col = 0; col < imagewidth; col += tw) {
1187  /*
1188  * Tile is clipped horizontally. Calculate
1189  * visible portion and skewing factors.
1190  */
1191  if (colb + tilew > imagew) {
1192  uint32 width = imagew - colb;
1193  int oskew = tilew - width;
1194  cpStripToTile(obuf, bufp + colb, nrow, width,
1195  oskew, oskew + iskew);
1196  } else
1197  cpStripToTile(obuf, bufp + colb, nrow, tilew,
1198  0, iskew);
1199  if (TIFFWriteTile(out, obuf, col, row, 0, 0) < 0) {
1200  _TIFFfree(obuf);
1201  return (FALSE);
1202  }
1203  colb += tilew;
1204  }
1205  bufp += nrow * imagew;
1206  }
1207  _TIFFfree(obuf);
1208  return (TRUE);
1209 }

References cpStripToTile(), FALSE, NULL, tilelength, and TRUE.

Referenced by cpContigStrips2ContigTiles(), cpContigTiles2ContigTiles(), cpSeparateStrips2ContigTiles(), and cpSeparateTiles2ContigTiles().

◆ writeBufferToSeparateStrips()

static int writeBufferToSeparateStrips ( TIFF *  out,
unsigned char *  buf,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 1139 of file geotifcp.c.

1140 {
1141  unsigned char *obuf = (unsigned char *) _TIFFmalloc(TIFFScanlineSize(out));
1142  tsample_t s;
1143 
1144  if (obuf == NULL)
1145  return (0);
1146  for (s = 0; s < spp; s++) {
1147  uint32 row;
1148  for (row = 0; row < imagelength; row++) {
1149  unsigned char* inp = buf + s;
1150  unsigned char* outp = obuf;
1151  uint32 n = imagewidth;
1152 
1153  while (n-- > 0)
1154  *outp++ = *inp, inp += spp;
1155  if (TIFFWriteScanline(out, obuf, row, s) < 0) {
1156  _TIFFfree(obuf);
1157  return (FALSE);
1158  }
1159  }
1160  }
1161  _TIFFfree(obuf);
1162  return (TRUE);
1163 
1164 }

References FALSE, NULL, and TRUE.

Referenced by cpContigTiles2SeparateStrips(), and cpSeparateTiles2SeparateStrips().

◆ writeBufferToSeparateTiles()

static int writeBufferToSeparateTiles ( TIFF *  out,
unsigned char *  buf,
uint32  imagelength,
uint32  imagewidth,
tsample_t  spp 
)
static

Definition at line 1211 of file geotifcp.c.

1212 {
1213  uint32 imagew = TIFFScanlineSize(out);
1214  tsize_t tilew = TIFFTileRowSize(out);
1215  int iskew = imagew - tilew;
1216  unsigned char *obuf = (unsigned char*) _TIFFmalloc(TIFFTileSize(out));
1217  unsigned char *bufp = buf;
1218  uint32 tl, tw;
1219  uint32 row;
1220 
1221  if (obuf == NULL)
1222  return (FALSE);
1223  (void) TIFFGetField(out, TIFFTAG_TILELENGTH, &tl);
1224  (void) TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw);
1225  for (row = 0; row < imagelength; row += tl) {
1226  uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl;
1227  uint32 colb = 0;
1228  uint32 col;
1229 
1230  for (col = 0; col < imagewidth; col += tw) {
1231  tsample_t s;
1232  for (s = 0; s < spp; s++) {
1233  /*
1234  * Tile is clipped horizontally. Calculate
1235  * visible portion and skewing factors.
1236  */
1237  if (colb + tilew > imagew) {
1238  uint32 width = imagew - colb;
1239  int oskew = tilew - width;
1240 
1242  bufp + colb + s,
1243  nrow, width,
1244  oskew/spp, oskew + imagew, spp);
1245  } else
1247  bufp + colb + s,
1248  nrow, tilewidth,
1249  0, iskew, spp);
1250  if (TIFFWriteTile(out, obuf, col, row, 0, s) < 0) {
1251  _TIFFfree(obuf);
1252  return (FALSE);
1253  }
1254  }
1255  colb += tilew;
1256  }
1257  bufp += nrow * imagew;
1258  }
1259  _TIFFfree(obuf);
1260  return (TRUE);
1261 }

References cpContigBufToSeparateBuf(), FALSE, NULL, tilewidth, and TRUE.

Referenced by cpContigStrips2SeparateTiles(), cpContigTiles2SeparateTiles(), cpSeparateStrips2SeparateTiles(), and cpSeparateTiles2SeparateTiles().

Variable Documentation

◆ compression

uint16 compression
static

Definition at line 47 of file geotifcp.c.

Referenced by main(), and tiffcp().

◆ config

uint16 config
static

Definition at line 46 of file geotifcp.c.

Referenced by main(), pickCopyFunc(), and tiffcp().

◆ convert_8_to_4

int convert_8_to_4 = 0
static

Definition at line 44 of file geotifcp.c.

Referenced by main(), pickCopyFunc(), and tiffcp().

◆ defcompression

uint16 defcompression = (uint16) -1
static

Definition at line 56 of file geotifcp.c.

Referenced by main(), and processCompressOptions().

◆ defg3opts

uint32 defg3opts = (uint32) -1
static

Definition at line 53 of file geotifcp.c.

Referenced by main(), and processG3Options().

◆ defpredictor

uint16 defpredictor = (uint16) -1
static

Definition at line 57 of file geotifcp.c.

Referenced by main(), and processCompressOptions().

◆ fillorder

uint16 fillorder
static

Definition at line 49 of file geotifcp.c.

Referenced by main(), and tiffcp().

◆ forced_version

int forced_version = 0
static

Definition at line 67 of file geotifcp.c.

Referenced by parseVersion(), and SetVersionNumbers().

◆ g3opts

uint32 g3opts
static

Definition at line 51 of file geotifcp.c.

Referenced by main(), and tiffcp().

◆ geofile

char* geofile =(char *)0
static

Definition at line 58 of file geotifcp.c.

Referenced by InstallGeoTIFF(), main(), and tiffcp().

◆ ignore

◆ jpegcolormode

int jpegcolormode = JPEGCOLORMODE_RGB
static

Definition at line 55 of file geotifcp.c.

Referenced by processCompressOptions(), and tiffcp().

◆ key_version

unsigned short key_version = 0
static

Definition at line 69 of file geotifcp.c.

Referenced by parseVersion(), and SetVersionNumbers().

◆ minor_revision

unsigned short minor_revision = 0
static

Definition at line 70 of file geotifcp.c.

Referenced by GTIFSetVersionNumbers(), parseVersion(), and SetVersionNumbers().

◆ outtiled

int outtiled = -1
static

Definition at line 41 of file geotifcp.c.

Referenced by main(), and tiffcp().

◆ predictor

uint16 predictor
static

Definition at line 48 of file geotifcp.c.

Referenced by main(), and tiffcp().

◆ proj4_string

char* proj4_string = (char *) 0
static

Definition at line 59 of file geotifcp.c.

Referenced by InstallGeoTIFF(), main(), and tiffcp().

◆ quality

int quality = 75
static

Definition at line 54 of file geotifcp.c.

Referenced by processCompressOptions(), and tiffcp().

◆ rowsperstrip

uint32 rowsperstrip
static

Definition at line 50 of file geotifcp.c.

Referenced by cpDecodedStrips(), main(), pickCopyFunc(), and tiffcp().

◆ stuff

char* stuff[]

Definition at line 429 of file geotifcp.c.

Referenced by usage().

◆ tags

struct cpTag tags[]
static

Referenced by cpOtherTags().

◆ tilelength

uint32 tilelength
static

Definition at line 43 of file geotifcp.c.

Referenced by main(), pickCopyFunc(), tiffcp(), and writeBufferToContigTiles().

◆ tilewidth

uint32 tilewidth
static

Definition at line 42 of file geotifcp.c.

Referenced by main(), pickCopyFunc(), tiffcp(), and writeBufferToSeparateTiles().

◆ version

unsigned short version = 0
static

◆ worldfile

char* worldfile =(char *)0
static

Definition at line 60 of file geotifcp.c.

Referenced by main(), and tiffcp().

predictor
static uint16 predictor
Definition: geotifcp.c:48
pack
#define pack(a, b, c, d, e)
strneq
#define strneq(a, b, n)
Definition: geotifcp.c:34
readContigStripsIntoBuffer
static void readContigStripsIntoBuffer(TIFF *in, unsigned char *buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:991
CopyField4
#define CopyField4(tag, v1, v2, v3, v4)
Definition: geotifcp.c:514
cpSeparateTiles2ContigStrips
static int cpSeparateTiles2ContigStrips(TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:1376
geofile
static char * geofile
Definition: geotifcp.c:58
processG3Options
static void processG3Options(char *cp)
Definition: geotifcp.c:376
cpContigTiles2ContigStrips
static int cpContigTiles2ContigStrips(TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:1354
FLAG_FILE_MODIFIED
@ FLAG_FILE_MODIFIED
Definition: geo_keyp.h:121
getopt
int getopt()
GTIFF_TIEPOINTS
#define GTIFF_TIEPOINTS
Definition: geo_tiffp.h:73
gtiff::gt_tif
tiff_t * gt_tif
Definition: geo_keyp.h:91
cpSeparate2ContigByRow
static int cpSeparate2ContigByRow(TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:903
CheckAndCorrectColormap
static void CheckAndCorrectColormap(TIFF *tif, int n, uint16 *r, uint16 *g, uint16 *b)
Definition: geotifcp.c:491
writeBufferToSeparateStrips
static int writeBufferToSeparateStrips(TIFF *out, unsigned char *buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:1139
stuff
char * stuff[]
Definition: geotifcp.c:429
cpContig2ContigByRow
static int cpContig2ContigByRow(TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:749
cpSeparateTiles2SeparateTiles
static int cpSeparateTiles2SeparateTiles(TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:1343
CVT
#define CVT(x)
GTIFSetFromProj4
int GTIFSetFromProj4(GTIF *gtif, const char *proj4)
Definition: geotiff_proj4.c:213
GTIFNew
GTIF * GTIFNew(void *tif)
Public Routines.
Definition: geo_new.c:71
cpSeparateBufToContigBuf
static void cpSeparateBufToContigBuf(unsigned char *out, unsigned char *in, uint32 rows, uint32 cols, int outskew, int inskew, tsample_t spp)
Definition: geotifcp.c:964
proj4_string
static char * proj4_string
Definition: geotifcp.c:59
CopyGeoTIFF
static void CopyGeoTIFF(TIFF *in, TIFF *out)
Definition: geotifcp.c:344
InstallGeoTIFF
static void InstallGeoTIFF(TIFF *out)
Definition: geotifcp.c:302
cpDecodedStrips
static int cpDecodedStrips(TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:811
defcompression
static uint16 defcompression
Definition: geotifcp.c:56
cpContig2ContigByRow_8_to_4
static int cpContig2ContigByRow_8_to_4(TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:772
GTIFF_PIXELSCALE
#define GTIFF_PIXELSCALE
Definition: geo_tiffp.h:70
version
static unsigned short version
Definition: geotifcp.c:68
CopyField
#define CopyField(tag, v)
Definition: geotifcp.c:508
convert_8_to_4
static int convert_8_to_4
Definition: geotifcp.c:44
cpContigTiles2ContigTiles
static int cpContigTiles2ContigTiles(TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:1310
key_version
static unsigned short key_version
Definition: geotifcp.c:69
writeBufferToContigStrips
static int writeBufferToContigStrips(TIFF *out, unsigned char *buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:1125
gtiff::gt_flags
int gt_flags
Definition: geo_keyp.h:93
FALSE
#define FALSE
Definition: geotifcp.c:37
GTIFFree
void GTIFFree(GTIF *gtif)
geo_free.c – Public routines for GEOTIFF GeoKey access.
Definition: geo_free.c:38
cpTag
Definition: geotifcp.c:517
readContigTilesIntoBuffer
static void readContigTilesIntoBuffer(TIFF *in, unsigned char *buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:1035
TIFFTAG_GEOTRANSMATRIX
#define TIFFTAG_GEOTRANSMATRIX
Definition: xtiffio.h:33
ignore
static int ignore
Definition: geotifcp.c:52
forced_version
static int forced_version
Definition: geotifcp.c:67
TRUE
#define TRUE
Definition: geotifcp.c:36
rowsperstrip
static uint32 rowsperstrip
Definition: geotifcp.c:50
GTIFImport
int GTIFImport(GTIF *gtif, GTIFReadMethod scan, void *aux)
Definition: geo_print.c:265
fillorder
static uint16 fillorder
Definition: geotifcp.c:49
tags
static struct cpTag tags[]
quality
static int quality
Definition: geotifcp.c:54
writeBufferToSeparateTiles
static int writeBufferToSeparateTiles(TIFF *out, unsigned char *buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:1211
readSeparateTilesIntoBuffer
static void readSeparateTilesIntoBuffer(TIFF *in, unsigned char *buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:1077
outtiled
static int outtiled
Definition: geotifcp.c:41
g3opts
static uint32 g3opts
Definition: geotifcp.c:51
CopyField2
#define CopyField2(tag, v1, v2)
Definition: geotifcp.c:510
F
#define F
defpredictor
static uint16 defpredictor
Definition: geotifcp.c:57
usage
static void usage(void)
Definition: geotifcp.c:479
cpTag::count
uint16 count
Definition: geotifcp.c:519
defg3opts
static uint32 defg3opts
Definition: geotifcp.c:53
cpOtherTags
static void cpOtherTags(TIFF *in, TIFF *out)
Definition: geotifcp.c:565
SetVersionNumbers
static void SetVersionNumbers(GTIF *gtif)
Definition: geotifcp.c:89
jpegcolormode
static int jpegcolormode
Definition: geotifcp.c:55
worldfile
static char * worldfile
Definition: geotifcp.c:60
cpSeparateTiles2SeparateStrips
static int cpSeparateTiles2SeparateStrips(TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:1387
cpContigStrips2SeparateTiles
static int cpContigStrips2SeparateTiles(TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:1277
writeBufferToContigTiles
static int writeBufferToContigTiles(TIFF *out, unsigned char *buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:1166
ABS
#define ABS(x)
Definition: cpl_serv.h:95
cpContig2SeparateByRow
static int cpContig2SeparateByRow(TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:866
cpSeparateTiles2ContigTiles
static int cpSeparateTiles2ContigTiles(TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:1332
cpSeparate2SeparateByRow
static int cpSeparate2SeparateByRow(TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:840
optind
int optind
Definition: getopt.c:45
compression
static uint16 compression
Definition: geotifcp.c:47
cpTag::tag
uint16 tag
Definition: geotifcp.c:518
gtiff
Definition: geo_keyp.h:90
pickCopyFunc
static copyFunc pickCopyFunc(TIFF *, TIFF *, uint16, uint16)
Definition: geotifcp.c:1399
readSeparateStripsIntoBuffer
static void readSeparateStripsIntoBuffer(TIFF *in, unsigned char *buf, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:1005
ApplyWorldFile
static void ApplyWorldFile(const char *worldfile, TIFF *out)
Definition: geotifcp.c:235
cpContigStrips2ContigTiles
static int cpContigStrips2ContigTiles(TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:1266
processCompressOptions
static int processCompressOptions(char *)
Definition: geotifcp.c:396
tilelength
static uint32 tilelength
Definition: geotifcp.c:43
tiffcp
static int tiffcp(TIFF *, TIFF *)
Definition: geotifcp.c:622
cpTag::type
TIFFDataType type
Definition: geotifcp.c:520
NTAGS
#define NTAGS
Definition: geotifcp.c:562
cpSeparateStrips2ContigTiles
static int cpSeparateStrips2ContigTiles(TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:1288
TIFFClose
#define TIFFClose
Definition: geotifcp.c:27
NULL
#define NULL
Definition: cpl_serv.h:74
optarg
char * optarg
Definition: getopt.c:47
minor_revision
static unsigned short minor_revision
Definition: geotifcp.c:70
streq
#define streq(a, b)
Definition: geotifcp.c:33
cpSeparateStrips2SeparateTiles
static int cpSeparateStrips2SeparateTiles(TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:1299
parseVersion
static int parseVersion(const char *str)
Definition: geotifcp.c:72
cpContigBufToSeparateBuf
static void cpContigBufToSeparateBuf(unsigned char *out, unsigned char *in, uint32 rows, uint32 cols, int outskew, int inskew, tsample_t spp)
Definition: geotifcp.c:951
tilewidth
static uint32 tilewidth
Definition: geotifcp.c:42
cpImage
static int cpImage(TIFF *in, TIFF *out, readFunc fin, writeFunc fout, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:977
TIFFOpen
#define TIFFOpen
Definition: geotifcp.c:26
cpContigTiles2SeparateStrips
static int cpContigTiles2SeparateStrips(TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:1365
GTIFF_TRANSMATRIX
#define GTIFF_TRANSMATRIX
Definition: geo_tiffp.h:71
T
#define T
cpStripToTile
static void cpStripToTile(unsigned char *out, unsigned char *in, uint32 rows, uint32 cols, int outskew, int inskew)
Definition: geotifcp.c:938
config
static uint16 config
Definition: geotifcp.c:46
GTIFWriteKeys
int GTIFWriteKeys(GTIF *gt)
This function flushes all the GeoTIFF keys that have been set with the GTIFKeySet() function into the...
Definition: geo_write.c:34
cpContigTiles2SeparateTiles
static int cpContigTiles2SeparateTiles(TIFF *in, TIFF *out, uint32 imagelength, uint32 imagewidth, tsample_t spp)
Definition: geotifcp.c:1321
copyFunc
int(* copyFunc)(TIFF *in, TIFF *out, uint32 l, uint32 w, uint16 samplesperpixel)
Definition: geotifcp.c:618
GTIFSetVersionNumbers
int GTIFSetVersionNumbers(GTIF *gtif, unsigned short version, unsigned short key_revision, unsigned short minor_revision)
Definition: geo_set.c:205