Return-Path: <tiff-bounces@remotesensing.org>
Received: from inav002.isp.belgacom.be (inav002.isp.belgacom.be [195.238.3.145])
        by mailst035.isp.belgacom.be (8.12.11/8.12.11/Skynet-MAILSTORE-2.14) with ESMTP id iAGAWgFf026978
        for <joris.at.lebbeke@skynet.be>; Tue, 16 Nov 2004 11:32:42 +0100
        (envelope-from <tiff-bounces@remotesensing.org>)
Received: from inas014.isp.belgacom.be (localhost [127.0.0.1])
        by inav002.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-AV-3.00) with ESMTP id iAGAWaTF028431
        for <joris.at.lebbeke@skynet.be>; Tue, 16 Nov 2004 11:32:37 +0100
        (envelope-from <tiff-bounces@remotesensing.org>)
Received: from inmx011.isp.belgacom.be (inmx011.isp.belgacom.be [195.238.3.50])
        by inas014.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-AS-2.03) with ESMTP id iAGAWR4j025523
        for <joris.at.lebbeke@skynet.be>; Tue, 16 Nov 2004 11:32:29 +0100
        (envelope-from <tiff-bounces@remotesensing.org>)
Received: from xserve.flids.com (adsl-065-083-169-202.sip.mco.bellsouth.net [65.83.169.202])
        by inmx011.isp.belgacom.be (8.12.11/8.12.11/Skynet-IN-2.32) with ESMTP id iAGAWLIb000673
        for <joris.at.lebbeke@skynet.be>; Tue, 16 Nov 2004 11:32:23 +0100
        (envelope-from <tiff-bounces@remotesensing.org>)
Received: from adsl-065-083-169-202.sip.mco.bellsouth.net (localhost [127.0.0.1])
	by xserve.flids.com (Postfix) with ESMTP
	id EADE547CC6A; Tue, 16 Nov 2004 05:32:04 -0500 (EST)
X-Original-To: tiff@remotesensing.org
Delivered-To: tiff@remotesensing.org
Received: from outmx014.isp.belgacom.be (outmx014.isp.belgacom.be
	[195.238.2.69])
	by xserve.flids.com (Postfix) with ESMTP id 5201F47CC45
	for <tiff@remotesensing.org>; Tue, 16 Nov 2004 05:32:02 -0500 (EST)
Received: from outmx014.isp.belgacom.be (localhost [127.0.0.1])
	by outmx014.isp.belgacom.be (8.12.11/8.12.11/Skynet-OUT-2.22) with
	ESMTP id iAGAW0vK011201
	for <tiff@remotesensing.org>; Tue, 16 Nov 2004 11:32:01 +0100
	(envelope-from <joris.at.lebbeke@skynet.be>)
Received: from dfgrrxsknr4e (176.45-200-80.adsl.skynet.be [80.200.45.176])
	by outmx014.isp.belgacom.be (8.12.11/8.12.11/Skynet-OUT-2.22) with SMTP
	id iAGAVqBe011149; Tue, 16 Nov 2004 11:31:53 +0100
	(envelope-from <joris.at.lebbeke@skynet.be>)
Message-ID: <001c01c4cbc7$7ed20500$b02dc850@dfgrrxsknr4e>
From: "Joris" <joris.at.lebbeke@skynet.be>
To: <tiff@remotesensing.org>,
        "Lars-goran Edholm" <lars-goran.edholm@sandviken.se>
References: <fc.004c4e0501835226004c4e0501835226.183523a@sandviken.se>
Subject: Re: [Tiff] Libtiff in Delphi
Date: Tue, 16 Nov 2004 11:31:51 +0100
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Cc: 
X-BeenThere: tiff@remotesensing.org
X-Mailman-Version: 2.1.2
Precedence: list
List-Id: TIFF and libtiff discussion  <tiff.remotesensing.org>
List-Unsubscribe: <http://xserve.flids.com/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=unsubscribe>
List-Archive: <http://xserve.flids.com/pipermail/tiff>
List-Post: <mailto:tiff@remotesensing.org>
List-Help: <mailto:tiff-request@remotesensing.org?subject=help>
List-Subscribe: <http://xserve.flids.com/mailman/listinfo/tiff>,
	<mailto:tiff-request@remotesensing.org?subject=subscribe>
Sender: tiff-bounces@remotesensing.org
Errors-To: tiff-bounces@remotesensing.org
X-UIDL: 1e742638b0b027b2aa84f60bd6ad9578

> I'm trying to read Tiff tags in Delphi 7 but with no luck:

It's usefull to mention you are using LibTiffDelphi
(http://www.awaresystems.be/imaging/tiff/delphi.html), because there are also
LibTiff DLL's around that could be used in Delphi, and some issues probably are
handled differently with those.

> var
> han:PTIFF;
> begin
> if OpenDialog1.Execute then
> try
> han:=TIFFOpen(OpenDialog1.FileName,'r');
> showmessage(inttostr(TIFFGetField(han, TIFFTAG_IMAGEWIDTH)));
>  except
>  end;
>   TIFFClose(han);
>  end;

Two mistakes here:

- LibTiff does not raise exceptions. So get rid of the try...except...end
scheme. Instead, you need to check the return of those functions to see if they
worked or not.

- TIFFGetField takes a pointer as third argument, or pointers as third and
fourth and so on. This is rather odd to you, as a Delphi programmer, Pascal does
not support the varargs scheme. But it's a varargs C function you're calling.
The tag value is returned in the memory pointed to by this third argument. The
function return merely signals error status.

So your code should be (unchecked, from the top of my head):

var
  han: PTIFF;
  m: Cardinal;
begin
  if OpenDialog1.Execute then
  begin
    han:=TIFFOpen(OpenDialog1.Filename,'r');
    if han=nil then ... {respond to the error here}
    if TIFFGetField(han, TIFFTAG_IMAGEWIDTH,@m)=0 then... {respond to the error
here}
    {m is now your image width}
  end;
end;


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@remotesensing.org
http://xserve.flids.com/mailman/listinfo/tiff
