Return-Path: <tiff-bounces@lists.maptools.org>
Received: from inas013.isp.belgacom.be (localhost [127.0.0.1])
        by inav021.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AV-3.00) with ESMTP id l0VHYULb005075
        for <joris.at.lebbeke@skynet.be>; Wed, 31 Jan 2007 18:34:30 +0100
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from inmx009.isp.belgacom.be (inmx009.isp.belgacom.be [195.238.5.146])
        by inas013.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-AS-2.03) with ESMTP id l0VHYPdL002343
        for <joris.at.lebbeke@skynet.be>; Wed, 31 Jan 2007 18:34:26 +0100
        (envelope-from <tiff-bounces@lists.maptools.org>)
Received: from duke.maptools.org (r153.dmsolutions.ca [209.217.116.153] (may be forged))
        by inmx009.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-IN-2.32) with ESMTP id l0VHYLWr029845
        for <joris.at.lebbeke@skynet.be>; Wed, 31 Jan 2007 18:34:22 +0100
        (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 l0VHNNxl030641;
	Wed, 31 Jan 2007 12:23:32 -0500
Received: from outmx012.isp.belgacom.be (outmx012.isp.belgacom.be
	[195.238.5.70])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id l0VHNLZ6030638
	for <tiff@lists.maptools.org>; Wed, 31 Jan 2007 12:23:22 -0500
Received: from outmx012.isp.belgacom.be (localhost [127.0.0.1])
	by outmx012.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-OUT-2.22)
	with ESMTP id l0VHNH3w002424
	for <tiff@lists.maptools.org>; Wed, 31 Jan 2007 18:23:19 +0100
	(envelope-from <joris.at.lebbeke@skynet.be>)
Received: from AWareCore2Duo (172.160-241-81.adsl-dyn.isp.belgacom.be
	[81.241.160.172])
	by outmx012.isp.belgacom.be (8.12.11.20060308/8.12.11/Skynet-OUT-2.22)
	with SMTP id l0VHNCLB002346; Wed, 31 Jan 2007 18:23:12 +0100
	(envelope-from <joris.at.lebbeke@skynet.be>)
Message-ID: <001d01c7455c$7b5cde20$a100a8c0@AWareCore2Duo>
From: "Joris" <joris.at.lebbeke@skynet.be>
To: "mikk" <mikk@go2.pl>, <tiff@lists.maptools.org>
References: <45C07531.8080604@go2.pl>
Subject: Re: [Tiff] Interpreting SubIFDs tag
Date: Wed, 31 Jan 2007 18:23:07 +0100
MIME-Version: 1.0
Content-Type: text/plain; format=flowed; charset="ISO-8859-2";
	reply-type=response
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2900.3028
x-mimeole: Produced By Microsoft MimeOLE V6.00.2900.3028
Cc: 
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.00002050
X-MSP-STORE: Wed, 31 Jan 2007 18:34:38 +0100
Status:   

mikk,

mikk wrote:
> I'm a bit confused with interpreting SubIFDs tag value.
>
> Each value of N values in SubIFDs tag is an offset (from the beginning
> of the TIFF file, as always) to a child IFD. But is each value of N
> values an offset to a single child IFD, or to the first IFD from a
> linked list of IFDs? When I read each of these N child IFDs, am I
> supposed to interpret NextIFDOffset field and read next directory from
> this position for each of child IFDs?

Both are possible, and both are common. In fact, sometimes both are 
combined, and I've come accross files where the same second and third SubIFD 
gets pointed to in both ways.

What I do, is take the value of the SubIFDs tag as an array, and build a 
list of pending IFDs to read from that. For each IFD I read, I take its next 
IFD offset pointer and if it's not zero marking the end of the list, I add 
it to the front of that list of pending IFDs to read. Before adding any 
initial or secondary value to the list, I double-check and see that I've not 
read that IFD before.

The first part of this scheme makes sure I get at all SubIFDs, whether they 
are mentioned inside the tag value or inside a linked list, or both. The 
last action prevents double inclusion and IFD looping.


Best regards,

Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be/
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html

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