2002.03.13 09:39 "How to use TIFFReadScanLine() method", by Shan

2002.03.13 22:04 "Re: How to use TIFFReadScanLine() method", by Peter Montgomery

Shan,

Awfully vague question. Here's a vague answer:

Assuming you've read the TIFF header and know A) how big scanlines are, B) how big the image is, and C) have malloc'ed a scanline, just loop through and read the scanline into your buffer

int CurrSL, // Current scanline being read
    ReturnVal,
    Height; // REad header to figure out how many scanlines are in the TIFF image

TIFF* Tif; // This is your TIF file pointer.  Needs to be opened
tdata_t Buf; // Scanline buffer.  Needs to be malloc'ed


// Open the TIF file, read header, malloc "buf"
// Once that's done, read each scanline into the buffer

for (CurrSL = 0; CurrSL <Height; CurrSL++){
 if (Config == PLANARCONFIG_CONTIG){

 // Read a scanline of data
 ReturnVal = TIFFReadScanline(Tif, Buf, CurrSL, 0);
  if (ReturnVal == -1){
   printf("TiffRead() ERROR: Problem reading scanline %d.\n", CurrSL);
   break; // We have a problem, bail out now...
  }
 } else {
 printf("TiffRead() ERROR: 1/28/2000 - Can't handle TIFF's with non-contiguous pixel channels.\n");
 break; // We have a problem, bail out now...
 }

 // Do something with the scanline you just read

}

Thanks,
PeterM