Return-Path: <tiff-bounces@lists.maptools.org>
Received: from inas019.isp.belgacom.be (localhost [127.0.0.1])
        by inav007.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AV-3.00) with ESMTP id k73KLYKp029877
        for <joris.at.lebbeke@skynet.be>; Thu, 3 Aug 2006 22:21:34 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from inmx012.isp.belgacom.be (inmx012.isp.belgacom.be [195.238.5.90])
        by inas019.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AS-2.03) with ESMTP id k73KLUmQ009805
        for <joris.at.lebbeke@skynet.be>; Thu, 3 Aug 2006 22:21:31 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (r153.dmsolutions.ca [209.217.116.153] (may be forged))
        by inmx012.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-2.32) with ESMTP id k73KLOjC024229
        for <joris.at.lebbeke@skynet.be>; Thu, 3 Aug 2006 22:21:24 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (duke.maptools.org [127.0.0.1])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id k73JxmMJ022695;
	Thu, 3 Aug 2006 16:01:05 -0400
Received: from mailgw.aecom.yu.edu (mailgw.aecom.yu.edu [129.98.1.16])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id k73JxkKk022692
	for <tiff@lists.maptools.org>; Thu, 3 Aug 2006 15:59:46 -0400
Received: from mailvx.aecom.yu.edu (mailvx.aecom.yu.edu [129.98.1.17])
	by mailgw.aecom.yu.edu (8.12.11.20060308/8.12.11) with SMTP id
	k73JxfrV029679
	for <tiff@lists.maptools.org>; Thu, 3 Aug 2006 15:59:45 -0400
Received: from post.aecom.yu.edu ([129.98.1.100])
	by mailvx.aecom.yu.edu (SAVSMTP 3.1.1.32) with SMTP id
	M2006080315594513439
	for <tiff@lists.maptools.org>; Thu, 03 Aug 2006 15:59:45 -0400
Received: from [127.0.0.1] (singerlab.aecom.yu.edu [129.98.80.155])
	by post.aecom.yu.edu (Postfix) with ESMTP id B208B25
	for <tiff@lists.maptools.org>; Thu,  3 Aug 2006 15:59:45 -0400 (EDT)
Message-ID: <44D25577.7080203@aecom.yu.edu>
Date: Thu, 03 Aug 2006 15:58:47 -0400
From: Sean Burke <sburke@aecom.yu.edu>
User-Agent: Thunderbird 1.5.0.5 (Windows/20060719)
MIME-Version: 1.0
To: tiff@lists.maptools.org
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Subject: [Tiff] libTiff and MSVC 6.0
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.4
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/mailman/private/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=subscribe>
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org
X-UIDL: 000000000023ceae.00001934
X-MSP-STORE: Thu, 03 Aug 2006 22:21:41 +0200
Status:   

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


_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
