pass TIFF handle instead of filename to overview builder

This commit is contained in:
Frank Warmerdam 2000-01-28 15:36:38 +00:00
parent 164da391dd
commit aca9e32b0a
2 changed files with 25 additions and 20 deletions

View File

@ -1,5 +1,5 @@
/****************************************************************************** /******************************************************************************
* $Id: addtiffo.c,v 1.1 1999-08-17 01:47:59 warmerda Exp $ * $Id: addtiffo.c,v 1.2 2000-01-28 15:36:38 warmerda Exp $
* *
* Project: GeoTIFF Overview Builder * Project: GeoTIFF Overview Builder
* Purpose: Mainline for building overviews in a TIFF file. * Purpose: Mainline for building overviews in a TIFF file.
@ -28,7 +28,10 @@
****************************************************************************** ******************************************************************************
* *
* $Log: addtiffo.c,v $ * $Log: addtiffo.c,v $
* Revision 1.1 1999-08-17 01:47:59 warmerda * Revision 1.2 2000-01-28 15:36:38 warmerda
* pass TIFF handle instead of filename to overview builder
*
* Revision 1.1 1999/08/17 01:47:59 warmerda
* New * New
* *
* Revision 1.1 1999/03/12 17:46:32 warmerda * Revision 1.1 1999/03/12 17:46:32 warmerda
@ -45,7 +48,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "tiffio.h" #include "tiffio.h"
void TIFFBuildOverviews( const char *, int, int *, int ); void TIFFBuildOverviews( TIFF *, int, int *, int );
/************************************************************************/ /************************************************************************/
/* main() */ /* main() */
@ -57,6 +60,7 @@ int main( int argc, char ** argv )
int anOverviews[100]; int anOverviews[100];
int nOverviewCount = 0; int nOverviewCount = 0;
int bUseSubIFD = 0; int bUseSubIFD = 0;
TIFF *hTIFF;
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/* Usage: */ /* Usage: */
@ -102,7 +106,16 @@ int main( int argc, char ** argv )
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/* Build the overview. */ /* Build the overview. */
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
TIFFBuildOverviews( argv[1], nOverviewCount, anOverviews, bUseSubIFD ); hTIFF = TIFFOpen( argv[1], "r+" );
if( hTIFF == NULL )
{
fprintf( stderr, "TIFFOpen(%s) failed.\n", argv[1] );
exit( 1 );
}
TIFFBuildOverviews( hTIFF, nOverviewCount, anOverviews, bUseSubIFD );
TIFFClose( hTIFF );
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/* Optionally test for memory leaks. */ /* Optionally test for memory leaks. */

View File

@ -1,5 +1,5 @@
/****************************************************************************** /******************************************************************************
* $Id: tif_overview.c,v 1.1 2000-01-28 15:04:03 warmerda Exp $ * $Id: tif_overview.c,v 1.2 2000-01-28 15:36:38 warmerda Exp $
* *
* Project: TIFF Overview Builder * Project: TIFF Overview Builder
* Purpose: Library function for building overviews in a TIFF file. * Purpose: Library function for building overviews in a TIFF file.
@ -45,7 +45,10 @@
****************************************************************************** ******************************************************************************
* *
* $Log: tif_overview.c,v $ * $Log: tif_overview.c,v $
* Revision 1.1 2000-01-28 15:04:03 warmerda * Revision 1.2 2000-01-28 15:36:38 warmerda
* pass TIFF handle instead of filename to overview builder
*
* Revision 1.1 2000/01/28 15:04:03 warmerda
* New * New
* *
*/ */
@ -68,7 +71,7 @@
# define MAX(a,b) ((a>b) ? a : b) # define MAX(a,b) ((a>b) ? a : b)
#endif #endif
void TIFFBuildOverviews( const char *, int, int *, int ); void TIFFBuildOverviews( TIFF *, int, int *, int );
/************************************************************************/ /************************************************************************/
/* TIFF_WriteOverview() */ /* TIFF_WriteOverview() */
@ -316,8 +319,7 @@ void TIFF_ProcessFullResBlock( TIFF *hTIFF, int nPlanarConfig,
/* overviews. */ /* overviews. */
/************************************************************************/ /************************************************************************/
void TIFFBuildOverviews( const char * pszTIFFFilename, void TIFFBuildOverviews( TIFF *hTIFF, int nOverviews, int * panOvList,
int nOverviews, int * panOvList,
int bUseSubIFDs ) int bUseSubIFDs )
{ {
@ -327,20 +329,12 @@ void TIFFBuildOverviews( const char * pszTIFFFilename,
nPlanarConfig, nSampleFormat; nPlanarConfig, nSampleFormat;
int bTiled, nSXOff, nSYOff, i; int bTiled, nSXOff, nSYOff, i;
unsigned char *pabySrcTile; unsigned char *pabySrcTile;
TIFF *hTIFF;
uint16 *panRedMap, *panGreenMap, *panBlueMap; uint16 *panRedMap, *panGreenMap, *panBlueMap;
TIFFErrorHandler pfnWarning; TIFFErrorHandler pfnWarning;
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/* Get the base raster size. */ /* Get the base raster size. */
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
hTIFF = TIFFOpen( pszTIFFFilename, "r+" );
if( hTIFF == NULL )
{
fprintf( stderr, "TIFFOpen(%s) failed.\n", pszTIFFFilename );
exit( 1 );
}
TIFFGetField( hTIFF, TIFFTAG_IMAGEWIDTH, &nXSize ); TIFFGetField( hTIFF, TIFFTAG_IMAGEWIDTH, &nXSize );
TIFFGetField( hTIFF, TIFFTAG_IMAGELENGTH, &nYSize ); TIFFGetField( hTIFF, TIFFTAG_IMAGELENGTH, &nYSize );
@ -357,7 +351,7 @@ void TIFFBuildOverviews( const char * pszTIFFFilename,
TIFFError( "TIFFBuildOverviews", TIFFError( "TIFFBuildOverviews",
"File `%s' has samples of %d bits per sample. Sample\n" "File `%s' has samples of %d bits per sample. Sample\n"
"sizes of less than 8 bits per sample are not supported.\n", "sizes of less than 8 bits per sample are not supported.\n",
pszTIFFFilename, nBitsPerPixel ); TIFFFileName(hTIFF), nBitsPerPixel );
return; return;
} }
@ -491,7 +485,5 @@ void TIFFBuildOverviews( const char * pszTIFFFilename,
if( papoRawBIs != NULL ) if( papoRawBIs != NULL )
_TIFFfree( papoRawBIs ); _TIFFfree( papoRawBIs );
TIFFClose( hTIFF );
TIFFSetWarningHandler( pfnWarning ); TIFFSetWarningHandler( pfnWarning );
} }