Closed GoogleCodeExporter closed 8 years ago
I have attached the offending TIFF. TIFF tags are 282 (hex 0x011A) and 283
(hex 0x011B).
How can I go about putting a band aid on this in my code, for now?
Original comment by alexfrom...@gmail.com
on 16 May 2012 at 5:58
Attachments:
[deleted comment]
Thanks for the sample image.
I think the following might work or should at least help.
In ExifReader.java, there's a switch statement that branches on type.
Currently both FMT_SRATIONAL and FMT_URATIONAL have the same handler. In fact
they should be different:
case FMT_SRATIONAL:
if (componentCount == 1) {
directory.setRational(tagType, new Rational(reader.getInt32(tagValueOffset), reader.getInt32(tagValueOffset + 4)));
} else if (componentCount > 1) {
Rational[] rationals = new Rational[componentCount];
for (int i = 0; i < componentCount; i++)
rationals[i] = new Rational(reader.getInt32(tagValueOffset + (8 * i)), reader.getInt32(tagValueOffset + 4 + (8 * i)));
directory.setRationalArray(tagType, rationals);
}
break;
case FMT_URATIONAL:
if (componentCount == 1) {
directory.setRational(tagType, new Rational(reader.getUInt32(tagValueOffset), reader.getUInt32(tagValueOffset + 4)));
} else if (componentCount > 1) {
Rational[] rationals = new Rational[componentCount];
for (int i = 0; i < componentCount; i++)
rationals[i] = new Rational(reader.getUInt32(tagValueOffset + (8 * i)), reader.getUInt32(tagValueOffset + 4 + (8 * i)));
directory.setRationalArray(tagType, rationals);
}
break;
The method BufferReader.getUInt32 doesn't exist yet either. It'll look
something like:
public int getUInt32(int index) throws BufferBoundsException
{
CheckBounds(index, 4);
if (_isMotorolaByteOrder) {
// Motorola - MSB first (big endian)
return (((long)_buffer[index ]) << 24 & 0xFF000000L) |
(((long)_buffer[index + 1]) << 16 & 0xFF0000L) |
(((long)_buffer[index + 2]) << 8 & 0xFF00L) |
(((long)_buffer[index + 3]) & 0xFFL);
} else {
// Intel ordering - LSB first (little endian)
return (((long)_buffer[index + 3]) << 24 & 0xFF000000L) |
(((long)_buffer[index + 2]) << 16 & 0xFF0000L) |
(((long)_buffer[index + 1]) << 8 & 0xFF00L) |
(((long)_buffer[index ]) & 0xFFL);
}
}
I haven't tested those chunks of code, but they should get you started even if
they don't work exactly.
Original comment by drewnoakes
on 16 May 2012 at 7:03
This issue has been fixed in the repo. Please note that source control has
moved from SVN to Git. The old SVN repo is still available, however this and
all future changes will be available only via Git.
Thanks very much for the bug report. I'll get a release out soon. In case you
can't wait, you can build it yourself from the latest source.
Original comment by drewnoakes
on 18 May 2012 at 10:10
Original issue reported on code.google.com by
drewnoakes
on 16 May 2012 at 8:53