AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2008.08.28 07:39 "[Tiff] Array of doubles to private tag", by Janis
2008.08.28 08:05 "Re: [Tiff] Array of doubles to private tag", by Andrey Kiselev
2008.08.28 08:54 "Re: [Tiff] Array of doubles to private tag", by Janis

2008.08.28 07:39 "[Tiff] Array of doubles to private tag", by Janis

Hi,

I'm dealing with (for me) a strange problem. I'm trying to write a number of double's to a private tag. Shouldn't be a problem I thought, but it seems it is.

For this I wrote the following test code for an array of shorts and doubles. The array with shorts works great! With the double's, I see that the tag is made within the TIFF file, but there arent't any values... I check each ' TIFFSetField' and all results are 1, meaning succes...

Result: http://i38.tinypic.com/143qgat.png

[CODE]
-------------------------------------------

#include <tiffio.h>
#include <stdio.h>

#define TIFFTAG_R00 40001
#define TIFFTAG_R01 40002

static void TagExtender(TIFF *tiff)
{
    static const TIFFFieldInfo xtiffFieldInfo[] = {
                { TIFFTAG_R00, 4, 4, TIFF_DOUBLE, FIELD_CUSTOM, 0, 1, "R00"
},
                { TIFFTAG_R01, 4, 4, TIFF_SHORT, FIELD_CUSTOM, 0, 1, "R01"
},

        };

    TIFFMergeFieldInfo( tiff, xtiffFieldInfo,
                sizeof(xtiffFieldInfo) / sizeof(xtiffFieldInfo[0]) );
}

int main()
{
    TIFF *tiff;

    TIFFSetTagExtender(TagExtender);

    tiff = TIFFOpen("foo.tiff", "w");

        short        shortD[4]     = {1,2,3,4};
        double  doubleD[4] = {0.2,1.2,2.2,3.2};

        TIFFSetDirectory(tiff, 0);

        bool result = true;

        // Setting fields
        result &= (TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, 100) ==
1);

        result &= (TIFFSetField(tiff, TIFFTAG_IMAGELENGTH,  100) == 1 );
        result &= (TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE,  8) == 1);
        result &= (TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL,3) == 1);

        // Writing Private tags
        result &= (TIFFSetField(tiff, TIFFTAG_R00, 4, &doubleD) == 1);
        result &= (TIFFSetField(tiff, TIFFTAG_R01, 4, &shortD) == 1);

        TIFFWriteDirectory(tiff);
        TIFFClose(tiff);

    return 0;
}