Received: from mailgate002.isp.belgacom.be (mailgate002.isp.belgacom.be [195.238.6.87])
	by maildelivery018.isp.belgacom.be (Postfix) with ESMTP id 09B6A3AC055
	for <joris.at.lebbeke@skynet.be>; Wed,  6 Feb 2008 21:25:36 +0100 (CET)
Authentication-Results: in.mx.skynet.be; dkim=neutral (message not signed) header.i=none
Received: from r153.dmsolutions.ca (HELO duke.maptools.org) ([209.217.116.153])
  by in.mx.skynet.be with ESMTP; 06 Feb 2008 21:24:42 +0100
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 m16K3gWP031766;
	Wed, 6 Feb 2008 15:04:36 -0500
Received: from mail.sidefx.com (mail.sidefx.com [149.99.58.193])
	by duke.maptools.org (8.12.11/8.12.10) with ESMTP id m16K3chm031763
	for <tiff@lists.maptools.org>; Wed, 6 Feb 2008 15:03:39 -0500
Received: from [192.168.235.105] (unknown [192.168.235.105])
	by mail.sidefx.com (Postfix) with ESMTP id 75BB25C080
	for <tiff@lists.maptools.org>; Wed,  6 Feb 2008 15:03:36 -0500 (EST)
Message-ID: <47AA12A3.1060503@sidefx.com>
Date: Wed, 06 Feb 2008 15:03:47 -0500
From: Edward Lam <edward@sidefx.com>
User-Agent: Thunderbird 2.0.0.9 (Windows/20071031)
MIME-Version: 1.0
To: tiff@lists.maptools.org
References: <54382CA459FA433BB9033B7CD2F97604@amd64>
In-Reply-To: <54382CA459FA433BB9033B7CD2F97604@amd64>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Subject: [Tiff] Bug in tif_print.c for TIFFTAG_REFERENCEBLACKWHITE
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.00002a78
X-MSP-STORE: Wed, 06 Feb 2008 21:25:36 +0100
Status: RO

Hi,

I've found a bug in tiffinfo when used to display images RGBA images. I 
would have checked the bug database at,
     http://bugzilla.remotesensing.org/buglist.cgi?product=libtiff
but it seems to be down at the moment. I've confirmed that the problem 
exists in CVS HEAD (since at least 3.7.0).

I have the following image and used tiffinfo on it:

$ ./tiffinfo c:/cygwin/tmp/foo.tiff
TIFF Directory at offset 0x92c3c (601148)
   Image Width: 512 Image Length: 512
   Resolution: 1, 1 (unitless)
   Position: 0, 0
   Bits/Sample: 32
   Sample Format: IEEE floating point
   Compression Scheme: LZW
   Photometric Interpretation: RGB color
   Extra Samples: 1<assoc-alpha>
   Orientation: row 0 top, col 0 lhs
   Samples/Pixel: 4
   Rows/Strip: 2
   Planar Configuration: single image plane
   DateTime: 2008:02:06 13:29:39
   Reference Black/White:
      0:     0     1
      1:     0     1
      2:     0     1
      3: 2.9389e-039 1.10203e-038

Notice that for the Reference Black/White entry, there's garbage printed 
out in the last pair. According to page 87 of the TIFF6.pdf, the 
ReferenceBlackWhite tag contains 6 rationals (or 3 pairs). tiffinfo 
however is display 4 pairs.

I tracked this down to tif_print.c where we have code like this:

case TIFFTAG_REFERENCEBLACKWHITE:
{
	uint16 i;

	fprintf(fd, "  Reference Black/White:\n");
	for (i = 0; i < td->td_samplesperpixel; i++)
	    fprintf(fd, "    %2d: %5g %5g\n", i,
		((float *)raw_data)[2*i+0],
		((float *)raw_data)[2*i+1]);
	return 1;
}

Notice that i loops from 0 to td_samplesperpixel when I think it should 
be looping from 0 to *3* instead. We similarly hardcode this constant 
for this tag in other places.

One might think that perhaps the SamplesPerPixel tag should be 3 for 
RGBA images but I think the TIFF 6 spec clearly says that 
SamplesPerPixel *includes* ExtraSamples in the description for 
ExtraSamples (page ) as well as the note on it on page 27.

Thanks,
-Edward



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