AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2004.11.04 06:42 "[Tiff] N TIFFTAG_TRANSFERFUNCTION", by Kai-Uwe Behrmann
2004.11.04 08:21 "Re: [Tiff] N TIFFTAG_TRANSFERFUNCTION", by Kai-Uwe Behrmann
2004.11.04 08:38 "Re: [Tiff] N TIFFTAG_TRANSFERFUNCTION", by Ross A. Finlayson
2004.11.04 09:00 "Re: [Tiff] N TIFFTAG_TRANSFERFUNCTION", by Kai-Uwe Behrmann

2004.11.04 09:00 "Re: [Tiff] N TIFFTAG_TRANSFERFUNCTION", by Kai-Uwe Behrmann

Ross,

thanks for pointing out this behaviour. I will change this in my code. This message may be helpfull to the lcms list too. Therefore I crosspost.

As about libtiff fax coding I must pass. I am coming from the float side, working on HDR imagery.

kind regards

Kai-Uwe Behrmann
                                + imaging development / panoramas
                                + color management
                                + email: ku.b@gmx.de

Am 04.11.04, 00:38 -0800 schrieb 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

                                + email: ku.b@gmx.de

Am 04.11.04, 07:42 +0100 schrieb Kai-Uwe Behrmann:

How can I determine the size of TIFFTAG_TRANSFERFUNCTION to calculate the number of curves used by the tag. As stated in the spec 1 and 3 curves are both possible for RGB. For GRAY I would expect 1 curve is allways ok.

man TIFFGetField only says:
TIFFTAG_TRANSFERFUNCTION 1 or 3- uint16**1<<BitsPerSample entry arrays

Just to be shure, I dont exceede memory.

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 fun