diff options
author | joris <joris> | 2006-03-25 17:52:37 +0000 |
---|---|---|
committer | joris <joris> | 2006-03-25 17:52:37 +0000 |
commit | 01ad016740d2485b1fe26d99e8567ecdcff2839e (patch) | |
tree | 49fb6dd1214b25b29318630ddc1ccf8643460712 /contrib | |
parent | 3849f700bacde1df8971ea6fbe9c36dc74ae845d (diff) | |
download | libtiff-01ad016740d2485b1fe26d99e8567ecdcff2839e.tar.gz |
bugfix to correctly pass size of last truncated strip data to TIFFWriteEncodedStrip
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/addtiffo/tif_ovrcache.c | 137 |
1 files changed, 69 insertions, 68 deletions
diff --git a/contrib/addtiffo/tif_ovrcache.c b/contrib/addtiffo/tif_ovrcache.c index e203a173..ac1a3568 100644 --- a/contrib/addtiffo/tif_ovrcache.c +++ b/contrib/addtiffo/tif_ovrcache.c @@ -1,5 +1,5 @@ /****************************************************************************** - * $Id: tif_ovrcache.c,v 1.6 2005-12-21 12:23:13 joris Exp $ + * $Id: tif_ovrcache.c,v 1.7 2006-03-25 17:52:37 joris Exp $ * * Project: TIFF Overview Builder * Purpose: Library functions to maintain two rows of tiles or two strips @@ -137,7 +137,8 @@ static void TIFFWriteOvrRow( TIFFOvrCache * psCache ) int nRet, iTileX, iTileY = psCache->nBlockOffset; unsigned char *pabyData; uint32 nBaseDirOffset; - + uint32 RowsInStrip; + /* -------------------------------------------------------------------- */ /* If the output cache is multi-byte per sample, and the file */ /* being written to is of a different byte order than the current */ @@ -169,72 +170,72 @@ static void TIFFWriteOvrRow( TIFFOvrCache * psCache ) /* -------------------------------------------------------------------- */ /* Write blocks to TIFF file. */ /* -------------------------------------------------------------------- */ - for( iTileX = 0; iTileX < psCache->nBlocksPerRow; iTileX++ ) - { - int nTileID; - - if (psCache->nPlanarConfig == PLANARCONFIG_SEPARATE) - { - int iSample; - - for( iSample = 0; iSample < psCache->nSamples; iSample++ ) - { - pabyData = TIFFGetOvrBlock( psCache, iTileX, iTileY, iSample ); - - if( psCache->bTiled ) - { - nTileID = - TIFFComputeTile( psCache->hTIFF, - iTileX * psCache->nBlockXSize, - iTileY * psCache->nBlockYSize, - 0, (tsample_t) iSample ); - TIFFWriteEncodedTile( psCache->hTIFF, nTileID, - pabyData, - TIFFTileSize(psCache->hTIFF) ); - } - else - { - nTileID = - TIFFComputeStrip( psCache->hTIFF, - iTileY * psCache->nBlockYSize, - (tsample_t) iSample ); - - TIFFWriteEncodedStrip( psCache->hTIFF, nTileID, - pabyData, - TIFFStripSize(psCache->hTIFF) ); - } - } - - } - else - { - pabyData = TIFFGetOvrBlock( psCache, iTileX, iTileY, 0 ); - - if( psCache->bTiled ) - { - nTileID = - TIFFComputeTile( psCache->hTIFF, - iTileX * psCache->nBlockXSize, - iTileY * psCache->nBlockYSize, - 0, 0 ); - TIFFWriteEncodedTile( psCache->hTIFF, nTileID, - pabyData, - TIFFTileSize(psCache->hTIFF) ); - } - else - { - nTileID = - TIFFComputeStrip( psCache->hTIFF, - iTileY * psCache->nBlockYSize, - 0 ); - - TIFFWriteEncodedStrip( psCache->hTIFF, nTileID, - pabyData, - TIFFStripSize(psCache->hTIFF) ); - } - } - } - /* TODO: add checks on error status return of TIFFWriteEncodedTile and TIFFWriteEncodedStrip */ + for( iTileX = 0; iTileX < psCache->nBlocksPerRow; iTileX++ ) + { + int nTileID; + + if (psCache->nPlanarConfig == PLANARCONFIG_SEPARATE) + { + int iSample; + + for( iSample = 0; iSample < psCache->nSamples; iSample++ ) + { + pabyData = TIFFGetOvrBlock( psCache, iTileX, iTileY, iSample ); + + if( psCache->bTiled ) + { + nTileID = TIFFComputeTile( psCache->hTIFF, + iTileX * psCache->nBlockXSize, + iTileY * psCache->nBlockYSize, + 0, (tsample_t) iSample ); + TIFFWriteEncodedTile( psCache->hTIFF, nTileID, + pabyData, + TIFFTileSize(psCache->hTIFF) ); + } + else + { + nTileID = TIFFComputeStrip( psCache->hTIFF, + iTileY * psCache->nBlockYSize, + (tsample_t) iSample ); + RowsInStrip=psCache->nBlockYSize; + if ((iTileY+1)*psCache->nBlockYSize>psCache->nYSize) + RowsInStrip=psCache->nYSize-iTileY*psCache->nBlockYSize; + TIFFWriteEncodedStrip( psCache->hTIFF, nTileID, + pabyData, + TIFFVStripSize(psCache->hTIFF,RowsInStrip) ); + } + } + + } + else + { + pabyData = TIFFGetOvrBlock( psCache, iTileX, iTileY, 0 ); + + if( psCache->bTiled ) + { + nTileID = TIFFComputeTile( psCache->hTIFF, + iTileX * psCache->nBlockXSize, + iTileY * psCache->nBlockYSize, + 0, 0 ); + TIFFWriteEncodedTile( psCache->hTIFF, nTileID, + pabyData, + TIFFTileSize(psCache->hTIFF) ); + } + else + { + nTileID = TIFFComputeStrip( psCache->hTIFF, + iTileY * psCache->nBlockYSize, + 0 ); + RowsInStrip=psCache->nBlockYSize; + if ((iTileY+1)*psCache->nBlockYSize>psCache->nYSize) + RowsInStrip=psCache->nYSize-iTileY*psCache->nBlockYSize; + TIFFWriteEncodedStrip( psCache->hTIFF, nTileID, + pabyData, + TIFFVStripSize(psCache->hTIFF,RowsInStrip) ); + } + } + } + /* TODO: add checks on error status return of TIFFWriteEncodedTile and TIFFWriteEncodedStrip */ /* -------------------------------------------------------------------- */ /* Rotate buffers. */ |