- 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 */