
Thread
2010.04.26 20:12 "Re: [Tiff] Bug in tif_print.c for TIFFTAG_REFERENCEBLACKWHITE", by Edward Lam
Edward Lam wrote:
> I have an 6-Bit RGBA image and using tiffinfo on it gives:
Er, I meant 8-bit here of course.
I also noticed another problem with the number of expected floats for TIFFTAG_REFERENCEBLACKWHITE in the documentation for TIFFSetField:
http://libtiff.maptools.org/man/TIFFSetField.3tiff.html
where it says:
2*SamplesPerPixel
-Edward
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 planeDateTime: 2008:02:06 13:29:39
Reference Black/White:
0: 0 1
1: 0 1
2: 0 1
3: 2.9389e-039 1.10203e-038Notice 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.