AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2004.06.07 13:40 "[Tiff] Reading from part of a TIFF while writing another", by James Carroll
2004.06.07 14:05 "Re: [Tiff] Reading from part of a TIFF while writing another", by Frank Warmerdam
2004.06.07 17:29 "RE: [Tiff] Reading from part of a TIFF while writing another", by James Carroll

2004.06.07 17:29 "RE: [Tiff] Reading from part of a TIFF while writing another", by James Carroll

Thanks Frank,

This gives me some much nicer options than having lots of little files while I'm trying to read and write.

The first thing that I'm trying to write while I read (I can write after I read since the volume of data is small in this case) is a thumbnail overview.

I'm following the code in the tiff3.6.1/tools/thumbnail.c and used the official thumbnail tool to transform

this tiff image:
   http://neuroinformatica.com:8080/jims/256x4x3.tif

into this:
   http://neuroinformatica.com:8080/jims/256x4x3t.tif

using the command: thumbnail 256x4x3.tif 256x4x3t.tif

Irfanview can view the first one, but the second (with the t in the name) is not recognized as valid.

My guess is that I didn't really write a valid tiff when I created the first file. My code looks like:

    m_pTiff = TIFFOpen(lpszPathName, "w");
    TIFFSetField(m_pTiff, TIFFTAG_IMAGEWIDTH, iWidth)
    TIFFSetField(m_pTiff, TIFFTAG_IMAGELENGTH, iHeight)
    TIFFSetField(m_pTiff, TIFFTAG_BITSPERSAMPLE, 8)
    TIFFSetField(m_pTiff,TIFFTAG_SAMPLESPERPIXEL, 3)
    TIFFSetField(m_pTiff,TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)
    TIFFSetField(m_pTiff, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);

    // YCbCr makes a much smaller jpeg tile
    TIFFSetField(m_pTiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR);

    // make the tiles jpegs
    uint32 iJpegQuality = 80;
    uint32 jpegcolormode = JPEGCOLORMODE_RGB;

    TIFFSetField(m_pTiff, TIFFTAG_COMPRESSION, COMPRESSION_JPEG);
    TIFFSetField(m_pTiff, TIFFTAG_JPEGQUALITY, iJpegQuality);
    TIFFSetField(m_pTiff, TIFFTAG_JPEGCOLORMODE, jpegcolormode);

    uint32 tilewidth = 256;
    uint32 tilelength = 256;
    TIFFSetField(m_pTiff, TIFFTAG_TILEWIDTH, tilewidth);
    TIFFSetField(m_pTiff, TIFFTAG_TILELENGTH, tilelength);

Then I call WriteTile a bunch of times...

    sizeWritten = TIFFWriteTile(m_pTiff, tempTile, iTileX, iTileY, 0, 0);

Am I forgetting to initialize anything?

Thanks,
-Jim