From 64bd1138df5c3d7dd8b93907a6dc2d3a958362a4 Mon Sep 17 00:00:00 2001 From: Joris Van Damme Date: Sat, 25 Mar 2006 17:52:37 +0000 Subject: [PATCH] bugfix to correctly pass size of last truncated strip data to TIFFWriteEncodedStrip --- ChangeLog | 5 ++ contrib/addtiffo/tif_ovrcache.c | 127 ++++++++++++++++---------------- 2 files changed, 69 insertions(+), 63 deletions(-) diff --git a/ChangeLog b/ChangeLog index 78fa317e..c814eae2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-03-25 Joris Van Damme + + * contrib/addtiffo/tif_ovrcache.c: bugfix to correctly pass size + of last truncated strip data to TIFFWriteEncodedStrip + 2006-03-25 Joris Van Damme * libtiff/{tif_jpeg.c, tif_strip.c}: bugfix of tif_jpeg decode raw 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; + for( iTileX = 0; iTileX < psCache->nBlocksPerRow; iTileX++ ) + { + int nTileID; - if (psCache->nPlanarConfig == PLANARCONFIG_SEPARATE) - { - int iSample; + if (psCache->nPlanarConfig == PLANARCONFIG_SEPARATE) + { + int iSample; - for( iSample = 0; iSample < psCache->nSamples; iSample++ ) - { - pabyData = TIFFGetOvrBlock( psCache, iTileX, iTileY, 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 ); + 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) ); + } + } - TIFFWriteEncodedStrip( psCache->hTIFF, nTileID, - pabyData, - TIFFStripSize(psCache->hTIFF) ); - } - } + } + else + { + pabyData = TIFFGetOvrBlock( psCache, iTileX, iTileY, 0 ); - } - 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 */ + 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. */