X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8414a40c52191d4c7cfeea74df22d9d64cbec415..95316a3f245a4baf3046e97222660bed986153ed:/src/tiff/contrib/addtiffo/tif_ovrcache.c?ds=sidebyside diff --git a/src/tiff/contrib/addtiffo/tif_ovrcache.c b/src/tiff/contrib/addtiffo/tif_ovrcache.c index eb8607d96a..dac8e7c8da 100644 --- a/src/tiff/contrib/addtiffo/tif_ovrcache.c +++ b/src/tiff/contrib/addtiffo/tif_ovrcache.c @@ -40,11 +40,11 @@ /* existing TIFF directory. */ /************************************************************************/ -TIFFOvrCache *TIFFCreateOvrCache( TIFF *hTIFF, int nDirOffset ) +TIFFOvrCache *TIFFCreateOvrCache( TIFF *hTIFF, toff_t nDirOffset ) { TIFFOvrCache *psCache; - uint32 nBaseDirOffset; + toff_t nBaseDirOffset; psCache = (TIFFOvrCache *) _TIFFmalloc(sizeof(TIFFOvrCache)); psCache->nDirOffset = nDirOffset; @@ -136,8 +136,9 @@ static void TIFFWriteOvrRow( TIFFOvrCache * psCache ) { int nRet, iTileX, iTileY = psCache->nBlockOffset; unsigned char *pabyData; - uint32 nBaseDirOffset; - + toff_t 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. */ @@ -331,3 +332,10 @@ void TIFFDestroyOvrCache( TIFFOvrCache * psCache ) _TIFFfree( psCache->pabyRow2Blocks ); _TIFFfree( psCache ); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */