Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checkbounds #62

Merged
merged 1 commit into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<groupId>fr.igred</groupId>
<artifactId>simple-omero-client</artifactId>
<version>5.13.0</version>
<version>5.13.1</version>
<packaging>jar</packaging>

<name>Simple OMERO Client</name>
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/fr/igred/omero/repository/PixelsWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,22 @@ private static void copy(byte[] bytes, Plane2D p, Coordinates start, int width,


/**
* Checks bounds
* Checks bounds.
* <br>If the lower bound is outside [0 - imageSize-1], the resulting value will be 0.
* <br>Conversely, if the higher bound is outside [0 - imageSize-1], the resulting value will be imageSize-1.
*
* @param bounds Array containing the specified bounds for 1 coordinate.
* @param imageSize Size of the image (in the corresponding dimension).
*
* @return New array with valid bounds.
*/
private static int[] checkBounds(int[] bounds, int imageSize) {
int[] newBounds = {0, imageSize - 1};
int[] b = {0, imageSize - 1};
if (bounds != null && bounds.length > 1) {
newBounds[0] = Math.max(newBounds[0], bounds[0]);
newBounds[1] = Math.min(newBounds[1], bounds[1]);
b[0] = bounds[0] >= b[0] && bounds[0] <= b[1] ? bounds[0] : b[0];
b[1] = bounds[1] >= b[0] && bounds[1] <= b[1] ? bounds[1] : b[1];
}
return newBounds;
return b;
}


Expand Down
4 changes: 2 additions & 2 deletions src/test/java/fr/igred/omero/repository/PixelsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ void testGetRawDataBoundError() throws Exception {
PixelsWrapper pixels = image.getPixels();

int[] xBounds = {511, 513};
int[] yBounds = {0, 2};
int[] cBounds = {0, 2};
int[] yBounds = {525, 2};
int[] cBounds = {-1, -1};
int[] zBounds = {0, 2};
int[] tBounds = {0, 2};

Expand Down