diff --git a/contrib/addtiffo/tif_overview.c b/contrib/addtiffo/tif_overview.c index 83313abf..65f6e3b5 100644 --- a/contrib/addtiffo/tif_overview.c +++ b/contrib/addtiffo/tif_overview.c @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: tif_overview.c,v 1.6 2004-08-08 15:32:29 dron Exp $ + * tif_overview.c,v 1.9 2005/05/25 09:03:16 dron Exp * * Project: TIFF Overview Builder * Purpose: Library function for building overviews in a TIFF file. @@ -53,6 +53,10 @@ #include "tiffio.h" #include "tif_ovrcache.h" +#include "cpl_port.h" + +CPL_CVSID("tif_overview.c,v 1.2 2001/07/18 04:51:56 warmerda Exp"); + #ifndef FALSE # define FALSE 0 # define TRUE 1 @@ -76,7 +80,7 @@ void TIFFBuildOverviews( TIFF *, int, int *, int, const char *, /************************************************************************/ uint32 TIFF_WriteOverview( TIFF *hTIFF, int nXSize, int nYSize, - int nBitsPerPixel, int nSamples, + int nBitsPerPixel, int nPlanarConfig, int nSamples, int nBlockXSize, int nBlockYSize, int bTiled, int nCompressFlag, int nPhotometric, int nSampleFormat, @@ -101,7 +105,7 @@ uint32 TIFF_WriteOverview( TIFF *hTIFF, int nXSize, int nYSize, if( nSamples == 1 ) TIFFSetField( hTIFF, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG ); else - TIFFSetField( hTIFF, TIFFTAG_PLANARCONFIG, PLANARCONFIG_SEPARATE ); + TIFFSetField( hTIFF, TIFFTAG_PLANARCONFIG, nPlanarConfig ); TIFFSetField( hTIFF, TIFFTAG_BITSPERSAMPLE, nBitsPerPixel ); TIFFSetField( hTIFF, TIFFTAG_SAMPLESPERPIXEL, nSamples ); @@ -531,14 +535,15 @@ void TIFFBuildOverviews( TIFF *hTIFF, int nOverviews, int * panOvList, &panRedMap, &panGreenMap, &panBlueMap ) ) { uint16 *panRed2, *panGreen2, *panBlue2; + int nColorCount = 1 << nBitsPerPixel; - panRed2 = (uint16 *) _TIFFmalloc(2*256); - panGreen2 = (uint16 *) _TIFFmalloc(2*256); - panBlue2 = (uint16 *) _TIFFmalloc(2*256); + panRed2 = (uint16 *) _TIFFmalloc(2*nColorCount); + panGreen2 = (uint16 *) _TIFFmalloc(2*nColorCount); + panBlue2 = (uint16 *) _TIFFmalloc(2*nColorCount); - memcpy( panRed2, panRedMap, 512 ); - memcpy( panGreen2, panGreenMap, 512 ); - memcpy( panBlue2, panBlueMap, 512 ); + memcpy( panRed2, panRedMap, 2 * nColorCount ); + memcpy( panGreen2, panGreenMap, 2 * nColorCount ); + memcpy( panBlue2, panBlueMap, 2 * nColorCount ); panRedMap = panRed2; panGreenMap = panGreen2; @@ -575,8 +580,8 @@ void TIFFBuildOverviews( TIFF *hTIFF, int nOverviews, int * panOvList, } nDirOffset = TIFF_WriteOverview( hTIFF, nOXSize, nOYSize, - nBitsPerPixel, nSamples, - nOBlockXSize, nOBlockYSize, + nBitsPerPixel, nPlanarConfig, + nSamples, nOBlockXSize, nOBlockYSize, bTiled, nCompressFlag, nPhotometric, nSampleFormat, panRedMap, panGreenMap, panBlueMap, diff --git a/contrib/addtiffo/tif_ovrcache.h b/contrib/addtiffo/tif_ovrcache.h index 99961570..f0775cf9 100644 --- a/contrib/addtiffo/tif_ovrcache.h +++ b/contrib/addtiffo/tif_ovrcache.h @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: tif_ovrcache.h,v 1.1 2000-01-28 15:03:32 warmerda Exp $ + * tif_ovrcache.h,v 1.3 2005/05/25 09:03:16 dron Exp * * Project: TIFF Overview Builder * Purpose: Library functions to maintain two rows of tiles or two strips @@ -30,16 +30,17 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************** - * - * $Log: tif_ovrcache.h,v $ - * Revision 1.1 2000-01-28 15:03:32 warmerda - * New - * */ #ifndef TIF_OVRCACHE_H_INCLUDED #define TIF_OVRCACHE_H_INCLUDED +#include "tiffio.h" + +#if defined(__cplusplus) +extern "C" { +#endif + typedef struct { uint32 nXSize; @@ -68,5 +69,25 @@ TIFFOvrCache *TIFFCreateOvrCache( TIFF *hTIFF, int nDirOffset ); unsigned char *TIFFGetOvrBlock( TIFFOvrCache *, int, int, int ); void TIFFDestroyOvrCache( TIFFOvrCache * ); +void TIFFBuildOverviews( TIFF *, int, int *, int, const char *, + int (*)(double,void*), void * ); + +void TIFF_ProcessFullResBlock( TIFF *hTIFF, int nPlanarConfig, + int nOverviews, int * panOvList, + int nBitsPerPixel, + int nSamples, TIFFOvrCache ** papoRawBIs, + int nSXOff, int nSYOff, + unsigned char *pabySrcTile, + int nBlockXSize, int nBlockYSize, + int nSampleFormat, const char * pszResampling ); + +uint32 TIFF_WriteOverview( TIFF *, int, int, int, int, int, int, int, + int, int, int, int, unsigned short *, + unsigned short *, unsigned short *, int ); + +#if defined(__cplusplus) +} +#endif + #endif /* ndef TIF_OVRCACHE_H_INCLUDED */