Package jj2000.j2k.fileformat.reader
Class FileFormatReader
- java.lang.Object
-
- jj2000.j2k.fileformat.reader.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
-
-
Field Summary
-
Fields inherited from interface jj2000.j2k.fileformat.FileFormatBoxes
BITS_PER_COMPONENT_BOX, CAPTURE_RESOLUTION_BOX, CHANNEL_DEFINITION_BOX, COLOUR_SPECIFICATION_BOX, COMPONENT_MAPPING_BOX, CONTIGUOUS_CODESTREAM_BOX, CSB_APPROX, CSB_ENUM_GREY, CSB_ENUM_SRGB, CSB_ENUM_YCC, CSB_METH, CSB_PREC, DEFAULT_DISPLAY_RESOLUTION_BOX, FILE_TYPE_BOX, FT_BR, IMAGE_HEADER_BOX, IMB_C, IMB_IPR, IMB_UnkC, IMB_VERS, INTELLECTUAL_PROPERTY_BOX, JP2_HEADER_BOX, JP2_SIGNATURE_BOX, PALETTE_BOX, RESOLUTION_BOX, URL_BOX, UUID_BOX, UUID_INFO_BOX, UUID_LIST_BOX, XML_BOX
-
-
Constructor Summary
Constructors Constructor Description FileFormatReader(RandomAccessIO in, J2KMetadata metadata)
The constructor of the FileFormatReader
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long[]
getCodeStreamPos()
This method creates and returns an array of positions to contiguous codestreams in the fileColorModel
getColorModel()
Returns the color model created from the palette box.int
getFirstCodeStreamLength()
This method returns the length of the first contiguous codestreams in the fileint
getFirstCodeStreamPos()
This method returns the position of the first contiguous codestreams in the filevoid
readBitsPerComponentBox(int length)
Read the bits per component.void
readChannelDefinitionBox(int length)
This method reads the Channel Definition boxvoid
readColourSpecificationBox(int length)
Read the color specifications.void
readComponentMappingBox(int length)
Read the component mapping channel.boolean
readContiguousCodeStreamBox(int length, long longLength)
This method skips the Contiguous codestream box and adds position of contiguous codestream to a vectorvoid
readFileFormat()
This method checks whether the given RandomAccessIO is a valid JP2 file and if so finds the first codestream in the file.boolean
readFileTypeBox(int length, long longLength)
This method reads the File Type boxboolean
readImageHeaderBox(int length)
This method reads the Image Header boxvoid
readIntPropertyBox(int length)
This method reads the contents of the Intellectual property boxboolean
readJP2HeaderBox(int length)
This method reads the JP2Header boxvoid
readPaletteBox(int length)
This method reads the content of the palette boxvoid
readResolutionBox(int type, int length)
Read the resolution.void
readURLBox(int length)
This method reads the contents of the XML boxvoid
readUUIDBox(int length)
This method reads the contents of the Intellectual property boxvoid
readUUIDListBox(int length)
This method reads the contents of the UUID List boxvoid
readXMLBox(int length)
This method reads the contents of the XML box
-
-
-
Constructor Detail
-
FileFormatReader
public FileFormatReader(RandomAccessIO in, J2KMetadata metadata)
The constructor of the FileFormatReader- Parameters:
in
- The RandomAccessIO from which to read the file format
-
-
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- 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:
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
-
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:
length
- The length of the JP2Header boxlongLength
- 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
-
readIntPropertyBox
public void readIntPropertyBox(int length) throws IOException
This method reads the contents of the Intellectual property box- Throws:
IOException
-
readXMLBox
public void readXMLBox(int length) throws IOException
This method reads the contents of the XML box- Throws:
IOException
-
readURLBox
public void readURLBox(int length) throws IOException
This method reads the contents of the XML box- Throws:
IOException
-
readUUIDBox
public void readUUIDBox(int length) throws IOException
This method reads the contents of the Intellectual property box- Throws:
IOException
-
readUUIDListBox
public void readUUIDListBox(int length) throws IOException
This method reads the contents of the UUID List box- Throws:
IOException
-
readPaletteBox
public void readPaletteBox(int length) throws IOException
This method reads the content of the palette box- Throws:
IOException
-
readComponentMappingBox
public void readComponentMappingBox(int length) throws IOException
Read the component mapping channel.- Throws:
IOException
-
readChannelDefinitionBox
public void readChannelDefinitionBox(int length) throws IOException
This method reads the Channel Definition box- Throws:
IOException
- If an I/O error ocurred.
-
readBitsPerComponentBox
public void readBitsPerComponentBox(int length) throws IOException
Read the bits per component.- Throws:
IOException
-
readColourSpecificationBox
public void readColourSpecificationBox(int length) throws IOException
Read the color specifications.- Throws:
IOException
-
readResolutionBox
public void readResolutionBox(int type, int length) throws IOException
Read the resolution.- Throws:
IOException
-
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
-
getColorModel
public ColorModel getColorModel()
Returns the color model created from the palette box.
-
-