Return-Path: <tiff-bounces@lists.maptools.org>
X-Original-To: info@awaresystems.be
Delivered-To: info@awaresystems.be
Received: from mx-s.b-one.net (mx-s.one.com [91.198.169.250])
	by mail9.b-one.net (Postfix) with ESMTP id 8FE58400400
	for <info@awaresystems.be>; Mon, 26 Apr 2010 20:46:45 +0200 (CEST)
Received: by mx-s.b-one.net (Postfix, from userid 106)
	id 7F5234C50E59; Mon, 26 Apr 2010 20:46:45 +0200 (CEST)
X-Virus-Scanned: by one.com
X-Spam-Score: 0
X-Spam-Level: 
X-Spam-Status: No, score=0 tagged_above=0 required=4 tests=[none]
X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4
Received: from lists.maptools.org (lists.maptools.org [65.39.174.144]) by
 mx-s.b-one.net (Postfix) with ESMTP id 7060D24AFC for <info@awaresystems.be>;
 Mon, 26 Apr 2010 20:46:44 +0200 (CEST)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by
 lists.maptools.org (Postfix) with ESMTP id C4ABA1D18B146; Mon, 26 Apr 2010
 13:43:59 -0500 (EST)
Received: from mail.sidefx.com (unknown [38.99.137.163]) by
 lists.maptools.org (Postfix) with ESMTP id 976DC1D0E52A0 for
 <tiff@lists.maptools.org>; Mon, 26 Apr 2010 13:39:16 -0500 (EST)
Message-ID: <4BD5DDCA.2090808@sidefx.com>
Date: Mon, 26 Apr 2010 14:39:06 -0400
From: Edward Lam <edward@sidefx.com>
User-Agent: Thunderbird 2.0.0.24 (Windows/20100228)
MIME-Version: 1.0
To: Tiff List <tiff@lists.maptools.org>
Subject: [Tiff] Bug in tif_print.c for TIFFTAG_REFERENCEBLACKWHITE
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.9
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>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org

Hi,

This is a repost from awhile back that got no reply which still looks 
like it exists in CVS HEAD. Again, I'd log it in the bug database except 
that I can't seem to currently access remotesensing.org at all.

I have an 6-Bit RGBA image and using tiffinfo on it gives:

$ ./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 31) as well as the note about 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/
