AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2000.03.14 01:02 "Writing subfiles out of order", by Rick LaMont
2000.03.14 03:01 "Re: Writing subfiles out of order", by Frank Warmerdam

2000.03.14 01:02 "Writing subfiles out of order", by Rick LaMont

I have an application that uses libtiff to create a file with multiple subfiles. Each subfile is tiled and may be compressed. Currently, the file is written in strictly sequential order:

    for (subfile = 0 to n) {
        set-all-TIFF-fields
        for (tile = upper-left to lower-right)
            TIFFWriteTile(data(subfile, tile))
        TIFFWriteDirectory
    }

This solution works but is slow because it has to make n passes over the input file (not shown in pseudocode). Buffering the entire input file in memory is not an option because it might be on the order of a gigabyte. It would be preferable to renest the loops to something like this:

    for (subfile = 0 to n) {
        set-all-TIFF-fields
        TIFFWriteDirectory
    }
    for (tile = upper-left to lower-right)
        for (subfile = 0 to n) {
            TIFFSetDirectory(subfile)
            TIFFWriteTile(data(subfile, tile))
        }

Is it possible to write tiles across all subfiles like this or am I just dreaming? My first attempt failed on the TIFFWriteDirectory because the tile offsets weren't initialized. If necessary, I wouldn't mind creating all black tiles and then going back to fill in the framework. My fear is that these placeholders would compress better than the actual data, not leaving enough room.

I remember reading somewhere that TIFFWriteTile *usually* appends to the end of the output file. Under what circumstances can it overwrite the middle?

Thanks,

Rick LaMont
Dot C Software, Inc.