Class TJDecompressor
- java.lang.Object
-
- org.libjpegturbo.turbojpeg.TJDecompressor
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
- Direct Known Subclasses:
TJTransformer
public class TJDecompressor extends java.lang.Object implements java.io.Closeable
TurboJPEG decompressor
-
-
Constructor Summary
Constructors Constructor Description TJDecompressor()
Create a TurboJPEG decompresssor instance.TJDecompressor(byte[] jpegImage)
Create a TurboJPEG decompressor instance and associate the JPEG source image or "abbreviated table specification" (AKA "tables-only") datastream stored injpegImage
with the newly created instance.TJDecompressor(byte[] jpegImage, int imageSize)
Create a TurboJPEG decompressor instance and associate the JPEG source image or "abbreviated table specification" (AKA "tables-only") datastream of lengthimageSize
bytes stored injpegImage
with the newly created instance.TJDecompressor(YUVImage yuvImage)
Create a TurboJPEG decompressor instance and associate the 8-bit-per-sample planar YUV source image stored inyuvImage
with the newly created instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
close()
Free the native structures associated with this decompressor instance.void
decompress(byte[] dstBuf, int x, int y, int desiredWidth, int pitch, int desiredHeight, int pixelFormat, int flags)
Deprecated.void
decompress(int[] dstBuf, int x, int y, int desiredWidth, int stride, int desiredHeight, int pixelFormat, int flags)
Deprecated.java.awt.image.BufferedImage
decompress(int desiredWidth, int desiredHeight, int bufferedImageType, int flags)
Deprecated.byte[]
decompress(int desiredWidth, int pitch, int desiredHeight, int pixelFormat, int flags)
Deprecated.void
decompress(java.awt.image.BufferedImage dstImage, int flags)
Deprecated.short[]
decompress12(int pitch, int pixelFormat)
Decompress the 12-bit-per-sample JPEG source image associated with this decompressor instance and return a buffer containing a 12-bit-per-sample packed-pixel decompressed image.void
decompress12(short[] dstBuf, int x, int y, int pitch, int pixelFormat)
Decompress the 12-bit-per-sample JPEG source image associated with this decompressor instance and output a 12-bit-per-sample packed-pixel grayscale, RGB, or CMYK image to the given destination buffer.short[]
decompress16(int pitch, int pixelFormat)
Decompress the 16-bit-per-sample JPEG source image associated with this decompressor instance and return a buffer containing a 16-bit-per-sample packed-pixel decompressed image.void
decompress16(short[] dstBuf, int x, int y, int pitch, int pixelFormat)
Decompress the 16-bit-per-sample lossless JPEG source image associated with this decompressor instance and output a 16-bit-per-sample packed-pixel grayscale, RGB, or CMYK image to the given destination buffer.void
decompress8(byte[] dstBuf, int x, int y, int pitch, int pixelFormat)
Decompress the 8-bit-per-sample JPEG source image or decode the planar YUV source image associated with this decompressor instance and output an 8-bit-per-sample packed-pixel grayscale, RGB, or CMYK image to the given destination buffer.java.awt.image.BufferedImage
decompress8(int bufferedImageType)
Decompress the 8-bit-per-sample JPEG source image or decode the planar YUV source image associated with this decompressor instance and return aBufferedImage
instance containing the 8-bit-per-sample packed-pixel decompressed/decoded image.void
decompress8(int[] dstBuf, int x, int y, int stride, int pixelFormat)
Decompress the 8-bit-per-sample JPEG source image or decode the planar YUV source image associated with this decompressor instance and output an 8-bit-per-sample packed-pixel grayscale, RGB, or CMYK image to the given destination buffer.byte[]
decompress8(int pitch, int pixelFormat)
Decompress the 8-bit-per-sample JPEG source image or decode the planar YUV source image associated with this decompressor instance and return a buffer containing an 8-bit-per-sample packed-pixel decompressed image.void
decompress8(java.awt.image.BufferedImage dstImage)
Decompress the 8-bit-per-sample JPEG source image or decode the planar YUV source image associated with this decompressor instance and output an 8-bit-per-sample packed-pixel decompressed/decoded image to the givenBufferedImage
instance.YUVImage
decompressToYUV(int align)
Decompress the 8-bit-per-sample JPEG source image associated with this decompressor instance into an 8-bit-per-sample unified planar YUV image and return aYUVImage
instance containing the decompressed image.YUVImage
decompressToYUV(int[] strides)
Decompress the 8-bit-per-sample JPEG source image associated with this decompressor instance into a set of 8-bit-per-sample Y, U (Cb), and V (Cr) image planes and return aYUVImage
instance containing the decompressed image planes.YUVImage
decompressToYUV(int desiredWidth, int[] strides, int desiredHeight, int flags)
Deprecated.YUVImage
decompressToYUV(int desiredWidth, int align, int desiredHeight, int flags)
Deprecated.void
decompressToYUV(YUVImage dstImage)
Decompress the 8-bit-per-sample JPEG source image associated with this decompressor instance into an 8-bit-per-sample planar YUV image and store it in the givenYUVImage
instance.void
decompressToYUV(YUVImage dstImage, int flags)
Deprecated.protected void
finalize()
int
get(int param)
Get the value of a decompression parameter.int
getColorspace()
Deprecated.Use
instead.get
(TJ.PARAM_COLORSPACE
)int
getHeight()
Returns the height of the source image (JPEG or YUV) associated with this decompressor instance.byte[]
getJPEGBuf()
Returns the JPEG buffer associated with this decompressor instance.int
getJPEGSize()
Returns the size of the JPEG image (in bytes) associated with this decompressor instance.int
getScaledHeight(int desiredWidth, int desiredHeight)
Deprecated.UsesetScalingFactor()
andTJScalingFactor.getScaled()
instead.int
getScaledWidth(int desiredWidth, int desiredHeight)
Deprecated.UsesetScalingFactor()
andTJScalingFactor.getScaled()
instead.int
getSubsamp()
Deprecated.Use
instead.get
(TJ.PARAM_SUBSAMP
)int
getWidth()
Returns the width of the source image (JPEG or YUV) associated with this decompressor instance.void
set(int param, int value)
Set the value of a decompression parameter.void
setCroppingRegion(java.awt.Rectangle croppingRegion)
Set the cropping region for partially decompressing a lossy JPEG image into a packed-pixel image.void
setScalingFactor(TJScalingFactor scalingFactor)
Set the scaling factor for subsequent lossy decompression operations.void
setSourceImage(byte[] jpegImage, int imageSize)
Associate the JPEG image or "abbreviated table specification" (AKA "tables-only") datastream of lengthimageSize
bytes stored injpegImage
with this decompressor instance.void
setSourceImage(YUVImage srcImage)
Associate the specified planar YUV source image with this decompressor instance.
-
-
-
Constructor Detail
-
TJDecompressor
public TJDecompressor() throws TJException
Create a TurboJPEG decompresssor instance.- Throws:
TJException
-
TJDecompressor
public TJDecompressor(byte[] jpegImage) throws TJException
Create a TurboJPEG decompressor instance and associate the JPEG source image or "abbreviated table specification" (AKA "tables-only") datastream stored injpegImage
with the newly created instance. Refer tosetSourceImage(byte[], int)
for more details.- Parameters:
jpegImage
- buffer containing a JPEG source image or tables-only datastream. (The size of the JPEG image or datastream is assumed to be the length of the array.) This buffer is not modified.- Throws:
TJException
-
TJDecompressor
public TJDecompressor(byte[] jpegImage, int imageSize) throws TJException
Create a TurboJPEG decompressor instance and associate the JPEG source image or "abbreviated table specification" (AKA "tables-only") datastream of lengthimageSize
bytes stored injpegImage
with the newly created instance. Refer tosetSourceImage(byte[], int)
for more details.- Parameters:
jpegImage
- buffer containing a JPEG source image or tables-only datastream. This buffer is not modified.imageSize
- size of the JPEG source image or tables-only datastream (in bytes)- Throws:
TJException
-
TJDecompressor
public TJDecompressor(YUVImage yuvImage) throws TJException
Create a TurboJPEG decompressor instance and associate the 8-bit-per-sample planar YUV source image stored inyuvImage
with the newly created instance. Refer tosetSourceImage(YUVImage)
for more details.- Parameters:
yuvImage
-YUVImage
instance containing a planar YUV source image to be decoded. This image is not modified.- Throws:
TJException
-
-
Method Detail
-
setSourceImage
public void setSourceImage(byte[] jpegImage, int imageSize) throws TJException
Associate the JPEG image or "abbreviated table specification" (AKA "tables-only") datastream of lengthimageSize
bytes stored injpegImage
with this decompressor instance. IfjpegImage
contains a JPEG image, then this image will be used as the source image for subsequent decompression operations. Passing a tables-only datastream to this method primes the decompressor with quantization and Huffman tables that can be used when decompressing subsequent "abbreviated image" datastreams. This is useful, for instance, when decompressing video streams in which all frames share the same quantization and Huffman tables. If a JPEG image is passed to this method, then theparameters
that describe the JPEG image will be set when the method returns.- Parameters:
jpegImage
- buffer containing a JPEG source image or tables-only datastream. This buffer is not modified.imageSize
- size of the JPEG source image or tables-only datastream (in bytes)- Throws:
TJException
-
setSourceImage
public void setSourceImage(YUVImage srcImage)
Associate the specified planar YUV source image with this decompressor instance. Subsequent decompression operations will decode this image into a packed-pixel RGB or grayscale destination image. This method setsTJ.PARAM_SUBSAMP
to the chrominance subsampling level of the source image.- Parameters:
srcImage
-YUVImage
instance containing a planar YUV source image to be decoded. This image is not modified.
-
getWidth
public int getWidth()
Returns the width of the source image (JPEG or YUV) associated with this decompressor instance.- Returns:
- the width of the source image (JPEG or YUV) associated with this decompressor instance.
-
getHeight
public int getHeight()
Returns the height of the source image (JPEG or YUV) associated with this decompressor instance.- Returns:
- the height of the source image (JPEG or YUV) associated with this decompressor instance.
-
set
public void set(int param, int value)
Set the value of a decompression parameter.- Parameters:
param
- one ofTJ.PARAM_*
value
- value of the decompression parameter (refer toparameter documentation
)
-
get
public int get(int param)
Get the value of a decompression parameter.- Parameters:
param
- one ofTJ.PARAM_*
- Returns:
- the value of the specified decompression parameter, or -1 if the value is unknown.
-
setScalingFactor
public void setScalingFactor(TJScalingFactor scalingFactor)
Set the scaling factor for subsequent lossy decompression operations.- Parameters:
scalingFactor
-TJScalingFactor
instance that specifies a fractional scaling factor that the decompressor supports (seeTJ.getScalingFactors()
), orTJ.UNSCALED
for no scaling. Decompression scaling is a function of the IDCT algorithm, so scaling factors are generally limited to multiples of 1/8. If the entire JPEG image will be decompressed, then the width and height of the scaled destination image can be determined by callingscalingFactor.
getScaled()
with the JPEG image width and height (seegetWidth()
andgetHeight()
.) When decompressing into a planar YUV image, an intermediate buffer copy will be performed if the width or height of the scaled destination image is not an even multiple of the MCU block size (seeTJ.getMCUWidth()
andTJ.getMCUHeight()
.) Note that decompression scaling is not available (and the specified scaling factor is ignored) when decompressing lossless JPEG images (seeTJ.PARAM_LOSSLESS
), since the IDCT algorithm is not used with those images. Note also thatTJ.PARAM_FASTDCT
is ignored when decompression scaling is enabled.
-
setCroppingRegion
public void setCroppingRegion(java.awt.Rectangle croppingRegion) throws TJException
Set the cropping region for partially decompressing a lossy JPEG image into a packed-pixel image.- Parameters:
croppingRegion
-java.awt.Rectangle
instance that specifies a subregion of the JPEG image to decompress, orTJ.UNCROPPED
for no cropping. The left boundary of the cropping region must be evenly divisible by the scaled MCU block width, which can be determined by callingTJScalingFactor.getScaled()
with the specified scaling factor (seesetScalingFactor()
) and the MCU block width (seeTJ.getMCUWidth()
) for the level of chrominance subsampling in the JPEG image (seeTJ.PARAM_SUBSAMP
.) The cropping region should be specified relative to the scaled image dimensions. UnlesscroppingRegion
isTJ.UNCROPPED
, the JPEG header must be read (seesetSourceImage(byte[], int)
prior to calling this method.- Throws:
TJException
-
getSubsamp
@Deprecated public int getSubsamp()
Deprecated.Use
instead.get
(TJ.PARAM_SUBSAMP
)
-
getColorspace
@Deprecated public int getColorspace()
Deprecated.Use
instead.get
(TJ.PARAM_COLORSPACE
)
-
getJPEGBuf
public byte[] getJPEGBuf()
Returns the JPEG buffer associated with this decompressor instance.- Returns:
- the JPEG buffer associated with this decompressor instance.
-
getJPEGSize
public int getJPEGSize()
Returns the size of the JPEG image (in bytes) associated with this decompressor instance.- Returns:
- the size of the JPEG image (in bytes) associated with this decompressor instance.
-
getScaledWidth
@Deprecated public int getScaledWidth(int desiredWidth, int desiredHeight)
Deprecated.UsesetScalingFactor()
andTJScalingFactor.getScaled()
instead.
-
getScaledHeight
@Deprecated public int getScaledHeight(int desiredWidth, int desiredHeight)
Deprecated.UsesetScalingFactor()
andTJScalingFactor.getScaled()
instead.
-
decompress8
public void decompress8(byte[] dstBuf, int x, int y, int pitch, int pixelFormat) throws TJException
Decompress the 8-bit-per-sample JPEG source image or decode the planar YUV source image associated with this decompressor instance and output an 8-bit-per-sample packed-pixel grayscale, RGB, or CMYK image to the given destination buffer.NOTE: The destination image is fully recoverable if this method throws a non-fatal
TJException
(unlessTJ.PARAM_STOPONWARNING
is set.)- Parameters:
dstBuf
- buffer that will receive the packed-pixel decompressed/decoded image. This buffer should normally bepitch * destinationHeight
bytes in size. However, the buffer may also be larger, in which case thex
,y
, andpitch
parameters can be used to specify the region into which the source image should be decompressed/decoded. NOTE: If the source image is a lossy JPEG image, thendestinationHeight
is either the scaled JPEG height (seesetScalingFactor()
,TJScalingFactor.getScaled()
, andgetHeight()
) or the height of the cropping region (seesetCroppingRegion()
.) If the source image is a YUV image or a lossless JPEG image, thendestinationHeight
is the height of the source image.x
- x offset (in pixels) of the region in the destination image into which the source image should be decompressed/decodedy
- y offset (in pixels) of the region in the destination image into which the source image should be decompressed/decodedpitch
- bytes per row in the destination image. Normally this should be set todestinationWidth *
, if the destination image will be unpadded. (Setting this parameter to 0 is the equivalent of setting it toTJ.getPixelSize
(pixelFormat)destinationWidth *
.) However, you can also use this parameter to specify the row alignment/padding of the destination image, to skip rows, or to decompress/decode into a specific region of a larger image. NOTE: if the source image is a lossy JPEG image, thenTJ.getPixelSize
(pixelFormat)destinationWidth
is either the scaled JPEG width (seesetScalingFactor()
,TJScalingFactor.getScaled()
, andgetWidth()
) or the width of the cropping region (seesetCroppingRegion()
.) If the source image is a YUV image or a lossless JPEG image, thendestinationWidth
is the width of the source image.pixelFormat
- pixel format of the decompressed/decoded image (one ofTJ.PF_*
)- Throws:
TJException
-
decompress
@Deprecated public void decompress(byte[] dstBuf, int x, int y, int desiredWidth, int pitch, int desiredHeight, int pixelFormat, int flags) throws TJException
Deprecated.- Throws:
TJException
-
decompress8
public byte[] decompress8(int pitch, int pixelFormat) throws TJException
Decompress the 8-bit-per-sample JPEG source image or decode the planar YUV source image associated with this decompressor instance and return a buffer containing an 8-bit-per-sample packed-pixel decompressed image.- Parameters:
pitch
- seedecompress8(byte[], int, int, int, int)
for descriptionpixelFormat
- pixel format of the decompressed image (one ofTJ.PF_*
)- Returns:
- a buffer containing an 8-bit-per-sample packed-pixel decompressed image.
- Throws:
TJException
-
decompress
@Deprecated public byte[] decompress(int desiredWidth, int pitch, int desiredHeight, int pixelFormat, int flags) throws TJException
Deprecated.- Throws:
TJException
-
decompress12
public void decompress12(short[] dstBuf, int x, int y, int pitch, int pixelFormat) throws TJException
Decompress the 12-bit-per-sample JPEG source image associated with this decompressor instance and output a 12-bit-per-sample packed-pixel grayscale, RGB, or CMYK image to the given destination buffer.NOTE: The destination image is fully recoverable if this method throws a non-fatal
TJException
(unlessTJ.PARAM_STOPONWARNING
is set.)- Parameters:
dstBuf
- buffer that will receive the packed-pixel decompressed image. This buffer should normally bepitch * destinationHeight
samples in size. However, the buffer may also be larger, in which case thex
,y
, andpitch
parameters can be used to specify the region into which the source image should be decompressed. NOTE: If the source image is a lossy JPEG image, thendestinationHeight
is either the scaled JPEG height (seesetScalingFactor()
,TJScalingFactor.getScaled()
, andgetHeight()
) or the height of the cropping region (seesetCroppingRegion()
.) If the source image is a lossless JPEG image, thendestinationHeight
is the height of the source image.x
- x offset (in pixels) of the region in the destination image into which the source image should be decompressedy
- y offset (in pixels) of the region in the destination image into which the source image should be decompressedpitch
- samples per row in the destination image. Normally this should be set todestinationWidth *
, if the destination image will be unpadded. (Setting this parameter to 0 is the equivalent of setting it toTJ.getPixelSize
(pixelFormat)destinationWidth *
.) However, you can also use this parameter to specify the row alignment/padding of the destination image, to skip rows, or to decompress into a specific region of a larger image. NOTE: if the source image is a lossy JPEG image, thenTJ.getPixelSize
(pixelFormat)destinationWidth
is either the scaled JPEG width (seesetScalingFactor()
,TJScalingFactor.getScaled()
, andgetWidth()
) or the width of the cropping region (seesetCroppingRegion()
.) If the source image is a YUV image or a lossless JPEG image, thendestinationWidth
is the width of the source image.pixelFormat
- pixel format of the decompressed image (one ofTJ.PF_*
)- Throws:
TJException
-
decompress12
public short[] decompress12(int pitch, int pixelFormat) throws TJException
Decompress the 12-bit-per-sample JPEG source image associated with this decompressor instance and return a buffer containing a 12-bit-per-sample packed-pixel decompressed image.- Parameters:
pitch
- seedecompress12(short[], int, int, int, int)
for descriptionpixelFormat
- pixel format of the decompressed image (one ofTJ.PF_*
)- Returns:
- a buffer containing an 8-bit-per-sample packed-pixel decompressed image.
- Throws:
TJException
-
decompress16
public void decompress16(short[] dstBuf, int x, int y, int pitch, int pixelFormat) throws TJException
Decompress the 16-bit-per-sample lossless JPEG source image associated with this decompressor instance and output a 16-bit-per-sample packed-pixel grayscale, RGB, or CMYK image to the given destination buffer.NOTE: The destination image is fully recoverable if this method throws a non-fatal
TJException
(unlessTJ.PARAM_STOPONWARNING
is set.)- Parameters:
dstBuf
- buffer that will receive the packed-pixel decompressed image. This buffer should normally bepitch * jpegHeight
samples in size. However, the buffer may also be larger, in which case thex
,y
, andpitch
parameters can be used to specify the region into which the source image should be decompressed.x
- x offset (in pixels) of the region in the destination image into which the source image should be decompressedy
- y offset (in pixels) of the region in the destination image into which the source image should be decompressedpitch
- samples per row in the destination image. Normally this should be set tojpegWidth *
, if the destination image will be unpadded. (Setting this parameter to 0 is the equivalent of setting it toTJ.getPixelSize
(pixelFormat)jpegWidth *
.) However, you can also use this parameter to specify the row alignment/padding of the destination image, to skip rows, or to decompress into a specific region of a larger image.TJ.getPixelSize
(pixelFormat)pixelFormat
- pixel format of the decompressed image (one ofTJ.PF_*
)- Throws:
TJException
-
decompress16
public short[] decompress16(int pitch, int pixelFormat) throws TJException
Decompress the 16-bit-per-sample JPEG source image associated with this decompressor instance and return a buffer containing a 16-bit-per-sample packed-pixel decompressed image.- Parameters:
pitch
- seedecompress16(short[], int, int, int, int)
for descriptionpixelFormat
- pixel format of the decompressed image (one ofTJ.PF_*
)- Returns:
- a buffer containing an 8-bit-per-sample packed-pixel decompressed image.
- Throws:
TJException
-
decompressToYUV
public void decompressToYUV(YUVImage dstImage) throws TJException
Decompress the 8-bit-per-sample JPEG source image associated with this decompressor instance into an 8-bit-per-sample planar YUV image and store it in the givenYUVImage
instance. This method performs JPEG decompression but leaves out the color conversion step, so a planar YUV image is generated instead of a packed-pixel image. This method cannot be used to decompress JPEG source images with the CMYK or YCCK colorspace.NOTE: The planar YUV destination image is fully recoverable if this method throws a non-fatal
TJException
(unlessTJ.PARAM_STOPONWARNING
is set.)- Parameters:
dstImage
-YUVImage
instance that will receive the planar YUV decompressed image. The level of subsampling specified in thisYUVImage
instance must match that of the JPEG image, and the width and height specified in theYUVImage
instance must match the scaled JPEG width and height (seesetScalingFactor()
,TJScalingFactor.getScaled()
,getWidth()
, andgetHeight()
.)- Throws:
TJException
-
decompressToYUV
@Deprecated public void decompressToYUV(YUVImage dstImage, int flags) throws TJException
Deprecated.- Throws:
TJException
-
decompressToYUV
public YUVImage decompressToYUV(int[] strides) throws TJException
Decompress the 8-bit-per-sample JPEG source image associated with this decompressor instance into a set of 8-bit-per-sample Y, U (Cb), and V (Cr) image planes and return aYUVImage
instance containing the decompressed image planes. This method performs JPEG decompression but leaves out the color conversion step, so a planar YUV image is generated instead of a packed-pixel image. This method cannot be used to decompress JPEG source images with the CMYK or YCCK colorspace.- Parameters:
strides
- an array of integers, each specifying the number of bytes per row in the corresponding plane of the YUV image. Setting the stride for any plane to 0 is the same as setting it to the scaled plane width (seeYUVImage
.) Ifstrides
is null, then the strides for all planes will be set to their respective scaled plane widths. You can adjust the strides in order to add an arbitrary amount of row padding to each plane.- Returns:
- a
YUVImage
instance containing the decompressed image planes - Throws:
TJException
-
decompressToYUV
@Deprecated public YUVImage decompressToYUV(int desiredWidth, int[] strides, int desiredHeight, int flags) throws TJException
Deprecated.- Throws:
TJException
-
decompressToYUV
public YUVImage decompressToYUV(int align) throws TJException
Decompress the 8-bit-per-sample JPEG source image associated with this decompressor instance into an 8-bit-per-sample unified planar YUV image and return aYUVImage
instance containing the decompressed image. This method performs JPEG decompression but leaves out the color conversion step, so a planar YUV image is generated instead of a packed-pixel image. This method cannot be used to decompress JPEG source images with the CMYK or YCCK colorspace.- Parameters:
align
- row alignment (in bytes) of the YUV image (must be a power of 2.) Setting this parameter to n will cause each row in each plane of the YUV image to be padded to the nearest multiple of n bytes (1 = unpadded.)- Returns:
- a
YUVImage
instance containing the unified planar YUV decompressed image - Throws:
TJException
-
decompressToYUV
@Deprecated public YUVImage decompressToYUV(int desiredWidth, int align, int desiredHeight, int flags) throws TJException
Deprecated.- Throws:
TJException
-
decompress8
public void decompress8(int[] dstBuf, int x, int y, int stride, int pixelFormat) throws TJException
Decompress the 8-bit-per-sample JPEG source image or decode the planar YUV source image associated with this decompressor instance and output an 8-bit-per-sample packed-pixel grayscale, RGB, or CMYK image to the given destination buffer.NOTE: The destination image is fully recoverable if this method throws a non-fatal
TJException
(unlessTJ.PARAM_STOPONWARNING
is set.)- Parameters:
dstBuf
- buffer that will receive the packed-pixel decompressed/decoded image. This buffer should normally bestride * destinationHeight
pixels in size. However, the buffer may also be larger, in which case thex
,y
, andpitch
parameters can be used to specify the region into which the source image should be decompressed/decoded. NOTE: If the source image is a lossy JPEG image, thendestinationHeight
is either the scaled JPEG height (seesetScalingFactor()
,TJScalingFactor.getScaled()
, andgetHeight()
) or the height of the cropping region (seesetCroppingRegion()
.) If the source image is a YUV image or a lossless JPEG image, thendestinationHeight
is the height of the source image.x
- x offset (in pixels) of the region in the destination image into which the source image should be decompressed/decodedy
- y offset (in pixels) of the region in the destination image into which the source image should be decompressed/decodedstride
- pixels per row in the destination image. Normally this should be set todestinationWidth
. (Setting this parameter to 0 is the equivalent of setting it todestinationWidth
.) However, you can also use this parameter to skip rows or to decompress/decode into a specific region of a larger image. NOTE: if the source image is a lossy JPEG image, thendestinationWidth
is either the scaled JPEG width (seesetScalingFactor()
,TJScalingFactor.getScaled()
, andgetWidth()
) or the width of the cropping region (seesetCroppingRegion()
.) If the source image is a YUV image or a lossless JPEG image, thendestinationWidth
is the width of the source image.pixelFormat
- pixel format of the decompressed/decoded image (one ofTJ.PF_*
)- Throws:
TJException
-
decompress
@Deprecated public void decompress(int[] dstBuf, int x, int y, int desiredWidth, int stride, int desiredHeight, int pixelFormat, int flags) throws TJException
Deprecated.- Throws:
TJException
-
decompress8
public void decompress8(java.awt.image.BufferedImage dstImage) throws TJException
Decompress the 8-bit-per-sample JPEG source image or decode the planar YUV source image associated with this decompressor instance and output an 8-bit-per-sample packed-pixel decompressed/decoded image to the givenBufferedImage
instance.NOTE: The destination image is fully recoverable if this method throws a non-fatal
TJException
(unlessTJ.PARAM_STOPONWARNING
is set.)- Parameters:
dstImage
- aBufferedImage
instance that will receive the packed-pixel decompressed/decoded image. If the source image is a lossy JPEG image, then the width and height of theBufferedImage
instance must match the scaled JPEG width and height (seesetScalingFactor()
,TJScalingFactor.getScaled()
,getWidth()
, andgetHeight()
) or the width and height of the cropping region (seesetCroppingRegion()
.) If the source image is a YUV image or a lossless JPEG image, then the width and height of theBufferedImage
instance must match the width and height of the source image.- Throws:
TJException
-
decompress
@Deprecated public void decompress(java.awt.image.BufferedImage dstImage, int flags) throws TJException
Deprecated.- Throws:
TJException
-
decompress8
public java.awt.image.BufferedImage decompress8(int bufferedImageType) throws TJException
Decompress the 8-bit-per-sample JPEG source image or decode the planar YUV source image associated with this decompressor instance and return aBufferedImage
instance containing the 8-bit-per-sample packed-pixel decompressed/decoded image.- Parameters:
bufferedImageType
- the image type of theBufferedImage
instance that will be created (for instance,BufferedImage.TYPE_INT_RGB
)- Returns:
- a
BufferedImage
instance containing the 8-bit-per-sample packed-pixel decompressed/decoded image. - Throws:
TJException
-
decompress
@Deprecated public java.awt.image.BufferedImage decompress(int desiredWidth, int desiredHeight, int bufferedImageType, int flags) throws TJException
Deprecated.- Throws:
TJException
-
close
public void close() throws TJException
Free the native structures associated with this decompressor instance.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
TJException
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
-