diff --git a/components/formats-bsd/src/loci/formats/tiff/TiffParser.java b/components/formats-bsd/src/loci/formats/tiff/TiffParser.java index bfc4228e132..3aa9e2f07a0 100644 --- a/components/formats-bsd/src/loci/formats/tiff/TiffParser.java +++ b/components/formats-bsd/src/loci/formats/tiff/TiffParser.java @@ -725,6 +725,14 @@ else if (stripByteCounts[countIndex] < 0 && countIndex > 0) { in.seek(stripOffset); in.read(tile); + // reverse bits in each byte if FillOrder == 2 + + if (ifd.getIFDIntValue(IFD.FILL_ORDER) == 2) { + for (int i=0; i> 24); + } + } + codecOptions.maxBytes = (int) Math.max(size, tile.length); codecOptions.ycbcr = ifd.getPhotometricInterpretation() == PhotoInterp.Y_CB_CR && @@ -874,6 +882,7 @@ public byte[] getSamples(IFD ifd, byte[] buf, int x, int y, photoInterp != PhotoInterp.WHITE_IS_ZERO && photoInterp != PhotoInterp.CMYK && photoInterp != PhotoInterp.Y_CB_CR && compression == TiffCompression.UNCOMPRESSED && + ifd.getIFDIntValue(IFD.FILL_ORDER) != 2 && numTileRows * numTileCols == 1 && stripOffsets != null && stripByteCounts != null && in.length() >= stripOffsets[0] + stripByteCounts[0]) {