AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2002.08.22 22:17 "Problem Reading MultiPage TIFFs", by Steven Luke
2002.08.22 22:39 "RE: Problem Reading MultiPage TIFFs", by Rypysc, George
2002.08.30 19:04 "Re: Problem Reading MultiPage TIFFs", by Steven Luke
2002.08.30 20:05 "RE: Problem Reading MultiPage TIFFs", by Bostrup, Tore
2002.08.31 13:12 "Re: Problem Reading MultiPage TIFFs", by Steven Luke
2002.09.02 13:20 "Re: Problem Reading MultiPage TIFFs", by Antonio E. Scuri
2002.09.03 17:58 "RE: Problem Reading MultiPage TIFFs", by Frank Palmieri
2002.09.03 18:32 "Re: Problem Reading MultiPage TIFFs", by Frank Warmerdam
2002.09.05 04:50 "Re: Problem Reading MultiPage TIFFs", by Steven Luke

2002.09.03 18:32 "Re: Problem Reading MultiPage TIFFs", by Frank Warmerdam

Steven:

1) To access the offset and byte counts directly, there is no API or interface. You can access them by using the internal structures of the tiff library assuming that they get loaded into those structures. Here's a fragment that shows including the private header files and some code to use them:

#include "tiffiop.h" /* include private headers before public header
*/
#include "tif_dir.h"
#include "tiffio.h"

        *
        *
        *
TIFF* in;
TIFFDirectory *td;

in = TIFFOpen(argv[1], "w");
        *
        *
        *
td = &in->tif_dir;
printf("  %lu %s:\n", (long) td->td_nstrips,

       isTiled(out)? "Tiles": "Strips");
for (s = 0; s < td->td_nstrips; s++)
{
    printf(" %3lu: [%8lu, %8lu]\n",
           (u_long) s,
           (u_long) td->td_stripoffset[s],
           (u_long) td->td_stripbytecount[s]);
}

Frank,

In fact, it should be possible to read the stripoffsets, and stripbytecounts for the current directory using the TIFFTAG_STRIPBYTECOUNTS and TIFFTAG_STRIPOFFSETS values.

eg.

int GTiffDataset::IsBlockAvailable( int nBlockId )

{
     uint32 *panByteCounts = NULL;

     if( ( TIFFIsTiled( hTIFF )
           && TIFFGetField( hTIFF, TIFFTAG_TILEBYTECOUNTS, &panByteCounts ) )
         || ( !TIFFIsTiled( hTIFF )
           && TIFFGetField( hTIFF, TIFFTAG_STRIPBYTECOUNTS, &panByteCounts ) ) )
     {
         if( panByteCounts == NULL )
             return FALSE;
         else
             return panByteCounts[nBlockId] != 0;
     }
     else
         return FALSE;
}

This is preferable to the direct approach in that you can avoid including the private tiff include file (tiffiop.h), and avoid unnecessary dependencies on the internal of the tiff datastructures.

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent