diff --git a/src/main/java/omero/gateway/facility/RawDataFacility.java b/src/main/java/omero/gateway/facility/RawDataFacility.java index b6a39c3b..37ef274d 100644 --- a/src/main/java/omero/gateway/facility/RawDataFacility.java +++ b/src/main/java/omero/gateway/facility/RawDataFacility.java @@ -279,6 +279,24 @@ public List getResolutionDescriptions(SecurityContext ctx } + /** + * Checks if the image is considered RGB by the Bioformats Reader + * @param ctx The SecurityContext + * @param pixels The PixelsData object + * @return See above + * @throws DataSourceException If an error occurs while retrieving the data + */ + public boolean isRGB(SecurityContext ctx, PixelsData pixels) throws DataSourceException { + if (pixels == null) + return false; + + try { + return getDataSink(ctx, pixels, gateway).isRGB(); + } catch (DSOutOfServiceException e) { + throw new DataSourceException("Can't initiate DataSink", e); + } + } + /** * Retrieves a data sink corresponding the pixels. * diff --git a/src/main/java/omero/gateway/rnd/DataSink.java b/src/main/java/omero/gateway/rnd/DataSink.java index cda7803f..94c6b857 100644 --- a/src/main/java/omero/gateway/rnd/DataSink.java +++ b/src/main/java/omero/gateway/rnd/DataSink.java @@ -202,6 +202,20 @@ public Plane2D getTile(int z, int t, int c, int x, return new Plane2D(array, w, h, bytesPerPixels, strategy); } + /** + * Checks if the image is considered RGB by the Bioformats Reader. + * @return See above. + * @throws DataSourceException + * If an error occurs. + */ + public boolean isRGB() throws DataSourceException { + try { + return store.isRGB(); + } catch (Exception e) { + throw new DataSourceException("Cannot access RawPixelStore", e); + } + } + /** * Extracts a 2D plane from the pixels set this object is working for. *