2004.11.04 06:42 "[Tiff] N TIFFTAG_TRANSFERFUNCTION", by Kai-Uwe Behrmann

2004.11.04 08:38 "Re: [Tiff] N TIFFTAG_TRANSFERFUNCTION", by Ross A. Finlayson

Thanks, have found it. Testing of the pointers for zero should do.

if (TIFFGetField (tiff, TIFFTAG_TRANSFERFUNCTION,
                  &r_uint16, &g_uint16, &b_uin16) )
    if (r_uin16)
        // there is at least one kurve
    if (r_uint16 && g_uin16 && b_uint16)
        // there are 3 curves

Hi Kai-Uwe,

I'm uncertain of the answer for that. I think instead you should compare the pointers to each other because if there is only one transfer function that each of the three pointers is set to the same value. So tiff2pdf compares the first to the second pointer to see if they are different. If they are the same, then there is only one transfer function, otherwise, three. I looked at the source code where that is done before I coded that.

Here is some copied code, from tif_dirread.c:

                case TIFFTAG_TRANSFERFUNCTION:
                        /*
                         * TransferFunction can have either 1x or 3x data
                         * values; Colormap can have only 3x items.
                         */
                        v = 1L<<td->td_bitspersample;
                        if (dp->tdir_tag == TIFFTAG_COLORMAP ||
                            dp->tdir_count != (uint32) v) {
                                if (!CheckDirCount(tif, dp, (uint32)(3*v)))
                                        break;
                        }
                        v *= sizeof (uint16);
                        cp = CheckMalloc(tif, dp->tdir_count, sizeof (uint16),
                            "to read \"TransferFunction\" tag");
                        if (cp != NULL) {
                                if (TIFFFetchData(tif, dp, cp)) {
                                        /*
                                         * This deals with there being only
                                         * one array to apply to all samples.
                                         */
                                        uint32 c =
                                            (uint32)1 << td->td_bitspersample;
                                        if (dp->tdir_count == c)
                                                v = 0;
                                        TIFFSetField(tif, dp->tdir_tag,
                                            cp, cp+v, cp+2*v);
                                }
                                _TIFFfree(cp);
                        }
                        break;

It sets the pointers to cp, cp+v, and cp+2*v. So, if there is only one transfer function, then each pointer is set to cp, where v==0. So, if cp != cp+v, then there are multiple transfer functions for the multiple channels, to get the transfer function count.

The answer of one for all or three separate transfer functions is whether r_uint16 == g_uint16 in your example. Is that not so?

Then, I have a question, it is off-topic, but I wonder if the fax codec supports uncompressed mode anymore. I tinker upon a fax codec, and want to understand libtiff's fax compression codec. Are you familiar with any limits of the libtiff fax codec?

Warm regards,

Ross F.