Changeset 12338

Show
Ignore:
Timestamp:
10/05/07 22:02:08 (1 year ago)
Author:
warmerdam
Message:

add support for partial bottom tiles/strips (#1179)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.4/gdal/frmts/gtiff/geotiff.cpp

    r12001 r12338  
    388388         
    389389/* -------------------------------------------------------------------- */ 
     390/*      The bottom most partial tiles and strips are sometimes only     */ 
     391/*      partially encoded.  This code reduces the requested data so     */ 
     392/*      an error won't be reported in this case. (#1179)                */ 
     393/* -------------------------------------------------------------------- */ 
     394    int nBlockReqSize = nBlockBufSize; 
     395 
     396    if( (nBlockYOff+1) * nBlockYSize > nRasterYSize ) 
     397    { 
     398        nBlockReqSize = (nBlockBufSize / nBlockYSize)  
     399            * (nBlockYSize - (((nBlockYOff+1) * nBlockYSize) % nRasterYSize)); 
     400    } 
     401 
     402/* -------------------------------------------------------------------- */ 
    390403/*      Handle the case of a strip or tile that doesn't exist yet.      */ 
    391404/*      Just set to zeros and return.                                   */ 
     
    405418        || poGDS->nPlanarConfig == PLANARCONFIG_SEPARATE ) 
    406419    { 
     420        if( nBlockReqSize < nBlockBufSize ) 
     421            memset( pImage, 0, nBlockBufSize ); 
     422 
    407423        if( TIFFIsTiled( poGDS->hTIFF ) ) 
    408424        { 
    409425            if( TIFFReadEncodedTile( poGDS->hTIFF, nBlockId, pImage, 
    410                                      nBlockBufSize ) == -1 ) 
     426                                     nBlockReqSize ) == -1 ) 
    411427            { 
    412428                memset( pImage, 0, nBlockBufSize ); 
     
    420436        { 
    421437            if( TIFFReadEncodedStrip( poGDS->hTIFF, nBlockId, pImage, 
    422                                       nBlockBufSize ) == -1 ) 
     438                                      nBlockReqSize ) == -1 ) 
    423439            { 
    424440                memset( pImage, 0, nBlockBufSize ); 
     
    17441760     
    17451761/* -------------------------------------------------------------------- */ 
     1762/*      The bottom most partial tiles and strips are sometimes only     */ 
     1763/*      partially encoded.  This code reduces the requested data so     */ 
     1764/*      an error won't be reported in this case. (#1179)                */ 
     1765/* -------------------------------------------------------------------- */ 
     1766    int nBlockReqSize = nBlockBufSize; 
     1767    int nBlocksPerRow = (nRasterXSize + nBlockXSize - 1) / nBlockXSize; 
     1768    int nBlockYOff = (nBlockId % nBlocksPerBand) / nBlocksPerRow; 
     1769 
     1770    if( (int)((nBlockYOff+1) * nBlockYSize) > nRasterYSize ) 
     1771    { 
     1772        nBlockReqSize = (nBlockBufSize / nBlockYSize)  
     1773            * (nBlockYSize - (((nBlockYOff+1) * nBlockYSize) % nRasterYSize)); 
     1774        memset( pabyBlockBuf, 0, nBlockBufSize ); 
     1775    } 
     1776 
     1777/* -------------------------------------------------------------------- */ 
    17461778/*      If we don't have this block already loaded, and we know it      */ 
    17471779/*      doesn't yet exist on disk, just zero the memory buffer and      */ 
     
    17611793    { 
    17621794        if( TIFFReadEncodedTile(hTIFF, nBlockId, pabyBlockBuf, 
    1763                                 nBlockBufSize) == -1 ) 
     1795                                nBlockReqSize) == -1 ) 
    17641796        { 
    17651797            /* Once TIFFError() is properly hooked, this can go away */ 
     
    17751807    { 
    17761808        if( TIFFReadEncodedStrip(hTIFF, nBlockId, pabyBlockBuf, 
    1777                                  nBlockBufSize) == -1 ) 
     1809                                 nBlockReqSize) == -1 ) 
    17781810        { 
    17791811            /* Once TIFFError() is properly hooked, this can go away */