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.04 15:00 "Re: libTiff and MSVC 6.0", by Bernie Pallek

Sean wrote:
> __declspec(dllexport) write2DTIFF(char *fname,
>                                 unsigned long *buf,
[...]
>     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);

Okay, some more things have occurred to me.  Two potential problems:
1) BitsPerSample is set to 16, while the allowed values (for greyscale) are
4 and 8.
2) "unsigned long *buf" points to 32-bit values, which differ from the
BitsPerSample size (16-bit samples).

Try using a value of 8 for BitsPerSample, change "unsigned long *buf" to
"unsigned char * buf", copy your original data into a temporary buffer,
which contains the original samples each divided by 256 (or bit-shifted
right by 8), and pass that temporary buffer.

>     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);