Package de.digitalcollections.openjpeg
Class OpenJpeg
- java.lang.Object
-
- de.digitalcollections.openjpeg.OpenJpeg
-
public class OpenJpeg extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static ColorModelCOLOR_MODEL_CMYKstatic ColorModelCOLOR_MODEL_CMYK_ALPHAlibopenjp2libjnr.ffi.Runtimeruntime
-
Constructor Summary
Constructors Constructor Description OpenJpeg()Load the library.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BufferedImagedecode(InStreamWrapper wrapper, Rectangle area, int reduceFactor)Decode the JPEG2000 image in the input stream to a BufferedImage.BufferedImagedecode(Path filePath, Rectangle area, int reduceFactor)Decode the JPEG2000 image located at the given path to a BufferedImage.voidencode(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(Path filePath)Obtain information about the JPEG200 image located at the given path.
-
-
-
Field Detail
-
COLOR_MODEL_CMYK
public static final ColorModel COLOR_MODEL_CMYK
-
COLOR_MODEL_CMYK_ALPHA
public static final ColorModel COLOR_MODEL_CMYK_ALPHA
-
lib
public libopenjp2 lib
-
runtime
public jnr.ffi.Runtime runtime
-
-
Method Detail
-
getInfo
public Info getInfo(Path filePath) throws IOException
Obtain information about the JPEG200 image located at the given path.- Throws:
IOException
-
getInfo
public Info getInfo(InStreamWrapper wrapper) throws IOException
Obtain information about the JPEG200 image in the input stream.- Throws:
IOException
-
decode
public BufferedImage decode(InStreamWrapper wrapper, Rectangle area, int reduceFactor) throws IOException
Decode 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:
IOException- if there's a problem decoding the image
-
decode
public BufferedImage decode(Path filePath, Rectangle area, int reduceFactor) throws 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 decodereduceFactor- Scale down the image by a factor of 2^reduceFactor- Returns:
- the decoded image
- Throws:
IOException- if there's a problem decoding the image or reading the file
-
encode
public void encode(Raster img, OutStreamWrapper output, opj_cparameters params) throws IOException
Encode a raster image to a JPEG2000 image.- Parameters:
img- image to encodeoutput- wrapped OutputStream the image should be written toparams- encoding parameters- Throws:
IOException- if encoding fails
-
-