2000.12.06 15:55 "Garbage for first write to TIFF", by Sean Finn
Ok, I am writing a simple 8-bit unsigned char tiff file via Strips and LZW with Differencing (Predictor=2) encoding. (I have an LZW license). The problem is that my first hunk of data that I send to the library to be written is always being corrupted. No errors or warnings are returned, but when I look at it later, it is static mess, and every strip/scanline after is ok.
here are the tags I am setting prior to writing:
TIFFTAG_IMAGEWIDTH = image width
TIFFTAG_IMAGELENGTH = image length
TIFFTAG_BITSPERSAMPLE = 8
TIFFTAG_SAMPLESPERPIXEL = 1
TIFFTAG_PHOTOMETRIC = MinIsBlack
TIFFTAG_COMPRESSION = LZW
TIFFTAG_ORIENTATION = ORIENTATION_TOPLEFT
TIFFTAG_PLANARCONFIG = 1
TIFFTAG_RESOLUTIONUNIT = 2 /* inches */
TIFFTAG_SAMPLEFORMAT = 1 /* unsigned char */
TIFFTAG_ROWSPERSTRIP = TIFFDefaultStripSize(tif, -1)
Then I call TIFFWriteBufferSetup() and TIFFWriteCheck
Then, I walk through my data with TIFFWriteEncodedStrip.
The only thing I can think of that the calculations being made for the offsets and all the LZW stuff are not being correctly set because the first call to TIFFWriteEncodedStrip always sets things to 0 (being the first strip), and that maybe that messes something up.
This behavior has been shown with 8-bit color and Mono (minIsBlack), with LZW or Deflate compression. No other types have been tested yet. But, uncompressed had no garbage in the first line/s.
Anyway, the tutorial stuff in libtiff is nice, but there is no write info, just simple read info. Kind of annoying :)
Any help would be SUPER DUPER appreciated,