AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
August 2006

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2006.08.03 19:58 "libTiff and MSVC 6.0", by Sean Burke
2006.08.03 21:38 "Re: libTiff and MSVC 6.0", by Bernie Pallek
2006.08.04 14:32 "Re: libTiff and MSVC 6.0", by Gerben Vos
2006.08.04 15:00 "Re: libTiff and MSVC 6.0", by Bernie Pallek

2006.08.03 19:58 "libTiff and MSVC 6.0", by Sean Burke

Hello folks. 
I am working with the Windows port of libtiff (v3.8.2) and MS Visual 
Studio 6.0.  I am running into a strange problem and I hope that someone 
on the list can help me out. 
   The following code is compiled as a multithreaded DLL and will throw 
an exception after TIFFOpen is called:

#include "write2DTIFF.h"
__declspec(dllexport) write2DTIFF(char *fname,
                                unsigned long *buf,
                                unsigned long width,
                                unsigned long height);


__declspec(dllexport) write2DTIFF(char *fname,
                                unsigned long *buf,
                                unsigned long width,
                                unsigned long height)
{
    TIFF *tif;
       
    tif = TIFFOpen(fname, "w");
    TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
    TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
    TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_LZW);
    TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16);
    TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
    TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
    if((TIFFWriteEncodedStrip(tif, 0, buf, width*height)) == -1){
        fprintf(stderr, "TIFFWriteEncodedStrip failed.\n");
    }
    TIFFClose(tif);
}

     If I comment out the TIFFSetField and TIFFClose commands, I can get 
an 8 bit file with the correct name (and presumably, the correct 
header).  If I add two or even three more TIFFOpen commands, they are 
all opened correctly.  Whenever I try to call any other command though, 
the parent that calls the DLL catches an exception. 
    The above code is simple enough and doesn't appear to contain any 
obvious bugs.  Am I screwing anything up here?  Does anyone have any 
experience making a Windows DLL with libtiff and MSVC6?

Thank you for your time.

Sean

-- 
Sean Burke
Imaging Analysis Specialist
Albert Einstein College of Medicine
1300 Morris Park Avenue
Bronx, NY 10461
PH: 718.430.8628