AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2003.07.30 21:53 "[Tiff] writing tiles to tiff file", by Pushkar Pradhan
2003.08.01 20:02 "[Tiff] problems using tiffwritetile", by Pushkar Pradhan
2003.08.03 01:52 "[Tiff] problems using tiffwritetile", by Frank Warmerdam
2003.08.03 02:41 "[Tiff] problems using tiffwritetile", by Pushkar Pradhan
2003.08.04 02:57 "[Tiff] Configure ZIP, JPEG, PIXARLOG", by Robin Rowe
2003.08.04 05:14 "[Tiff] Configure ZIP, JPEG, PIXARLOG", by Andrey Kiselev
2003.08.04 16:16 "[Tiff] Configure ZIP, JPEG, PIXARLOG", by Frank Warmerdam
2003.09.12 16:04 "[Tiff] writing out custom tags", by Chris Padwick
2003.09.15 07:45 "[Tiff] writing out custom tags", by Andrey Kiselev
2003.09.18 09:53 "[Tiff] color changes only with Windows Imaging (again)", by Takuya SATO
2003.09.18 12:26 "[Tiff] color changes only with Windows Imaging (again)", by Frank Warmerdam
2003.09.17 22:14 "[Tiff] is image tiled or striped?", by Pushkar Pradhan
2003.09.17 22:39 "[Tiff] is image tiled or striped?", by Frank Warmerdam

2003.07.30 21:53 "[Tiff] writing tiles to tiff file", by Pushkar Pradhan

Hi,
I'm new to libtiff programming. I've looked at some examples on the web but can't write out a tiled img. correctly.
I'm trying to read in a 3 band tiled img. into 3 buffers and write it out. (I use tiffinfo to verify it's a tiled, band separate img.)
I got the img width, length and tile width, length of the i/p img. using TIFFGetField and the other params. like planarconfig, samplesperpixel etc. Similarly I use TIFFSetField to set up the o/p img. info.

    bufR = (unsigned char*)_TIFFmalloc(TIFFTileSize(tif));
    bufG = (unsigned char*)_TIFFmalloc(TIFFTileSize(tif));
    bufB = (unsigned char*)_TIFFmalloc(TIFFTileSize(tif));

for(y = 0; y < imageLength; y += tileLength) {
  for(x = 0; x < imageWidth; x += tileWidth) {
    size = TIFFReadTile(tif, bufR, x, y, 0, 0);
    printf("read %d bytes\n", size);
    size = TIFFReadTile(tif, bufG, x, y, 0, 1);
    printf("read %d bytes\n", size);
    size = TIFFReadTile(tif, bufB, x, y, 0, 2);
    printf("read %d bytes\n", size);
    printf("width %d bytes\n", x);
    printf("length %d bytes\n", y);

/* RGBTOLHS */

        /*Rgb2Lhs(&bufR, &bufG, &bufB, &L, &H, &S, tileLength, tileWidth);*/
        size = TIFFWriteTile(wtif, bufR, x, y, 0, 0);
        printf("written %d bytes\n", size);
        TIFFWriteTile(wtif, bufG, x, y, 0, 1);
        printf("written %d bytes\n", size);
        TIFFWriteTile(wtif, bufB, x, y, 0, 2);
        printf("written %d bytes\n", size);

  }
}

Problem: It's not writing the no. of bytes it read, thus the o/p img. is invalid:
Sample Output:
read 16384 bytes
read 16384 bytes
read 16384 bytes
width 384 bytes
length 384 bytes
written 2048 bytes
written 2048 bytes
written 2048 bytes

Can anyone tell what's wrong? Thanks,

Pushkar Pradhan