Class JPEGTurboServiceImpl

java.lang.Object
loci.formats.services.JPEGTurboServiceImpl
All Implemented Interfaces:
loci.common.services.Service, JPEGTurboService

public class JPEGTurboServiceImpl extends Object implements JPEGTurboService
Based upon the NDPI to OME-TIFF converter by Matthias Baldauf: http://matthias-baldauf.at/software/ndpi_converter/
Author:
Melissa Linkert melissa at glencoesoftware.com
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • NATIVE_LIB_CLASS

      private static final String NATIVE_LIB_CLASS
      See Also:
    • SOF0

      private static final int SOF0
      See Also:
    • DRI

      private static final int DRI
      See Also:
    • SOS

      private static final int SOS
      See Also:
    • RST0

      private static final int RST0
      See Also:
    • RST7

      private static final int RST7
      See Also:
    • EOI

      private static final int EOI
      See Also:
    • logger

      private transient Logger logger
    • imageWidth

      private int imageWidth
    • imageHeight

      private int imageHeight
    • offset

      private long offset
    • in

      private loci.common.RandomAccessInputStream in
    • restartInterval

      private int restartInterval
    • sos

      private long sos
    • imageDimensions

      private long imageDimensions
    • mcuWidth

      private int mcuWidth
    • mcuHeight

      private int mcuHeight
    • tileWidth

      private int tileWidth
    • tileHeight

      private int tileHeight
    • xTiles

      private int xTiles
    • yTiles

      private int yTiles
    • restartMarkers

      private ArrayList<Long> restartMarkers
    • libraryLoaded

      private static boolean libraryLoaded
  • Constructor Details

    • JPEGTurboServiceImpl

      public JPEGTurboServiceImpl()
  • Method Details

    • setRestartMarkers

      public void setRestartMarkers(long[] markers)
      Specified by:
      setRestartMarkers in interface JPEGTurboService
      Parameters:
      markers - precalculated restart markers associated with the current JPEG stream
    • getRestartMarkers

      public long[] getRestartMarkers()
      Specified by:
      getRestartMarkers in interface JPEGTurboService
      Returns:
      the restart markers associated with the current JPEG stream
    • initialize

      public void initialize(loci.common.RandomAccessInputStream jpeg, int width, int height) throws loci.common.services.ServiceException, IOException
      Description copied from interface: JPEGTurboService
      Initialize the given stream, which represents an image of the given width and height. This service is primarily intended for very large JPEG images whose width and/or height exceed 65535 (the maximum that can be recorded in a JPEG stream).
      Specified by:
      initialize in interface JPEGTurboService
      Parameters:
      jpeg - open stream containing JPEG data
      width - total image width
      height - total image height
      Throws:
      loci.common.services.ServiceException
      IOException
    • getTileWidth

      public int getTileWidth()
      Specified by:
      getTileWidth in interface JPEGTurboService
      Returns:
      the width (in pixels) of a tile
    • getTileHeight

      public int getTileHeight()
      Specified by:
      getTileHeight in interface JPEGTurboService
      Returns:
      the height (in pixels) of a tile
    • getTileRows

      public int getTileRows()
      Specified by:
      getTileRows in interface JPEGTurboService
      Returns:
      the number of rows of tiles
    • getTileColumns

      public int getTileColumns()
      Specified by:
      getTileColumns in interface JPEGTurboService
      Returns:
      the number of columns of tiles
    • getTile

      public byte[] getTile(byte[] buf, int xCoordinate, int yCoordinate, int width, int height) throws IOException
      Description copied from interface: JPEGTurboService
      Get the uncompressed bytes representing the given bounding box.
      Specified by:
      getTile in interface JPEGTurboService
      Parameters:
      buf - array in which to store uncompressed bytes
      xCoordinate - upper-left X coordinate of bounding box
      yCoordinate - upper-left Y coordinate of bounding box
      width - width of bounding box
      height - height of bounding box
      Returns:
      uncompressed bytes
      Throws:
      IOException
    • getTile

      public byte[] getTile(int tileX, int tileY) throws IOException
      Description copied from interface: JPEGTurboService
      Get the uncompressed bytes representing the given tile index.
      Specified by:
      getTile in interface JPEGTurboService
      Parameters:
      tileX - column index of the tile
      tileY - row index of the tile
      Returns:
      uncompressed bytes
      Throws:
      IOException
    • getCompressedTile

      public byte[] getCompressedTile(int tileX, int tileY) throws IOException
      Description copied from interface: JPEGTurboService
      Similar to getTile(int, int), but returns the JPEG-compressed bytes.
      Specified by:
      getCompressedTile in interface JPEGTurboService
      Parameters:
      tileX - column index of the tile
      tileY - row index of the tile
      Returns:
      JPEG-compressed bytes
      Throws:
      IOException
    • getCompressedTile

      public byte[] getCompressedTile(byte[] data, int tileX, int tileY) throws IOException
      Description copied from interface: JPEGTurboService
      Similar to getTile(int, int), but returns the JPEG-compressed bytes.
      Specified by:
      getCompressedTile in interface JPEGTurboService
      Parameters:
      data - preallocated array for storing tile
      tileX - column index of the tile
      tileY - row index of the tile
      Returns:
      JPEG-compressed bytes
      Throws:
      IOException
    • close

      public void close() throws IOException
      Description copied from interface: JPEGTurboService
      Free resources associated with the initialized stream.
      Specified by:
      close in interface JPEGTurboService
      Throws:
      IOException
    • isLibraryLoaded

      public boolean isLibraryLoaded()
      Specified by:
      isLibraryLoaded in interface JPEGTurboService
      Returns:
      true if the underlying native library was successfully loaded
    • getFixedHeader

      private byte[] getFixedHeader() throws IOException
      Throws:
      IOException
    • parseSOF

      private void parseSOF() throws IOException
      Throws:
      IOException