2008.10.14 18:00 "[Tiff] debugging on Windows", by Rajmohan Banavi

2008.10.14 18:00 "[Tiff] debugging on Windows", by Rajmohan Banavi

Hi,

Just started using libtiff 3.8.2 on Windows (gnuwin32.sourceforge.net) and

am seeing an unhandled exception when I call the api - TIFFPrintDirectory().

I have pasted the code below. Even if I provide stdout as the 2nd parameter

to the function TIFFPrintDirectory(), i see the same crash. Please let me

know what I am missing. Further, just wanted to know how easy is it to build

a debug version of the libs for Windows?

Thanks.

------------------------------------------------------------------------------------------------------------------------------------------------------ #include "stdafx.h"

#include <stdio.h>
#include <stdlib.h>

#include "tiffio.h"

int main(int argc, char* argv[])
{
    TIFF *image;
    uint32 width, height, pages = 0;
    uint32 *raster = NULL;
    tsize_t stripSize;
    FILE *tiffinfo;

    /* open the TIFF image */
    if ((image = TIFFOpen("test.TIF", "r")) == NULL)
    {
        fprintf(stderr, "Could not open the input file\n");
        printf ("You never come here\n");
        exit(42);
    }

    tiffinfo = fopen ("tiffinfo.txt", "w");
    if (tiffinfo == NULL)
    {
        fprintf(stderr, "Could not open the tiff info output file\n");
    }

    do
    {
        pages++;

        /* Find the height and the width of the given image */
        TIFFGetField(image, TIFFTAG_IMAGEWIDTH, &width);
        TIFFGetField(image, TIFFTAG_IMAGELENGTH, &height);

        printf ("Image Height: %d and width: %d\n", height, width);

        TIFFPrintDirectory(image, tiffinfo, TIFFPRINT_NONE);
    } while (TIFFReadDirectory(image));

    printf ("Number of pages: %d\n", pages);

    TIFFClose(image);
    fclose(tiffinfo);

    return 0;
}