loci.formats.in

## Class JPEG2000MetadataParser

- java.lang.Object
- - loci.formats.in.JPEG2000MetadataParser

-     public class JPEG2000MetadataParser
      extends java.lang.Object

  A parser for JPEG 2000 metadata.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private long` | `codestreamOffset` Offset to first contiguous codestream.
    `private java.lang.Integer` | `codestreamPixelType` Pixel type as specified in the JPEG 2000 codestream..
    `private java.lang.Short` | `codestreamSizeC` Number of channels the image as specified in the JPEG 2000 codestream.
    `private java.lang.Integer` | `codestreamSizeX` Width of the image as specified in the JPEG 2000 codestream.
    `private java.lang.Integer` | `codestreamSizeY` Height of the image as specified in the JPEG 2000 codestream.
    `private java.util.ArrayList<java.lang.String>` | `comments` List of comments stored in the file.
    `private java.lang.Integer` | `headerPixelType` Pixel type as specified in the header.
    `private java.lang.Short` | `headerSizeC` Number of channels the image has as specified in the header.
    `private java.lang.Integer` | `headerSizeX` Width of the image as specified in the header.
    `private java.lang.Integer` | `headerSizeY` Height of the image as specified in the header.
    `private loci.common.RandomAccessInputStream` | `in` Stream that we're parsing metadata from.
    `private boolean` | `isRawCodestream` Whether or not the codestream is raw and not JP2 boxed.
    `private static org.slf4j.Logger` | `LOGGER` Logger for this class.
    `private int[][]` | `lut` Color lookup table stored in the file.
    `private long` | `maximumReadOffset` Maximum read offset within in the stream.
    `private java.lang.Integer` | `resolutionLevels` Number of JPEG 2000 resolution levels the file has.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JPEG2000MetadataParser(loci.common.RandomAccessInputStream in)` Constructs a new JPEG2000MetadataParser.
    `JPEG2000MetadataParser(loci.common.RandomAccessInputStream in, long maximumReadOffset)` Constructs a new JPEG2000MetadataParser.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `private int` | `convertPixelType(int type)`
    `long` | `getCodestreamOffset()` Retrieves the offset to the first contiguous codestream.
    `java.lang.Integer` | `getCodestreamPixelType()` Returns the pixel type as specified in the header.
    `java.lang.Short` | `getCodestreamSizeC()` Returns the number of channels the image has as specified in the header.
    `java.lang.Integer` | `getCodestreamSizeX()` Returns the width of the image as specified in the header.
    `java.lang.Integer` | `getCodestreamSizeY()` Returns the height of the image as specified in the header.
    `java.util.ArrayList<java.lang.String>` | `getComments()` Retrieves the list of comments stored in the file.
    `java.lang.Integer` | `getHeaderPixelType()` Returns the pixel type as specified in the header.
    `java.lang.Short` | `getHeaderSizeC()` Returns the number of channels the image has as specified in the header.
    `java.lang.Integer` | `getHeaderSizeX()` Returns the width of the image as specified in the header.
    `java.lang.Integer` | `getHeaderSizeY()` Returns the height of the image as specified in the header.
    `int[][]` | `getLookupTable()` Returns the color lookup table stored in the file, or null if a lookup table is not present.
    `java.lang.Integer` | `getResolutionLevels()` Returns the number of resolution levels the file JPEG 2000 data has.
    `boolean` | `isRawCodestream()` Whether or not the codestream is raw and not JP2 boxed.
    `private void` | `parseBoxes()` Parses the JPEG 2000 JP2 metadata boxes.
    `private void` | `parseContiguousCodestream(long length)` Parses the JPEG 2000 codestream metadata.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### LOGGER

          private static final org.slf4j.Logger LOGGER

      Logger for this class.

    - #### in

          private loci.common.RandomAccessInputStream in

      Stream that we're parsing metadata from.

    - #### codestreamOffset

          private long codestreamOffset

      Offset to first contiguous codestream.

    - #### maximumReadOffset

          private long maximumReadOffset

      Maximum read offset within in the stream.

    - #### headerSizeX

          private java.lang.Integer headerSizeX

      Width of the image as specified in the header.

    - #### headerSizeY

          private java.lang.Integer headerSizeY

      Height of the image as specified in the header.

    - #### headerSizeC

          private java.lang.Short headerSizeC

      Number of channels the image has as specified in the header.

    - #### headerPixelType

          private java.lang.Integer headerPixelType

      Pixel type as specified in the header.

    - #### codestreamSizeX

          private java.lang.Integer codestreamSizeX

      Width of the image as specified in the JPEG 2000 codestream.

    - #### codestreamSizeY

          private java.lang.Integer codestreamSizeY

      Height of the image as specified in the JPEG 2000 codestream.

    - #### codestreamSizeC

          private java.lang.Short codestreamSizeC

      Number of channels the image as specified in the JPEG 2000 codestream.

    - #### codestreamPixelType

          private java.lang.Integer codestreamPixelType

      Pixel type as specified in the JPEG 2000 codestream..

    - #### isRawCodestream

          private boolean isRawCodestream

      Whether or not the codestream is raw and not JP2 boxed.

    - #### resolutionLevels

          private java.lang.Integer resolutionLevels

      Number of JPEG 2000 resolution levels the file has.

    - #### lut

          private int[][] lut

      Color lookup table stored in the file.

    - #### comments

          private java.util.ArrayList<java.lang.String> comments

      List of comments stored in the file.

  - ### Constructor Detail

    - #### JPEG2000MetadataParser

          public JPEG2000MetadataParser(loci.common.RandomAccessInputStream in)
                                 throws java.io.IOException

      Constructs a new JPEG2000MetadataParser.
      Parameters:
        `in` - Stream to parse JPEG 2000 metadata from.
      Throws:
        `java.io.IOException` - Thrown if there is an error reading from the file.

    - #### JPEG2000MetadataParser

          public JPEG2000MetadataParser(loci.common.RandomAccessInputStream in,
                                        long maximumReadOffset)
                                 throws java.io.IOException

      Constructs a new JPEG2000MetadataParser.
      Parameters:
        `in` - Stream to parse JPEG 2000 metadata from.
        `maximumReadOffset` - Maximum read offset within the stream when parsing.
      Throws:
        `java.io.IOException` - Thrown if there is an error reading from the file.

  - ### Method Detail

    - #### getCodestreamOffset

          public long getCodestreamOffset()

      Retrieves the offset to the first contiguous codestream.

    - #### getComments

          public java.util.ArrayList<java.lang.String> getComments()

      Retrieves the list of comments stored in the file.

    - #### parseBoxes

          private void parseBoxes()
                           throws java.io.IOException

      Parses the JPEG 2000 JP2 metadata boxes.
      Throws:
        `java.io.IOException` - Thrown if there is an error reading from the file.

    - #### parseContiguousCodestream

          private void parseContiguousCodestream(long length)
                                          throws java.io.IOException

      Parses the JPEG 2000 codestream metadata.
      Parameters:
        `length` - Total length of the codestream block.
      Throws:
        `java.io.IOException` - Thrown if there is an error reading from the file.

    - #### isRawCodestream

          public boolean isRawCodestream()

      Whether or not the codestream is raw and not JP2 boxed.
      Returns:
        `true` if the codestream is raw and `false` otherwise.

    - #### getResolutionLevels

          public java.lang.Integer getResolutionLevels()

      Returns the number of resolution levels the file JPEG 2000 data has.
      Returns:
        The number of resolution levels or `null` if the number cannot be parsed.

    - #### getHeaderSizeX

          public java.lang.Integer getHeaderSizeX()

      Returns the width of the image as specified in the header.
      Returns:
        See above.

    - #### getHeaderSizeY

          public java.lang.Integer getHeaderSizeY()

      Returns the height of the image as specified in the header.
      Returns:
        See above.

    - #### getHeaderSizeC

          public java.lang.Short getHeaderSizeC()

      Returns the number of channels the image has as specified in the header.
      Returns:
        See above.

    - #### getHeaderPixelType

          public java.lang.Integer getHeaderPixelType()

      Returns the pixel type as specified in the header.
      Returns:
        See above.

    - #### getCodestreamSizeX

          public java.lang.Integer getCodestreamSizeX()

      Returns the width of the image as specified in the header.
      Returns:
        See above.

    - #### getCodestreamSizeY

          public java.lang.Integer getCodestreamSizeY()

      Returns the height of the image as specified in the header.
      Returns:
        See above.

    - #### getCodestreamSizeC

          public java.lang.Short getCodestreamSizeC()

      Returns the number of channels the image has as specified in the header.
      Returns:
        See above.

    - #### getCodestreamPixelType

          public java.lang.Integer getCodestreamPixelType()

      Returns the pixel type as specified in the header.
      Returns:
        See above.

    - #### getLookupTable

          public int[][] getLookupTable()

      Returns the color lookup table stored in the file, or null if a lookup table is not present.
      Returns:
        See above.

    - #### convertPixelType

          private int convertPixelType(int type)

Copyright © 2026 Open Microscopy Environment