Class OpenJpeg

java.lang.Object
de.digitalcollections.openjpeg.OpenJpeg

public class OpenJpeg
extends java.lang.Object
  • Field Summary

    Fields
    Modifier and Type Field Description
    libopenjp2 lib  
    jnr.ffi.Runtime runtime  
  • Constructor Summary

    Constructors
    Constructor Description
    OpenJpeg()
    Load the library.
  • Method Summary

    Modifier and Type Method Description
    java.awt.image.BufferedImage decode​(InStreamWrapper wrapper, java.awt.Rectangle area, int reduceFactor)
    Decode the JPEG2000 image in the input stream to a BufferedImage.
    java.awt.image.BufferedImage decode​(java.nio.file.Path filePath, java.awt.Rectangle area, int reduceFactor)
    Decode the JPEG2000 image located at the given path to a BufferedImage.
    void encode​(java.awt.image.Raster img, OutStreamWrapper output, opj_cparameters params)
    Encode a raster image to a JPEG2000 image.
    Info getInfo​(InStreamWrapper wrapper)
    Obtain information about the JPEG200 image in the input stream.
    Info getInfo​(java.nio.file.Path filePath)
    Obtain information about the JPEG200 image located at the given path.

    Methods inherited from class java.lang.Object

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

    • lib

      public libopenjp2 lib
    • runtime

      public jnr.ffi.Runtime runtime
  • Constructor Details

    • OpenJpeg

      public OpenJpeg()
      Load the library.
  • Method Details

    • getInfo

      public Info getInfo​(java.nio.file.Path filePath) throws java.io.IOException
      Obtain information about the JPEG200 image located at the given path.
      Throws:
      java.io.IOException
    • getInfo

      public Info getInfo​(InStreamWrapper wrapper) throws java.io.IOException
      Obtain information about the JPEG200 image in the input stream.
      Throws:
      java.io.IOException
    • decode

      public java.awt.image.BufferedImage decode​(InStreamWrapper wrapper, java.awt.Rectangle area, int reduceFactor) throws java.io.IOException
      Decode the JPEG2000 image in the input stream to a BufferedImage.
      Parameters:
      wrapper - Wrapper around the input stream pointing to the image
      area - Region of the image to decode
      reduceFactor - Scale down the image by a factor of 2^reduceFactor
      Returns:
      the decoded image
      Throws:
      java.io.IOException - if there's a problem decoding the image
    • decode

      public java.awt.image.BufferedImage decode​(java.nio.file.Path filePath, java.awt.Rectangle area, int reduceFactor) throws java.io.IOException
      Decode the JPEG2000 image located at the given path to a BufferedImage.
      Parameters:
      filePath - Path to the JPEG2000 image file.
      area - Region of the image to decode
      reduceFactor - Scale down the image by a factor of 2^reduceFactor
      Returns:
      the decoded image
      Throws:
      java.io.IOException - if there's a problem decoding the image or reading the file
    • encode

      public void encode​(java.awt.image.Raster img, OutStreamWrapper output, opj_cparameters params) throws java.io.IOException
      Encode a raster image to a JPEG2000 image.
      Parameters:
      img - image to encode
      output - wrapped OutputStream the image should be written to
      params - encoding parameters
      Throws:
      java.io.IOException - if encoding fails