Class FileFormatReader

  • All Implemented Interfaces:
    FileFormatBoxes

    public class FileFormatReader
    extends Object
    implements FileFormatBoxes
    This class reads the file format wrapper that may or may not exist around a valid JPEG 2000 codestream. Since no information from the file format is used in the actual decoding, this class simply goes through the file and finds the first valid codestream.
    See Also:
    FileFormatWriter
    • Constructor Detail

    • Method Detail

      • readFileFormat

        public void readFileFormat()
                            throws IOException,
                                   EOFException
        This method checks whether the given RandomAccessIO is a valid JP2 file and if so finds the first codestream in the file. Currently, the information in the codestream is not used
        Parameters:
        in - The RandomAccessIO from which to read the file format
        Throws:
        IOException - If an I/O error ocurred.
        EOFException - If end of file is reached
      • readFileTypeBox

        public boolean readFileTypeBox​(int length,
                                       long longLength)
                                throws IOException,
                                       EOFException
        This method reads the File Type box
        Returns:
        false if the File Type box was not found or invalid else true
        Throws:
        IOException - If an I/O error ocurred.
        EOFException - If the end of file was reached
      • readJP2HeaderBox

        public boolean readJP2HeaderBox​(int length)
                                 throws IOException,
                                        EOFException
        This method reads the JP2Header box
        Parameters:
        pos - The position in the file
        length - The length of the JP2Header box
        long - length The length of the JP2Header box if greater than 1<<32
        Returns:
        false if the JP2Header box was not found or invalid else true
        Throws:
        IOException - If an I/O error ocurred.
        EOFException - If the end of file was reached
      • readImageHeaderBox

        public boolean readImageHeaderBox​(int length)
                                   throws IOException,
                                          EOFException
        This method reads the Image Header box
        Parameters:
        length - The length of the JP2Header box
        Returns:
        false if the JP2Header box was not found or invalid else true
        Throws:
        IOException - If an I/O error ocurred.
        EOFException - If the end of file was reached
      • readContiguousCodeStreamBox

        public boolean readContiguousCodeStreamBox​(int length,
                                                   long longLength)
                                            throws IOException,
                                                   EOFException
        This method skips the Contiguous codestream box and adds position of contiguous codestream to a vector
        Parameters:
        pos - The position in the file
        length - The length of the JP2Header box
        long - length The length of the JP2Header box if greater than 1<<32
        Returns:
        false if the Contiguous codestream box was not found or invalid else true
        Throws:
        IOException - If an I/O error ocurred.
        EOFException - If the end of file was reached
      • getCodeStreamPos

        public long[] getCodeStreamPos()
        This method creates and returns an array of positions to contiguous codestreams in the file
        Returns:
        The positions of the contiguous codestreams in the file
      • getFirstCodeStreamPos

        public int getFirstCodeStreamPos()
        This method returns the position of the first contiguous codestreams in the file
        Returns:
        The position of the first contiguous codestream in the file
      • getFirstCodeStreamLength

        public int getFirstCodeStreamLength()
        This method returns the length of the first contiguous codestreams in the file
        Returns:
        The length of the first contiguous codestream in the file