home *** CD-ROM | disk | FTP | other *** search
/ Internet File Formats / InternetFileFormatsCD.bin / graphics / tiff / unix / archive.z / archive / text0021.txt < prev    next >
Encoding:
Text File  |  1995-09-20  |  2.0 KB  |  45 lines

  1.     To:  tiff@sgihub.corp.sgi.com
  2.     Subject:  Appending images to an existing file
  3.     Date: Fri, 02 Dec 1994 12:30:47 PST
  4.     From:  "Venkatesh Narayanan" <venky@jayhawk.asd.sgi.com>
  5.  
  6.     Hi,
  7.      I'm trying to append some images to an existing TIFF file that already has
  8.     an image in it. I'm not having much sucess doing this. Here is the sequence
  9.     of calls I'm making:
  10.         tiff = TIFFFOpen(filename, "r+"); //I've also tried "a" without success
  11.             TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, xsize);
  12.             TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, ysize);
  13.         TIFFSetField(tiff, TIFFTAG_IMAGEDEPTH, 1);
  14.         TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, bpp);
  15.         TIFFSetField(tiff, TIFFTAG_SAMPLEFORMAT, ttype);
  16.         TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
  17.         TIFFSetField(tiff, TIFFTAG_ORIENTATION,ORIENTATION_TOPLEFT);
  18.         TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, csize);
  19.         TIFFSetField(tiff, TIFFTAG_TILEWIDTH, xPageSize);
  20.         TIFFSetField(tiff, TIFFTAG_TILELENGTH, yPageSize);
  21.         TIFFSetField(tiff, TIFFTAG_TILEDEPTH, 1);
  22.         TIFFWriteDirectory(tiff);
  23.         TIFFSetDirectory(tiff, 1); //this always fails and I get the message :
  24.                                        //"Could not index into TIFF directory"
  25.         While(..there are tiles to write..)
  26.             TIFFWriteEncodedTile (tiff, tile, bufdata, bytecount);
  27.  
  28. Opening the file "r+" is not supported.  If you want to append use "a".
  29. I'm not sure what will happen with the above code.  My guess is that the
  30. TIFFWriteDirectory call will fail (though it should have generated a
  31. diagnostic) and then the TIFFSetDirectory call will fail because,
  32. presumably, you only have 1 IFD in the file.
  33.     
  34.     Even if I take out the TIFFSetDirectory() call, what happens is that the
  35.     existing file has been corrupted and can't be read at all.
  36.     Anyone successfully appended images ? The README file says that the append
  37.     mode hasn't been tested.
  38.  
  39. Appending to a file works fine in v3.3beta021; you don't indicate
  40. what version you have.
  41.  
  42.     Sam
  43.  
  44.  
  45.