Class BfPixelBuffer

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Serializable, java.lang.AutoCloseable, PixelBuffer

    public class BfPixelBuffer
    extends java.lang.Object
    implements PixelBuffer, java.io.Serializable
    PixelBuffer implementation which uses Bio-Formats to read pixels data directly from original files.
    Since:
    Beta4.1
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected loci.formats.IFormatReader bfReader  
      protected java.lang.String filePath  
      protected java.util.concurrent.atomic.AtomicReference<BfPixelsWrapper> reader  
    • Constructor Summary

      Constructors 
      Constructor Description
      BfPixelBuffer​(java.lang.String filePath, loci.formats.IFormatReader bfReader)
      We may want a constructor that takes the id of an imported file or that takes a File object? There should ultimately be some sort of check here that the file is in a/the repository.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] calculateMessageDigest()
      Calculates a SHA-1 message digest for the entire pixel buffer.
      void checkBounds​(java.lang.Integer x, java.lang.Integer y, java.lang.Integer z, java.lang.Integer c, java.lang.Integer t)
      Checks to ensure that no one particular axis has an offset out of bounds.
      void close()
      Closes the buffer, cleaning up file state.
      int getByteWidth()
      Returns the byte width for the pixel buffer.
      ome.util.PixelData getCol​(java.lang.Integer x, java.lang.Integer z, java.lang.Integer c, java.lang.Integer t)
      Retrieves a particular column from this pixel buffer.
      byte[] getColDirect​(java.lang.Integer x, java.lang.Integer z, java.lang.Integer c, java.lang.Integer t, byte[] buffer)
      Retrieves a particular column from this pixel buffer.
      java.lang.Integer getColSize()
      Retrieves the in memory size of a column of pixels in this pixel buffer.
      ome.util.PixelData getHypercube​(java.util.List<java.lang.Integer> offset, java.util.List<java.lang.Integer> size, java.util.List<java.lang.Integer> step)
      Retrieves a hypercube from this pixel buffer.
      byte[] getHypercubeDirect​(java.util.List<java.lang.Integer> offset, java.util.List<java.lang.Integer> size, java.util.List<java.lang.Integer> step, byte[] buffer)
      Retrieves a hypercube from the given pixels directly.
      java.lang.Long getHypercubeSize​(java.util.List<java.lang.Integer> offset, java.util.List<java.lang.Integer> size, java.util.List<java.lang.Integer> step)
      Retrieves a the size of a hypercube from this pixel buffer.
      long getId()
      Retrieves the identifier of this pixel buffer
      java.lang.String getPath()
      Retrieves the full path to this pixel buffer on disk
      ome.util.PixelData getPlane​(java.lang.Integer z, java.lang.Integer c, java.lang.Integer t)
      Retrieves a particular 2D image plane from this pixel buffer.
      byte[] getPlaneDirect​(java.lang.Integer z, java.lang.Integer c, java.lang.Integer t, byte[] buffer)
      Retrieves a particular 2D image plane from this pixel buffer.
      java.lang.Long getPlaneOffset​(java.lang.Integer z, java.lang.Integer c, java.lang.Integer t)
      Retrieves the offset for a particular 2D image plane in this pixel buffer.
      ome.util.PixelData getPlaneRegion​(java.lang.Integer x, java.lang.Integer y, java.lang.Integer width, java.lang.Integer height, java.lang.Integer z, java.lang.Integer c, java.lang.Integer t, java.lang.Integer stride)
      Retrieves a particular region of a 2D image plane from this pixel buffer.
      byte[] getPlaneRegionDirect​(java.lang.Integer z, java.lang.Integer c, java.lang.Integer t, java.lang.Integer count, java.lang.Integer offset, byte[] buffer)
      Retrieves a region from a given plane directly.
      java.lang.Long getPlaneSize()
      Retrieves the in memory size of a 2D image plane in this pixel buffer.
      ome.util.PixelData getRegion​(java.lang.Integer size, java.lang.Long offset)
      Retrieves a region from this pixel buffer.
      byte[] getRegionDirect​(java.lang.Integer size, java.lang.Long offset, byte[] buffer)
      Retrieves a region from this pixel buffer directly.
      java.util.List<java.util.List<java.lang.Integer>> getResolutionDescriptions()
      Return a list of lists each of which has sizeX, sizeY for the resolution level matching the index of the outer index.
      int getResolutionLevel()
      Retrieves the active resolution level.
      int getResolutionLevels()
      Retrieves the number of resolution levels that the backing pixels pyramid contains.
      ome.util.PixelData getRow​(java.lang.Integer y, java.lang.Integer z, java.lang.Integer c, java.lang.Integer t)
      Retrieves a particular row or scanline from this pixel buffer.
      byte[] getRowDirect​(java.lang.Integer y, java.lang.Integer z, java.lang.Integer c, java.lang.Integer t, byte[] buffer)
      Retrieves a particular row or scanline from this pixel buffer.
      java.lang.Long getRowOffset​(java.lang.Integer y, java.lang.Integer z, java.lang.Integer c, java.lang.Integer t)
      Retrieves the offset for a particular row or scanline in this pixel buffer.
      java.lang.Integer getRowSize()
      Retrieves the in memory size of a row or scanline of pixels in this pixel buffer.
      int getSeries()
      Retrieves the current series of the underlying Bio-Formats reader.
      int getSizeC()
      Retrieves the size in C of this pixel buffer
      int getSizeT()
      Retrieves the size in T of this pixel buffer
      int getSizeX()
      Retrieves the size in X of this pixel buffer
      int getSizeY()
      Retrieves the size in Y of this pixel buffer
      int getSizeZ()
      Retrieves the size in Z of this pixel buffer
      ome.util.PixelData getStack​(java.lang.Integer c, java.lang.Integer t)
      Retrieves the the entire number of optical sections for a single wavelength or channel at a particular timepoint in this pixel buffer.
      byte[] getStackDirect​(java.lang.Integer c, java.lang.Integer t, byte[] buffer)
      Retrieves the the entire number of optical sections for a single wavelength or channel at a particular timepoint in this pixel buffer.
      java.lang.Long getStackOffset​(java.lang.Integer c, java.lang.Integer t)
      Retrieves the offset for the entire number of optical sections for a single wavelength or channel at a particular timepoint in this pixel buffer.
      java.lang.Long getStackSize()
      Retrieves the in memory size of the entire number of optical sections for a single wavelength or channel at a particular timepoint in this pixel buffer.
      ome.util.PixelData getTile​(java.lang.Integer z, java.lang.Integer c, java.lang.Integer t, java.lang.Integer x, java.lang.Integer y, java.lang.Integer w, java.lang.Integer h)
      Retrieves a tile from this pixel buffer.
      byte[] getTileDirect​(java.lang.Integer z, java.lang.Integer c, java.lang.Integer t, java.lang.Integer x, java.lang.Integer y, java.lang.Integer w, java.lang.Integer h, byte[] buffer)
      Retrieves a tile from this pixel buffer.
      java.awt.Dimension getTileSize()
      Retrieves the tile size for the pixel store.
      ome.util.PixelData getTimepoint​(java.lang.Integer t)
      Retrieves the entire number of optical sections for all wavelengths or channels at a particular timepoint in this pixel buffer.
      byte[] getTimepointDirect​(java.lang.Integer t, byte[] buffer)
      Retrieves the entire number of optical sections for all wavelengths or channels at a particular timepoint in this pixel buffer.
      java.lang.Long getTimepointOffset​(java.lang.Integer t)
      Retrieves the in memory size of the entire number of optical sections for all wavelengths or channels at a particular timepoint in this pixel buffer.
      java.lang.Long getTimepointSize()
      Retrieves the in memory size of the entire number of optical sections for all wavelengths or channels at a particular timepoint in this pixel buffer.
      java.lang.Long getTotalSize()
      Retrieves the in memory size of the entire pixel buffer.
      boolean isFloat()
      Returns whether or not the pixel buffer has floating point pixels.
      boolean isLittleEndian()
      Delegates to IFormatReader.isLittleEndian().
      boolean isSigned()
      Returns whether or not the pixel buffer has signed pixels.
      protected BfPixelsWrapper reader()
      Do not call this method when looking to close the reader.
      void setPlane​(byte[] buffer, java.lang.Integer z, java.lang.Integer c, java.lang.Integer t)
      Sets a particular 2D image plane in this pixel buffer.
      void setPlane​(java.nio.ByteBuffer buffer, java.lang.Integer z, java.lang.Integer c, java.lang.Integer t)
      Sets a particular 2D image plane in this pixel buffer.
      void setRegion​(java.lang.Integer size, java.lang.Long offset, byte[] buffer)
      Sets a region in this pixel buffer.
      void setRegion​(java.lang.Integer size, java.lang.Long offset, java.nio.ByteBuffer buffer)
      Sets a region in this pixel buffer.
      void setResolutionLevel​(int resolutionLevel)
      Sets the active resolution level.
      void setRow​(java.nio.ByteBuffer buffer, java.lang.Integer y, java.lang.Integer z, java.lang.Integer c, java.lang.Integer t)
      Sets a particular row or scanline in this pixel buffer.
      void setSeries​(int series)
      Sets the current series in the underlying Bio-Formats reader.
      void setStack​(byte[] buffer, java.lang.Integer z, java.lang.Integer c, java.lang.Integer t)
      Sets the entire number of optical sections for a single wavelength or channel at a particular timepoint in this pixel buffer.
      void setStack​(java.nio.ByteBuffer buffer, java.lang.Integer z, java.lang.Integer c, java.lang.Integer t)
      Sets the entire number of optical sections for a single wavelength or channel at a particular timepoint in this pixel buffer.
      void setTile​(byte[] buffer, java.lang.Integer z, java.lang.Integer c, java.lang.Integer t, java.lang.Integer x, java.lang.Integer y, java.lang.Integer w, java.lang.Integer h)
      Sets a tile in this pixel buffer.
      void setTimepoint​(byte[] buffer, java.lang.Integer t)
      Sets the entire number of optical sections for all wavelengths or channels at a particular timepoint in this pixel buffer.
      void setTimepoint​(java.nio.ByteBuffer buffer, java.lang.Integer t)
      Sets the entire number of optical sections for all wavelengths or channels at a particular timepoint in this pixel buffer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • filePath

        protected final java.lang.String filePath
      • bfReader

        protected final loci.formats.IFormatReader bfReader
      • reader

        protected final java.util.concurrent.atomic.AtomicReference<BfPixelsWrapper> reader
    • Constructor Detail

      • BfPixelBuffer

        public BfPixelBuffer​(java.lang.String filePath,
                             loci.formats.IFormatReader bfReader)
                      throws java.io.IOException,
                             loci.formats.FormatException
        We may want a constructor that takes the id of an imported file or that takes a File object? There should ultimately be some sort of check here that the file is in a/the repository.
        Throws:
        java.io.IOException
        loci.formats.FormatException
    • Method Detail

      • reader

        protected BfPixelsWrapper reader()
        Do not call this method when looking to close the reader. Instead, call `reader.get()` directly.
      • isLittleEndian

        public boolean isLittleEndian()
        Delegates to IFormatReader.isLittleEndian().
        Returns:
        See above.
      • setSeries

        public void setSeries​(int series)
        Sets the current series in the underlying Bio-Formats reader.
        Parameters:
        series - The series to set.
      • getSeries

        public int getSeries()
        Retrieves the current series of the underlying Bio-Formats reader.
        Returns:
        The series.
      • calculateMessageDigest

        public byte[] calculateMessageDigest()
                                      throws java.io.IOException
        Description copied from interface: PixelBuffer
        Calculates a SHA-1 message digest for the entire pixel buffer.
        Specified by:
        calculateMessageDigest in interface PixelBuffer
        Returns:
        byte array containing the message digest.
        Throws:
        java.io.IOException - if there is a problem reading from the pixel buffer.
      • checkBounds

        public void checkBounds​(java.lang.Integer x,
                                java.lang.Integer y,
                                java.lang.Integer z,
                                java.lang.Integer c,
                                java.lang.Integer t)
                         throws DimensionsOutOfBoundsException
        Description copied from interface: PixelBuffer
        Checks to ensure that no one particular axis has an offset out of bounds. null may be passed as the argument to any one of the offsets to ignore it for the purposes of bounds checking.
        Specified by:
        checkBounds in interface PixelBuffer
        Parameters:
        x - offset across the X-axis of the pixel buffer to check.
        y - offset across the Y-axis of the pixel buffer to check.
        z - offset across the Z-axis of the pixel buffer to check.
        c - offset across the C-axis of the pixel buffer to check.
        t - offset across the T-axis of the pixel buffer to check.
        Throws:
        DimensionsOutOfBoundsException - if y, z, c or t is out of bounds.
      • close

        public void close()
                   throws java.io.IOException
        Description copied from interface: PixelBuffer
        Closes the buffer, cleaning up file state.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface PixelBuffer
        Throws:
        java.io.IOException - if an I/O error occurs.
      • getByteWidth

        public int getByteWidth()
        Description copied from interface: PixelBuffer
        Returns the byte width for the pixel buffer.
        Specified by:
        getByteWidth in interface PixelBuffer
        Returns:
        See above.
      • getColSize

        public java.lang.Integer getColSize()
        Description copied from interface: PixelBuffer
        Retrieves the in memory size of a column of pixels in this pixel buffer.
        Specified by:
        getColSize in interface PixelBuffer
        Returns:
        column size in bytes (sizeY*ByteWidth)
      • getId

        public long getId()
        Description copied from interface: PixelBuffer
        Retrieves the identifier of this pixel buffer
        Specified by:
        getId in interface PixelBuffer
      • getPath

        public java.lang.String getPath()
        Description copied from interface: PixelBuffer
        Retrieves the full path to this pixel buffer on disk
        Specified by:
        getPath in interface PixelBuffer
        Returns:
        fully qualified path.
      • getPlane

        public ome.util.PixelData getPlane​(java.lang.Integer z,
                                           java.lang.Integer c,
                                           java.lang.Integer t)
                                    throws java.io.IOException,
                                           DimensionsOutOfBoundsException
        Description copied from interface: PixelBuffer
        Retrieves a particular 2D image plane from this pixel buffer.
        Specified by:
        getPlane in interface PixelBuffer
        Parameters:
        z - offset across the Z-axis of the pixel buffer.
        c - offset across the C-axis of the pixel buffer.
        t - offset across the T-axis of the pixel buffer.
        Returns:
        buffer containing the data which comprises this 2D image plane. It is guaranteed that this buffer will have its order set correctly but not that the backing buffer will have been byte swapped.
        Throws:
        java.io.IOException - if there is a problem reading from the pixel buffer.
        DimensionsOutOfBoundsException - if offsets are out of bounds after checking with PixelBuffer.checkBounds(Integer, Integer, Integer, Integer, Integer).
      • getPlaneDirect

        public byte[] getPlaneDirect​(java.lang.Integer z,
                                     java.lang.Integer c,
                                     java.lang.Integer t,
                                     byte[] buffer)
                              throws java.io.IOException,
                                     DimensionsOutOfBoundsException
        Description copied from interface: PixelBuffer
        Retrieves a particular 2D image plane from this pixel buffer.
        Specified by:
        getPlaneDirect in interface PixelBuffer
        Parameters:
        z - offset across the Z-axis of the pixel buffer.
        c - offset across the C-axis of the pixel buffer.
        t - offset across the T-axis of the pixel buffer.
        buffer - pre-allocated buffer of the plane's size.
        Returns:
        buffer containing the data which comprises this 2D image plane. It is guaranteed that this buffer will have been byte swapped.
        Throws:
        java.io.IOException - if there is a problem reading from the pixel buffer.
        DimensionsOutOfBoundsException - if offsets are out of bounds after checking with PixelBuffer.checkBounds(Integer, Integer, Integer, Integer, Integer).
      • getPlaneRegionDirect

        public byte[] getPlaneRegionDirect​(java.lang.Integer z,
                                           java.lang.Integer c,
                                           java.lang.Integer t,
                                           java.lang.Integer count,
                                           java.lang.Integer offset,
                                           byte[] buffer)
                                    throws java.io.IOException,
                                           DimensionsOutOfBoundsException
        Description copied from interface: PixelBuffer
        Retrieves a region from a given plane directly.
        Specified by:
        getPlaneRegionDirect in interface PixelBuffer
        Parameters:
        z - offset across the Z-axis of the pixel buffer.
        c - offset across the C-axis of the pixel buffer.
        t - offset across the T-axis of the pixel buffer.
        count - the number of pixels to retrieve.
        offset - the offset at which to retrieve count pixels.
        buffer - pre-allocated buffer, count in size.
        Returns:
        buffer containing the data which comprises the region of the given 2D image plane. It is guaranteed that this buffer will have been byte swapped.
        Throws:
        java.io.IOException - if there is a problem reading from the pixel buffer.
        DimensionsOutOfBoundsException
        See Also:
        PixelBuffer.getRegionDirect(Integer, Long, byte[])
      • getPlaneSize

        public java.lang.Long getPlaneSize()
        Description copied from interface: PixelBuffer
        Retrieves the in memory size of a 2D image plane in this pixel buffer.
        Specified by:
        getPlaneSize in interface PixelBuffer
        Returns:
        2D image plane size in bytes (sizeX*sizeY*ByteWidth).
      • getRegion

        public ome.util.PixelData getRegion​(java.lang.Integer size,
                                            java.lang.Long offset)
                                     throws java.io.IOException
        Description copied from interface: PixelBuffer
        Retrieves a region from this pixel buffer.
        Specified by:
        getRegion in interface PixelBuffer
        Parameters:
        size - byte width of the region to retrieve.
        offset - offset within the pixel buffer.
        Returns:
        buffer containing the data. It is guaranteed that this buffer will have its order set correctly but not that the backing buffer will have been byte swapped. The buffer is essentially directly from disk.
        Throws:
        java.io.IOException - if there is a problem reading from the pixel buffer.
        See Also:
        PixelBuffer.getRegionDirect(Integer, Long, byte[])
      • getRegionDirect

        public byte[] getRegionDirect​(java.lang.Integer size,
                                      java.lang.Long offset,
                                      byte[] buffer)
                               throws java.io.IOException
        Description copied from interface: PixelBuffer
        Retrieves a region from this pixel buffer directly.
        Specified by:
        getRegionDirect in interface PixelBuffer
        Parameters:
        size - byte width of the region to retrieve.
        offset - offset within the pixel buffer.
        buffer - pre-allocated buffer of the row's size.
        Returns:
        buffer containing the data which comprises this region. It is guaranteed that this buffer will have been byte swapped. The buffer is essentially directly from disk.
        Throws:
        java.io.IOException - if there is a problem reading from the pixel buffer.
        See Also:
        PixelBuffer.getRegion(Integer, Long)
      • getRowSize

        public java.lang.Integer getRowSize()
        Description copied from interface: PixelBuffer
        Retrieves the in memory size of a row or scanline of pixels in this pixel buffer.
        Specified by:
        getRowSize in interface PixelBuffer
        Returns:
        row or scanline size in bytes (sizeX*ByteWidth)
      • getSizeC

        public int getSizeC()
        Description copied from interface: PixelBuffer
        Retrieves the size in C of this pixel buffer
        Specified by:
        getSizeC in interface PixelBuffer
      • getSizeT

        public int getSizeT()
        Description copied from interface: PixelBuffer
        Retrieves the size in T of this pixel buffer
        Specified by:
        getSizeT in interface PixelBuffer
      • getSizeX

        public int getSizeX()
        Description copied from interface: PixelBuffer
        Retrieves the size in X of this pixel buffer
        Specified by:
        getSizeX in interface PixelBuffer
      • getSizeY

        public int getSizeY()
        Description copied from interface: PixelBuffer
        Retrieves the size in Y of this pixel buffer
        Specified by:
        getSizeY in interface PixelBuffer
      • getSizeZ

        public int getSizeZ()
        Description copied from interface: PixelBuffer
        Retrieves the size in Z of this pixel buffer
        Specified by:
        getSizeZ in interface PixelBuffer
      • getStack

        public ome.util.PixelData getStack​(java.lang.Integer c,
                                           java.lang.Integer t)
                                    throws java.io.IOException,
                                           DimensionsOutOfBoundsException
        Description copied from interface: PixelBuffer
        Retrieves the the entire number of optical sections for a single wavelength or channel at a particular timepoint in this pixel buffer.
        Specified by:
        getStack in interface PixelBuffer
        Parameters:
        c - offset across the C-axis of the pixel buffer.
        t - offset across the T-axis of the pixel buffer.
        Returns:
        buffer containing the data which comprises this stack. It is guaranteed that this buffer will have its order set correctly but not that the backing buffer will have been byte swapped.
        Throws:
        java.io.IOException - if there is a problem reading from the pixel buffer.
        DimensionsOutOfBoundsException - if offsets are out of bounds after checking with PixelBuffer.checkBounds(Integer, Integer, Integer, Integer, Integer).
      • getStackDirect

        public byte[] getStackDirect​(java.lang.Integer c,
                                     java.lang.Integer t,
                                     byte[] buffer)
                              throws java.io.IOException,
                                     DimensionsOutOfBoundsException
        Description copied from interface: PixelBuffer
        Retrieves the the entire number of optical sections for a single wavelength or channel at a particular timepoint in this pixel buffer.
        Specified by:
        getStackDirect in interface PixelBuffer
        Parameters:
        c - offset across the C-axis of the pixel buffer.
        t - offset across the T-axis of the pixel buffer.
        buffer - pre-allocated buffer of the stack's size.
        Returns:
        buffer containing the data which comprises this stack. It is guaranteed that this buffer will have been byte swapped.
        Throws:
        java.io.IOException - if there is a problem reading from the pixel buffer.
        DimensionsOutOfBoundsException - if offsets are out of bounds after checking with PixelBuffer.checkBounds(Integer, Integer, Integer, Integer, Integer).
      • getStackSize

        public java.lang.Long getStackSize()
        Description copied from interface: PixelBuffer
        Retrieves the in memory size of the entire number of optical sections for a single wavelength or channel at a particular timepoint in this pixel buffer.
        Specified by:
        getStackSize in interface PixelBuffer
        Returns:
        stack size in bytes (sizeX*sizeY*sizeZ*ByteWidth).
      • getTimepoint

        public ome.util.PixelData getTimepoint​(java.lang.Integer t)
                                        throws java.io.IOException,
                                               DimensionsOutOfBoundsException
        Description copied from interface: PixelBuffer
        Retrieves the entire number of optical sections for all wavelengths or channels at a particular timepoint in this pixel buffer.
        Specified by:
        getTimepoint in interface PixelBuffer
        Parameters:
        t - offset across the T-axis of the pixel buffer.
        Returns:
        buffer containing the data which comprises this timepoint. It is guaranteed that this buffer will have its order set correctly but not that the backing buffer will have been byte swapped.
        Throws:
        java.io.IOException - if there is a problem reading from the pixel buffer.
        DimensionsOutOfBoundsException - if offsets are out of bounds after checking with PixelBuffer.checkBounds(Integer, Integer, Integer, Integer, Integer).
      • getTimepointDirect

        public byte[] getTimepointDirect​(java.lang.Integer t,
                                         byte[] buffer)
                                  throws java.io.IOException,
                                         DimensionsOutOfBoundsException
        Description copied from interface: PixelBuffer
        Retrieves the entire number of optical sections for all wavelengths or channels at a particular timepoint in this pixel buffer.
        Specified by:
        getTimepointDirect in interface PixelBuffer
        Parameters:
        t - offset across the T-axis of the pixel buffer.
        buffer - pre-allocated buffer of the timepoint's size.
        Returns:
        buffer containing the data which comprises this timepoint. It is guaranteed that this buffer will have been byte swapped.
        Throws:
        java.io.IOException - if there is a problem reading from the pixel buffer.
        DimensionsOutOfBoundsException - if offsets are out of bounds after checking with PixelBuffer.checkBounds(Integer, Integer, Integer, Integer, Integer).
      • getTimepointSize

        public java.lang.Long getTimepointSize()
        Description copied from interface: PixelBuffer
        Retrieves the in memory size of the entire number of optical sections for all wavelengths or channels at a particular timepoint in this pixel buffer.
        Specified by:
        getTimepointSize in interface PixelBuffer
        Returns:
        timepoint size in bytes (sizeX*sizeY*sizeZ*sizeC*ByteWidth).
      • getTotalSize

        public java.lang.Long getTotalSize()
        Description copied from interface: PixelBuffer
        Retrieves the in memory size of the entire pixel buffer.
        Specified by:
        getTotalSize in interface PixelBuffer
        Returns:
        total size of the pixel size in bytes (sizeX*sizeY*sizeZ*sizeC*sizeT*ByteWidth).
      • isFloat

        public boolean isFloat()
        Description copied from interface: PixelBuffer
        Returns whether or not the pixel buffer has floating point pixels.
        Specified by:
        isFloat in interface PixelBuffer
        Returns:
        true if the pixel buffer as floating point, false otherwise
      • isSigned

        public boolean isSigned()
        Description copied from interface: PixelBuffer
        Returns whether or not the pixel buffer has signed pixels.
        Specified by:
        isSigned in interface PixelBuffer
        Returns:
        See above.
      • setPlane

        public void setPlane​(java.nio.ByteBuffer buffer,
                             java.lang.Integer z,
                             java.lang.Integer c,
                             java.lang.Integer t)
                      throws java.io.IOException,
                             DimensionsOutOfBoundsException,
                             java.nio.BufferOverflowException
        Description copied from interface: PixelBuffer
        Sets a particular 2D image plane in this pixel buffer.
        Specified by:
        setPlane in interface PixelBuffer
        Parameters:
        buffer - a byte array of the data comprising this 2D image plane.
        z - offset across the Z-axis of the pixel buffer.
        c - offset across the C-axis of the pixel buffer.
        t - offset across the T-axis of the pixel buffer.
        Throws:
        java.io.IOException - if there is a problem writing to the pixel buffer.
        DimensionsOutOfBoundsException - if offsets are out of bounds after checking with PixelBuffer.checkBounds(Integer, Integer, Integer, Integer, Integer).
        java.nio.BufferOverflowException - if buffer.length > {@link #getPlaneSize()}.
      • setPlane

        public void setPlane​(byte[] buffer,
                             java.lang.Integer z,
                             java.lang.Integer c,
                             java.lang.Integer t)
                      throws java.io.IOException,
                             DimensionsOutOfBoundsException,
                             java.nio.BufferOverflowException
        Description copied from interface: PixelBuffer
        Sets a particular 2D image plane in this pixel buffer.
        Specified by:
        setPlane in interface PixelBuffer
        Parameters:
        buffer - a byte buffer of the data comprising this 2D image plane.
        z - offset across the Z-axis of the pixel buffer.
        c - offset across the C-axis of the pixel buffer.
        t - offset across the T-axis of the pixel buffer.
        Throws:
        java.io.IOException - if there is a problem writing to the pixel buffer.
        DimensionsOutOfBoundsException - if offsets are out of bounds after checking with PixelBuffer.checkBounds(Integer, Integer, Integer, Integer, Integer).
        java.nio.BufferOverflowException - if buffer.length > {@link #getPlaneSize()}.
      • setRegion

        public void setRegion​(java.lang.Integer size,
                              java.lang.Long offset,
                              byte[] buffer)
                       throws java.io.IOException,
                              java.nio.BufferOverflowException
        Description copied from interface: PixelBuffer
        Sets a region in this pixel buffer.
        Specified by:
        setRegion in interface PixelBuffer
        Parameters:
        size - byte width of the region to set.
        offset - offset within the pixel buffer.
        buffer - a byte array of the data.
        Throws:
        java.io.IOException - if there is a problem writing to the pixel buffer.
        java.nio.BufferOverflowException - if buffer.length > size.
      • setRegion

        public void setRegion​(java.lang.Integer size,
                              java.lang.Long offset,
                              java.nio.ByteBuffer buffer)
                       throws java.io.IOException,
                              java.nio.BufferOverflowException
        Description copied from interface: PixelBuffer
        Sets a region in this pixel buffer.
        Specified by:
        setRegion in interface PixelBuffer
        Parameters:
        size - byte width of the region to set.
        offset - offset within the pixel buffer.
        buffer - a byte buffer of the data.
        Throws:
        java.io.IOException - if there is a problem writing to the pixel buffer.
        java.nio.BufferOverflowException - if buffer.length > size.
      • setRow

        public void setRow​(java.nio.ByteBuffer buffer,
                           java.lang.Integer y,
                           java.lang.Integer z,
                           java.lang.Integer c,
                           java.lang.Integer t)
                    throws java.io.IOException,
                           DimensionsOutOfBoundsException,
                           java.nio.BufferOverflowException
        Description copied from interface: PixelBuffer
        Sets a particular row or scanline in this pixel buffer.
        Specified by:
        setRow in interface PixelBuffer
        Parameters:
        buffer - a byte buffer of the data comprising this row or scanline.
        y - offset across the Y-axis of the pixel buffer.
        z - offset across the Z-axis of the pixel buffer.
        c - offset across the C-axis of the pixel buffer.
        t - offset across the T-axis of the pixel buffer.
        Throws:
        java.io.IOException - if there is a problem reading from the pixel buffer.
        DimensionsOutOfBoundsException - if offsets are out of bounds after checking with PixelBuffer.checkBounds(Integer, Integer, Integer, Integer, Integer).
        java.nio.BufferOverflowException - if buffer.length > {@link #getRowSize()}.
      • setStack

        public void setStack​(java.nio.ByteBuffer buffer,
                             java.lang.Integer z,
                             java.lang.Integer c,
                             java.lang.Integer t)
                      throws java.io.IOException,
                             DimensionsOutOfBoundsException,
                             java.nio.BufferOverflowException
        Description copied from interface: PixelBuffer
        Sets the entire number of optical sections for a single wavelength or channel at a particular timepoint in this pixel buffer.
        Specified by:
        setStack in interface PixelBuffer
        Parameters:
        buffer - a byte buffer of the data comprising this stack.
        c - offset across the C-axis of the pixel buffer.
        t - offset across the T-axis of the pixel buffer.
        Throws:
        java.io.IOException - if there is a problem writing to the pixel buffer.
        DimensionsOutOfBoundsException - if offsets are out of bounds after checking with PixelBuffer.checkBounds(Integer, Integer, Integer, Integer, Integer).
        java.nio.BufferOverflowException - if buffer.length > {@link #getStackSize()}.
      • setStack

        public void setStack​(byte[] buffer,
                             java.lang.Integer z,
                             java.lang.Integer c,
                             java.lang.Integer t)
                      throws java.io.IOException,
                             DimensionsOutOfBoundsException,
                             java.nio.BufferOverflowException
        Description copied from interface: PixelBuffer
        Sets the entire number of optical sections for a single wavelength or channel at a particular timepoint in this pixel buffer.
        Specified by:
        setStack in interface PixelBuffer
        Parameters:
        buffer - a byte array of the data comprising this stack.
        z - offset across the Z-axis of the pixel buffer.
        c - offset across the C-axis of the pixel buffer.
        t - offset across the T-axis of the pixel buffer.
        Throws:
        java.io.IOException - if there is a problem writing to the pixel buffer.
        DimensionsOutOfBoundsException - if offsets are out of bounds after checking with PixelBuffer.checkBounds(Integer, Integer, Integer, Integer, Integer).
        java.nio.BufferOverflowException - if buffer.length > {@link #getStackSize()}.
      • setTimepoint

        public void setTimepoint​(java.nio.ByteBuffer buffer,
                                 java.lang.Integer t)
                          throws java.io.IOException,
                                 DimensionsOutOfBoundsException,
                                 java.nio.BufferOverflowException
        Description copied from interface: PixelBuffer
        Sets the entire number of optical sections for all wavelengths or channels at a particular timepoint in this pixel buffer.
        Specified by:
        setTimepoint in interface PixelBuffer
        Parameters:
        buffer - a byte buffer of the data comprising this timepoint.
        t - offset across the T-axis of the pixel buffer.
        Throws:
        java.io.IOException - if there is a problem writing to the pixel buffer.
        DimensionsOutOfBoundsException - if offsets are out of bounds after checking with PixelBuffer.checkBounds(Integer, Integer, Integer, Integer, Integer).
        java.nio.BufferOverflowException - if buffer.length > {@link #getTimepointSize()}.
      • setTimepoint

        public void setTimepoint​(byte[] buffer,
                                 java.lang.Integer t)
                          throws java.io.IOException,
                                 DimensionsOutOfBoundsException,
                                 java.nio.BufferOverflowException
        Description copied from interface: PixelBuffer
        Sets the entire number of optical sections for all wavelengths or channels at a particular timepoint in this pixel buffer.
        Specified by:
        setTimepoint in interface PixelBuffer
        Parameters:
        buffer - a byte array of the data comprising this timepoint.
        t - offset across the T-axis of the pixel buffer.
        Throws:
        java.io.IOException - if there is a problem writing to the pixel buffer.
        DimensionsOutOfBoundsException - if offsets are out of bounds after checking with PixelBuffer.checkBounds(Integer, Integer, Integer, Integer, Integer).
        java.nio.BufferOverflowException - if buffer.length > {@link #getTimepointSize()}.
      • getHypercubeSize

        public java.lang.Long getHypercubeSize​(java.util.List<java.lang.Integer> offset,
                                               java.util.List<java.lang.Integer> size,
                                               java.util.List<java.lang.Integer> step)
                                        throws DimensionsOutOfBoundsException
        Description copied from interface: PixelBuffer
        Retrieves a the size of a hypercube from this pixel buffer.
        Specified by:
        getHypercubeSize in interface PixelBuffer
        Parameters:
        offset - The offset of each dimension of the pixel buffer.
        size - The number of pixels to retrieve along each dimension .
        step - The step size across each dimension .
        Returns:
        the size.
        Throws:
        DimensionsOutOfBoundsException
      • getHypercube

        public ome.util.PixelData getHypercube​(java.util.List<java.lang.Integer> offset,
                                               java.util.List<java.lang.Integer> size,
                                               java.util.List<java.lang.Integer> step)
                                        throws java.io.IOException,
                                               DimensionsOutOfBoundsException
        Description copied from interface: PixelBuffer
        Retrieves a hypercube from this pixel buffer.
        Specified by:
        getHypercube in interface PixelBuffer
        Parameters:
        offset - The offset of each dimension of the pixel buffer.
        size - The number of pixels to retrieve along each dimension .
        step - The step size across each dimension .
        Returns:
        buffer containing the data.
        Throws:
        java.io.IOException - if there is a problem reading from the pixel buffer.
        DimensionsOutOfBoundsException
      • getHypercubeDirect

        public byte[] getHypercubeDirect​(java.util.List<java.lang.Integer> offset,
                                         java.util.List<java.lang.Integer> size,
                                         java.util.List<java.lang.Integer> step,
                                         byte[] buffer)
                                  throws java.io.IOException,
                                         DimensionsOutOfBoundsException
        Description copied from interface: PixelBuffer
        Retrieves a hypercube from the given pixels directly.
        Specified by:
        getHypercubeDirect in interface PixelBuffer
        Parameters:
        offset - The offset of each dimension of the pixel buffer.
        size - The number of pixels to retrieve along each dimension .
        step - The step size across each dimension .
        buffer - pre-allocated buffer, count in size.
        Returns:
        buffer containing the data.
        Throws:
        java.io.IOException - if there is a problem reading from the pixel buffer.
        DimensionsOutOfBoundsException
      • getPlaneRegion

        public ome.util.PixelData getPlaneRegion​(java.lang.Integer x,
                                                 java.lang.Integer y,
                                                 java.lang.Integer width,
                                                 java.lang.Integer height,
                                                 java.lang.Integer z,
                                                 java.lang.Integer c,
                                                 java.lang.Integer t,
                                                 java.lang.Integer stride)
                                          throws java.io.IOException,
                                                 DimensionsOutOfBoundsException
        Description copied from interface: PixelBuffer
        Retrieves a particular region of a 2D image plane from this pixel buffer.
        Specified by:
        getPlaneRegion in interface PixelBuffer
        Parameters:
        x - offset across the X-axis of the pixel buffer.
        y - offset across the Y-axis of the pixel buffer.
        width - The number of pixels to retrieve along the X-axis.
        height - The number of pixels to retrieve along the Y-axis.
        z - offset across the Z-axis of the pixel buffer.
        c - offset across the C-axis of the pixel buffer.
        t - offset across the T-axis of the pixel buffer.
        stride - The step size.
        Returns:
        buffer containing the data which comprises this 2D image plane. It is guaranteed that this buffer will have its order set correctly but not that the backing buffer will have been byte swapped.
        Throws:
        java.io.IOException - if there is a problem reading from the pixel buffer.
        DimensionsOutOfBoundsException - if offsets are out of bounds after checking with PixelBuffer.checkBounds(Integer, Integer, Integer, Integer, Integer).
      • getTile

        public ome.util.PixelData getTile​(java.lang.Integer z,
                                          java.lang.Integer c,
                                          java.lang.Integer t,
                                          java.lang.Integer x,
                                          java.lang.Integer y,
                                          java.lang.Integer w,
                                          java.lang.Integer h)
                                   throws java.io.IOException
        Description copied from interface: PixelBuffer
        Retrieves a tile from this pixel buffer.
        Specified by:
        getTile in interface PixelBuffer
        Parameters:
        z - offset across the Z-axis of the pixel buffer.
        c - offset across the C-axis of the pixel buffer.
        t - offset across the T-axis of the pixel buffer.
        x - Top left corner of the tile, X offset.
        y - Top left corner of the tile, Y offset.
        w - Width of the tile.
        h - Height of the tile.
        Returns:
        buffer containing the data which comprises the region of the given 2D image plane. It is guaranteed that this buffer will have been byte swapped.
        Throws:
        java.io.IOException - if there is a problem reading from the pixel buffer.
        See Also:
        PixelBuffer.getTileDirect(Integer, Integer, Integer, Integer, Integer, Integer, Integer, byte[])
      • getTileDirect

        public byte[] getTileDirect​(java.lang.Integer z,
                                    java.lang.Integer c,
                                    java.lang.Integer t,
                                    java.lang.Integer x,
                                    java.lang.Integer y,
                                    java.lang.Integer w,
                                    java.lang.Integer h,
                                    byte[] buffer)
                             throws java.io.IOException
        Description copied from interface: PixelBuffer
        Retrieves a tile from this pixel buffer.
        Specified by:
        getTileDirect in interface PixelBuffer
        Parameters:
        z - offset across the Z-axis of the pixel buffer.
        c - offset across the C-axis of the pixel buffer.
        t - offset across the T-axis of the pixel buffer.
        x - Top left corner of the tile, X offset.
        y - Top left corner of the tile, Y offset.
        w - Width of the tile.
        h - Height of the tile.
        buffer - Pre-allocated buffer of the tile's size.
        Returns:
        buffer containing the data which comprises this region. It is guaranteed that this buffer will have been byte swapped. The buffer is essentially directly from disk.
        Throws:
        java.io.IOException - if there is a problem reading from the pixel buffer.
        See Also:
        PixelBuffer.getTile(Integer, Integer, Integer, Integer, Integer, Integer, Integer)
      • setTile

        public void setTile​(byte[] buffer,
                            java.lang.Integer z,
                            java.lang.Integer c,
                            java.lang.Integer t,
                            java.lang.Integer x,
                            java.lang.Integer y,
                            java.lang.Integer w,
                            java.lang.Integer h)
                     throws java.io.IOException,
                            java.nio.BufferOverflowException
        Description copied from interface: PixelBuffer
        Sets a tile in this pixel buffer.
        Specified by:
        setTile in interface PixelBuffer
        Parameters:
        buffer - A byte array of the data.
        z - offset across the Z-axis of the pixel buffer.
        c - offset across the C-axis of the pixel buffer.
        t - offset across the T-axis of the pixel buffer.
        x - Top left corner of the tile, X offset.
        y - Top left corner of the tile, Y offset.
        w - Width of the tile.
        h - Height of the tile.
        Throws:
        java.io.IOException - if there is a problem writing to the pixel buffer.
        java.nio.BufferOverflowException - if an attempt is made to write off the end of the file.
      • getResolutionLevel

        public int getResolutionLevel()
        Description copied from interface: PixelBuffer
        Retrieves the active resolution level.
        Specified by:
        getResolutionLevel in interface PixelBuffer
        Returns:
        The active resolution level. The level will be non-negative and less than PixelBuffer.getResolutionLevels(). Resolution level 0 is the smallest resolution and resolution level getResolutionLevels() - 1 is the largest resolution. This is the inverse of how Bio-Formats indexes resolutions.
      • getResolutionLevels

        public int getResolutionLevels()
        Description copied from interface: PixelBuffer
        Retrieves the number of resolution levels that the backing pixels pyramid contains.
        Specified by:
        getResolutionLevels in interface PixelBuffer
        Returns:
        The number of resolution levels. This value does not necessarily indicate either the presence or absence of a pixels pyramid.
      • getTileSize

        public java.awt.Dimension getTileSize()
        Description copied from interface: PixelBuffer
        Retrieves the tile size for the pixel store.
        Specified by:
        getTileSize in interface PixelBuffer
        Returns:
        The dimension of the tile or null if the pixel buffer is not tiled.
      • getResolutionDescriptions

        public java.util.List<java.util.List<java.lang.Integer>> getResolutionDescriptions()
        Description copied from interface: PixelBuffer
        Return a list of lists each of which has sizeX, sizeY for the resolution level matching the index of the outer index. For example, if an image has 2 resolution levels of size 2048x1024 and 1024x512 then this returns: [[2048,1024],[1024,512]]
        Specified by:
        getResolutionDescriptions in interface PixelBuffer
        Returns:
        a list of lists containing sizeX, sizeY for each resolution level
      • setResolutionLevel

        public void setResolutionLevel​(int resolutionLevel)
        Description copied from interface: PixelBuffer
        Sets the active resolution level.
        Specified by:
        setResolutionLevel in interface PixelBuffer
        Parameters:
        resolutionLevel - The resolution level to be used by the pixel buffer. The level should be non-negative and less than PixelBuffer.getResolutionLevels(). Resolution level 0 is the smallest resolution and resolution level getResolutionLevels() - 1 is the largest resolution. This is the inverse of how Bio-Formats indexes resolutions.