Package de.digitalcollections.openjpeg
Class OpenJpeg
java.lang.Object
de.digitalcollections.openjpeg.OpenJpeg
public class OpenJpeg
extends java.lang.Object
-
Field Summary
Fields Modifier and Type Field Description libopenjp2libjnr.ffi.Runtimeruntime -
Constructor Summary
Constructors Constructor Description OpenJpeg()Load the library. -
Method Summary
Modifier and Type Method Description java.awt.image.BufferedImagedecode(InStreamWrapper wrapper, java.awt.Rectangle area, int reduceFactor)Decode the JPEG2000 image in the input stream to a BufferedImage.java.awt.image.BufferedImagedecode(java.nio.file.Path filePath, java.awt.Rectangle area, int reduceFactor)Decode the JPEG2000 image located at the given path to a BufferedImage.voidencode(java.awt.image.Raster img, OutStreamWrapper output, opj_cparameters params)Encode a raster image to a JPEG2000 image.InfogetInfo(InStreamWrapper wrapper)Obtain information about the JPEG200 image in the input stream.InfogetInfo(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
-
runtime
public jnr.ffi.Runtime runtime
-
-
Constructor Details
-
OpenJpeg
public OpenJpeg()Load the library.
-
-
Method Details
-
getInfo
Obtain information about the JPEG200 image located at the given path.- Throws:
java.io.IOException
-
getInfo
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.IOExceptionDecode the JPEG2000 image in the input stream to a BufferedImage.- Parameters:
wrapper- Wrapper around the input stream pointing to the imagearea- Region of the image to decodereduceFactor- 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.IOExceptionDecode 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 decodereduceFactor- 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.IOExceptionEncode a raster image to a JPEG2000 image.- Parameters:
img- image to encodeoutput- wrapped OutputStream the image should be written toparams- encoding parameters- Throws:
java.io.IOException- if encoding fails
-