2004.10.29 15:28 "[Tiff] libtiff in GDAL - append mode", by Julien Demaria

2004.10.29 15:28 "[Tiff] libtiff in GDAL - append mode", by Julien Demaria

Hi,

I try to create a multi-directory TIFF file with the libtiff embedded in GDAL, but this code which works well with the standard libtiff 3.7.0 creates only one directory with GDAL's libtiff.... (tested only on Linux):

Thanks in advance for help,

Julien

#include "tiff.h"
#include "tiffio.h"

int main(int argc, char **argv) {
     char *fout = argv[1];
     TIFF *tif;
     unsigned char buf[24] = {0};

     buf[0] = 22;
     buf[1] = 44;
     buf[2] = 55;

     tif = TIFFOpen(fout, "w");
     TIFFSetField( tif, TIFFTAG_BITSPERSAMPLE, 8 );
     TIFFSetField( tif, TIFFTAG_SAMPLESPERPIXEL, 1 );
     TIFFSetField( tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK );
     TIFFSetField( tif, TIFFTAG_IMAGEWIDTH, 4 );
     TIFFSetField( tif, TIFFTAG_IMAGELENGTH, 6 );
     TIFFSetField( tif, TIFFTAG_ROWSPERSTRIP, 6 );
     TIFFSetField( tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG );
     TIFFWriteEncodedStrip(tif, 0, buf, 24);
     TIFFClose(tif);

     tif = TIFFOpen(fout, "a");
     TIFFSetField( tif, TIFFTAG_BITSPERSAMPLE, 8 );
     TIFFSetField( tif, TIFFTAG_SAMPLESPERPIXEL, 1 );
     TIFFSetField( tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK );
     TIFFSetField( tif, TIFFTAG_IMAGEWIDTH, 2 );
     TIFFSetField( tif, TIFFTAG_IMAGELENGTH, 3 );
     TIFFSetField( tif, TIFFTAG_ROWSPERSTRIP, 3 );
     TIFFSetField( tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG );
     TIFFWriteEncodedStrip(tif, 0, buf, 6);
     TIFFWriteDirectory(tif);
     TIFFClose(tif);

     return 0;
}