Return-Path: <tiff-bounces@lists.maptools.org>
Received: from inas014.isp.belgacom.be (localhost [127.0.0.1])
        by inav019.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AV-3.00) with ESMTP id k6EENrZq023025
        for <joris.at.lebbeke@skynet.be>; Fri, 14 Jul 2006 16:23:53 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from inmx006.isp.belgacom.be (inmx006.isp.belgacom.be [195.238.4.106])
        by inas014.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AS-2.03) with ESMTP id k6EENmcZ007636
        for <joris.at.lebbeke@skynet.be>; Fri, 14 Jul 2006 16:23:49 +0200
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (r153.dmsolutions.ca [209.217.116.153] (may be forged))
        by inmx006.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-2.32) with ESMTP id k6EENhox026995
        for <joris.at.lebbeke@skynet.be>; Fri, 14 Jul 2006 16:23:43 +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 k6EEC8m1025704;
	Fri, 14 Jul 2006 10:12:52 -0400
Received: from scmze001.ssan.egs-seg.gc.ca (scmze001.ssan.egs-seg.gc.ca
	[205.194.19.85])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id k6EEC3D1025700
	for <tiff@lists.maptools.org>; Fri, 14 Jul 2006 10:12:03 -0400
Received: from bulwark1.ic.gc.ca ([192.197.178.1])
	by scmze001.ssan.egs-seg.gc.ca with ESMTP; 14 Jul 2006 10:08:41 -0400
Received: from msg-gate1.ic.gc.ca ([142.53.11.41]) by bulwark1.ic.gc.ca
	via smtpd (for scmze001.ssan.egs-seg.gc.ca [205.194.19.85]) with ESMTP;
	Fri, 14 Jul 2006 10:08:41 -0400
Received: from parapet11.ic.gc.ca (parapet11.ic.gc.ca [142.53.11.253])
	by msg-gate1.ic.gc.ca (Switch-3.1.8/Switch-3.1.7) with ESMTP id
	k6EE8eax005366
	for <tiff@lists.maptools.org>; Fri, 14 Jul 2006 10:08:40 -0400 (EDT)
Received: from msg-con2.icent.ic.gc.ca by parapet11.ic.gc.ca
	via smtpd (for msg-gate1.ic.gc.ca [142.53.11.41]) with ESMTP;
	Fri, 14 Jul 2006 10:08:40 -0400
Received: from msg-con1.icent.ic.gc.ca ([142.53.28.148]) by
	msg-con2.icent.ic.gc.ca with Microsoft SMTPSVC(6.0.3790.211); 
	Fri, 14 Jul 2006 10:08:40 -0400
Received: from msg-mb2.icent.ic.gc.ca ([142.53.28.151]) by
	msg-con1.icent.ic.gc.ca with Microsoft SMTPSVC(6.0.3790.211); 
	Fri, 14 Jul 2006 10:08:40 -0400
X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0
Content-class: urn:content-classes:message
MIME-Version: 1.0
Content-Type: text/plain;
	charset="gb2312"
Subject: RE: [Tiff] The problem of Convert tiff
Date: Fri, 14 Jul 2006 10:08:40 -0400
Message-ID: <F78E6BBD22A6FC4489EBE2504540790805592512@msg-mb2.icent.ic.gc.ca>
In-Reply-To: <BAY103-DAV2DD42D31F2E6ADB8201F78B6F0@phx.gbl>
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
Thread-Topic: [Tiff] The problem of Convert tiff
Thread-Index: AcanCUO2UTYnTtWLRXWewMKx2Lp2AgAQ8dEQ
From: "Pallek, Bernie: #CIPO - OPIC" <Pallek.Bernie@ic.gc.ca>
To: "tiff" <tiff@lists.maptools.org>
X-OriginalArrivalTime: 14 Jul 2006 14:08:40.0605 (UTC)
	FILETIME=[021874D0:01C6A74F]
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by duke.maptools.org id
	k6EEC3D1025700
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.0000187b
X-MSP-STORE: Fri, 14 Jul 2006 16:23:55 +0200
Status:   

Robert Zhang wrote:
> [...]
>  TIFFGetField(srcImage, TIFFTAG_IMAGEWIDTH, &wv);
>  TIFFGetField(srcImage, TIFFTAG_IMAGELENGTH, &lv);
>  for (uint32 x =0;x<CurrentPage;x++) {
>   int readResult =TIFFSetDirectory (srcImage, (tdir_t )x);
> [...]

I realize this isn't directly related to your issue, but are you sure all your pages are the same size?  It just seems a little risky to assume they are by fetching the size only once, outside the page loop.

Also:
> TIFFReadEncodedStrip(srcImage, s, buf, cc);
> if (TIFFWriteEncodedStrip(image, s, buf, cc) < 0) {
>  _TIFFfree(buf);
> }

TIFFReadEncodedStrip returns the number of bytes actually read; you should probably pass that value to TIFFWriteEncodedStrip, instead of re-using 'cc'.  More significantly, conditionally freeing the buffer, but staying in the loop that uses that buffer, is guaranteed to give you a crash if the condition is ever satisfied, so either replace '_TIFFfree()' with 'break' (there's another free outside, after the loop, anyway), or just get rid of the condition altogether.

I'm only pointing these things out because as you clean up your code, you'll often stumble upon the actual problem you're trying to solve (at least in my experience).

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