diff --git a/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java b/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java index 95d7f36e879..c05d47da625 100644 --- a/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java +++ b/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java @@ -734,7 +734,6 @@ protected void initFile(String id) throws FormatException, IOException { convertPixelType(planes.get(0).directoryEntry.pixelType); // remove any invalid SubBlocks - int bpp = FormatTools.getBytesPerPixel(getPixelType()); if (isRGB()) { bpp *= (getSizeC() / originalC); @@ -743,16 +742,18 @@ protected void initFile(String id) throws FormatException, IOException { for (int i=0; i= Integer.MAX_VALUE || size < 0) { // check for reduced resolution in the pyramid DimensionEntry[] entries = planes.get(i).directoryEntry.dimensionEntries; int pyramidType = planes.get(i).directoryEntry.pyramidType; - if ((pyramidType == 1 || pyramidType == 2 || compression == JPEGXR) && - (compression == JPEGXR || size == entries[0].storedSize * entries[1].storedSize * bpp)) + if (isCompressed || + ((pyramidType == 1 || pyramidType == 2 ) && (size == entries[0].storedSize * entries[1].storedSize * bpp))) { - int scale = planes.get(i).x / entries[0].storedSize; + // circumvent integer arithmetic rounding issue by using floating point precision calculation (see issue #4102) + int scale = (int)((double)planes.get(i).x / (double)entries[0].storedSize + 0.5); if (scale == 1 || (((scale % 2) == 0 || (scale % 3) == 0) && allowAutostitching())) { if (scale > 1 && scaleFactor == 0) { scaleFactor = scale % 2 == 0 ? 2 : 3; @@ -4186,7 +4187,7 @@ public byte[] readPixelData(RandomAccessInputStream s, Region tile, byte[] buf) } } else { - LOGGER.warn("ZSTD-1 compression used, but no high/low byte unpacking"); + LOGGER.debug("ZSTD-1 compression used, but no high/low byte unpacking"); data = decoded; }