Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.0-alpha1
-
None
-
None
Description
reading monochrome TIFF doesn't work.
wrong function getSamplesAsBytes(bis, samples);
Here with having 1 Bit per Pixel it returns value samples[0] = 255 instead of 1.
Then photometricInterpreter.interpretPixel(imageBuilder, samples, x, y); has a problem
public void interpretPixel(final ImageBuilder imageBuilder, final int[] samples, final int x,
final int y) throws ImageReadException, IOException
as the indexColorMaps only has two entries (black and white), but not 256 entries
The same problem will occur as the colour does not have 8 Bit.
The fix seems simple:
In routine
void getSamplesAsBytes(final BitInputStream bis, final int[] result) throws IOException {
for (int i = 0; i < bitsPerSample.length; i++) {
final int bits = bitsPerSample[i];
int sample = bis.readBits(bits);
if (bits < 8) {
final int sign = sample & 1;
sample = sample << (8 - bits); // scale to byte.
if (sign > 0)
}...
if 'sign>0' don't fill up to 8 bits, but to 'bits' amount of '1'.
I am not sure about other side effects, so I post this suggestion.