Skip to content

Commit

Permalink
Merge pull request #4072 from melissalinkert/gh-3927
Browse files Browse the repository at this point in the history
Ventana: fix tile arithmetic for smallest resolutions
  • Loading branch information
dgault authored Oct 4, 2023
2 parents 1067aec + 39f5ab6 commit 90bdfa5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions components/formats-gpl/src/loci/formats/in/VentanaReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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<thisTileHeight; row++) {
System.arraycopy(subResTile, input, tilePixels, output, outRow);
input += inRow;
output += outRow;
int copy = (int) Math.min(outRow, tilePixels.length - output);
copy = (int) Math.min(copy, subResTile.length - input);
if (copy >= 0) {
System.arraycopy(subResTile, input, tilePixels, output, copy);
input += inRow;
output += outRow;
}
}
}
}
Expand Down

0 comments on commit 90bdfa5

Please sign in to comment.