/** * Implemented as specified by {@link PixelBuffer} I/F. * @see PixelBuffer#getRegionDirect(Integer, Long, byte[]) */ public byte[] getRegionDirect(Integer size, Long offset, byte[] buffer) throws IOException { if (buffer.length != size) throw new ApiUsageException("Buffer size incorrect."); final PixelData pd = getRegion(size, offset); pd.getData().get(buffer); pd.dispose(); return buffer; }
public byte[] calculateMessageDigest() throws IOException { MessageDigest md; try { md = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e) { throw new RuntimeException( "Required SHA-1 message digest algorithm unavailable."); } for (int z = 0; z < getSizeZ(); z++) { for (int c = 0; c < getSizeC(); c++) { for (int t = 0; t < getSizeT(); t++) { try { ByteBuffer buffer = getPlane(z, c, t).getData(); md.update(buffer); } catch (DimensionsOutOfBoundsException e) { throw new RuntimeException(e); } } } } return md.digest(); }
/** * Implemented as specified by {@link PixelBuffer} I/F. * @see PixelBuffer#getPlaneRegionDirect(Integer, Integer, Integer, Integer, * Integer, byte[]) */ public byte[] getPlaneRegionDirect(Integer z, Integer c, Integer t, Integer count, Integer offset, byte[] buffer) throws IOException, DimensionsOutOfBoundsException { final PixelData pd = getPlane(z, c, t); final ByteBuffer b = pd.getData(); b.position(offset * getByteWidth()); b.get(buffer, 0, count * getByteWidth()); pd.dispose(); return buffer; }
/** * Implemented as specified by {@link PixelBuffer} I/F. * @see PixelBuffer#getRowDirect(Integer, Integer, Integer, Integer, byte[]) */ public byte[] getRowDirect(Integer y, Integer z, Integer c, Integer t, byte[] buffer) throws IOException, DimensionsOutOfBoundsException { if (buffer.length != getRowSize()) throw new ApiUsageException("Buffer size incorrect."); final PixelData pd = getRow(y, z, c, t); pd.getData().get(buffer); pd.dispose(); return buffer; }
/** * Implemented as specified by {@link PixelBuffer} I/F. * @see PixelBuffer#getPlaneDirect(Integer, Integer, Integer, byte[]) */ public byte[] getPlaneDirect(Integer z, Integer c, Integer t, byte[] buffer) throws IOException, DimensionsOutOfBoundsException { if (buffer.length != getPlaneSize()) throw new ApiUsageException("Buffer size incorrect."); final PixelData pd = getPlane(z, c, t); pd.getData().get(buffer); pd.dispose(); return buffer; }
/** * Implemented as specified by {@link PixelBuffer} I/F. * @see PixelBuffer#getStackDirect(Integer, Integer, byte[]) */ public byte[] getStackDirect(Integer c, Integer t, byte[] buffer) throws IOException, DimensionsOutOfBoundsException { if (buffer.length != getStackSize()) throw new ApiUsageException("Buffer size incorrect."); final PixelData pd = getStack(c, t); pd.getData().get(buffer); pd.dispose(); return buffer; }
/** * Implemented as specified by {@link PixelBuffer} I/F. * @see PixelBuffer#getTimepointDirect(Integer, byte[]) */ public byte[] getTimepointDirect(Integer t, byte[] buffer) throws IOException, DimensionsOutOfBoundsException { if (buffer.length != getTimepointSize()) throw new ApiUsageException("Buffer size incorrect."); final PixelData pd = getTimepoint(t); pd.getData().get(buffer); pd.dispose(); return buffer; }
/** * Implemented as specified by {@link PixelBuffer} I/F. * @see PixelBuffer#calculateMessageDigest() */ public byte[] calculateMessageDigest() throws IOException { MessageDigest md; try { md = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e) { throw new RuntimeException( "Required SHA-1 message digest algorithm unavailable."); } for (int t = 0; t < getSizeT(); t++) { for (int c = 0; c < getSizeC(); c++) { for (int z = 0; z < getSizeZ(); z++) { try { final PixelData pd = getPlane(z, c, t); md.update(pd.getData()); pd.dispose(); } catch (DimensionsOutOfBoundsException e) { // This better not happen. :) throw new RuntimeException(e); } } } } return md.digest(); }
/** * Implemented as specified by {@link PixelBuffer} I/F. * @see PixelBuffer#getPlane(Integer, Integer, Integer) */ public PixelData getPlane(Integer z, Integer c, Integer t) throws IOException, DimensionsOutOfBoundsException { log.info("Retrieving plane: " + z + "x" + c + "x" + t); Long offset = getPlaneOffset(z, c, t); Integer size = safeLongToInteger(getPlaneSize()); PixelData region = getRegion(size, offset); byte[] nullPlane = PixelsService.nullPlane; for (int i = 0; i < PixelsService.NULL_PLANE_SIZE; i++) { if (region.getData().get(i) != nullPlane[i]) { return region; } } region.dispose(); return null; // All of the nullPlane bytes match, non-filled plane }
PixelData tile = source.getTile(z, c, t, x, y, w, h); pixelsPyramid.setTile( tile.getData().array(), z, c, t, x, y, w, h); tile.dispose(); } finally {
@RolesAllowed("user") public synchronized byte[] getRegion(int arg0, long arg1) { errorIfNotLoaded(); PixelData pd = null; byte[] bytes = null; try { pd = buffer.getRegion(arg0, arg1); bytes = bufferAsByteArrayWithExceptionIfNull(pd.getData()); } catch (Exception e) { handleException(e); } finally { if (pd != null) { pd.dispose(); } } return bytes; }