From 783980abc0cb4e0f0b0165210f25e815231ede08 Mon Sep 17 00:00:00 2001 From: Melissa Linkert Date: Mon, 7 Aug 2023 11:25:00 -0500 Subject: [PATCH 1/2] Ventana BIF: fix tile calculation for small resolutions Fixes #3927. This makes the rounding consistent across all tile size and coordinate calculations, which should eliminate off-by-ones that cause a grid of black pixels to appear for the smallest few resolutions. --- .../formats-gpl/src/loci/formats/in/VentanaReader.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/formats-gpl/src/loci/formats/in/VentanaReader.java b/components/formats-gpl/src/loci/formats/in/VentanaReader.java index 49749983e7d..4a9513d18c6 100644 --- a/components/formats-gpl/src/loci/formats/in/VentanaReader.java +++ b/components/formats-gpl/src/loci/formats/in/VentanaReader.java @@ -230,8 +230,8 @@ public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) int outputRowLen = w * tilePixel; int scale = getScale(getCoreIndex()); - int thisTileWidth = tileWidth / scale; - int thisTileHeight = tileHeight / scale; + int thisTileWidth = scaleCoordinate(tileWidth, getCoreIndex()); + int thisTileHeight = scaleCoordinate(tileHeight, getCoreIndex()); byte[] subResTile = null; int subResX = -1, subResY = -1; @@ -250,8 +250,8 @@ public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) } tileBox.x = scaleCoordinate(tileBox.x, getCoreIndex()); tileBox.y = scaleCoordinate(tileBox.y, getCoreIndex()); - tileBox.width /= scale; - tileBox.height /= scale; + tileBox.width = scaleCoordinate(tileBox.width, getCoreIndex()); + tileBox.height = scaleCoordinate(tileBox.height, getCoreIndex()); if (tileBox.intersects(imageBox)) { if (scale == 1) { From 39f5ab6921781700fdac02c834477836c9dba284 Mon Sep 17 00:00:00 2001 From: Melissa Linkert Date: Mon, 7 Aug 2023 13:00:13 -0500 Subject: [PATCH 2/2] Add some bounds checking on array copies --- .../formats-gpl/src/loci/formats/in/VentanaReader.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/components/formats-gpl/src/loci/formats/in/VentanaReader.java b/components/formats-gpl/src/loci/formats/in/VentanaReader.java index 4a9513d18c6..12b0ec9860f 100644 --- a/components/formats-gpl/src/loci/formats/in/VentanaReader.java +++ b/components/formats-gpl/src/loci/formats/in/VentanaReader.java @@ -292,9 +292,13 @@ public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) input = inRow * (c * tileHeight + offsetY) + offsetX * tilePixel; output = c * thisTileHeight * outRow; for (int row=0; row= 0) { + System.arraycopy(subResTile, input, tilePixels, output, copy); + input += inRow; + output += outRow; + } } } }