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.CloseableTurboJPEG 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 injpegImagewith 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 lengthimageSizebytes stored injpegImagewith the newly created instance.TJDecompressor(YUVImage yuvImage)Create a TurboJPEG decompressor instance and associate the 8-bit-per-sample planar YUV source image stored inyuvImagewith the newly created instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclose()Free the native structures associated with this decompressor instance.voiddecompress(byte[] dstBuf, int x, int y, int desiredWidth, int pitch, int desiredHeight, int pixelFormat, int flags)Deprecated.voiddecompress(int[] dstBuf, int x, int y, int desiredWidth, int stride, int desiredHeight, int pixelFormat, int flags)Deprecated.java.awt.image.BufferedImagedecompress(int desiredWidth, int desiredHeight, int bufferedImageType, int flags)Deprecated.byte[]decompress(int desiredWidth, int pitch, int desiredHeight, int pixelFormat, int flags)Deprecated.voiddecompress(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.voiddecompress12(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.voiddecompress16(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.voiddecompress8(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.BufferedImagedecompress8(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 aBufferedImageinstance containing the 8-bit-per-sample packed-pixel decompressed/decoded image.voiddecompress8(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.voiddecompress8(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 givenBufferedImageinstance.YUVImagedecompressToYUV(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 aYUVImageinstance containing the decompressed image.YUVImagedecompressToYUV(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 aYUVImageinstance containing the decompressed image planes.YUVImagedecompressToYUV(int desiredWidth, int[] strides, int desiredHeight, int flags)Deprecated.YUVImagedecompressToYUV(int desiredWidth, int align, int desiredHeight, int flags)Deprecated.voiddecompressToYUV(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 givenYUVImageinstance.voiddecompressToYUV(YUVImage dstImage, int flags)Deprecated.protected voidfinalize()intget(int param)Get the value of a decompression parameter.intgetColorspace()Deprecated.Useinstead.get(TJ.PARAM_COLORSPACE)intgetHeight()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.intgetJPEGSize()Returns the size of the JPEG image (in bytes) associated with this decompressor instance.intgetScaledHeight(int desiredWidth, int desiredHeight)Deprecated.UsesetScalingFactor()andTJScalingFactor.getScaled()instead.intgetScaledWidth(int desiredWidth, int desiredHeight)Deprecated.UsesetScalingFactor()andTJScalingFactor.getScaled()instead.intgetSubsamp()Deprecated.Useinstead.get(TJ.PARAM_SUBSAMP)intgetWidth()Returns the width of the source image (JPEG or YUV) associated with this decompressor instance.voidset(int param, int value)Set the value of a decompression parameter.voidsetCroppingRegion(java.awt.Rectangle croppingRegion)Set the cropping region for partially decompressing a lossy JPEG image into a packed-pixel image.voidsetScalingFactor(TJScalingFactor scalingFactor)Set the scaling factor for subsequent lossy decompression operations.voidsetSourceImage(byte[] jpegImage, int imageSize)Associate the JPEG image or "abbreviated table specification" (AKA "tables-only") datastream of lengthimageSizebytes stored injpegImagewith this decompressor instance.voidsetSourceImage(YUVImage srcImage)Associate the specified planar YUV source image with this decompressor instance.
-
-
-
Constructor Detail
-
TJDecompressor
public TJDecompressor() throws TJExceptionCreate a TurboJPEG decompresssor instance.- Throws:
TJException
-
TJDecompressor
public TJDecompressor(byte[] jpegImage) throws TJExceptionCreate a TurboJPEG decompressor instance and associate the JPEG source image or "abbreviated table specification" (AKA "tables-only") datastream stored injpegImagewith 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 TJExceptionCreate a TurboJPEG decompressor instance and associate the JPEG source image or "abbreviated table specification" (AKA "tables-only") datastream of lengthimageSizebytes stored injpegImagewith 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 inyuvImagewith the newly created instance. Refer tosetSourceImage(YUVImage)for more details.- Parameters:
yuvImage-YUVImageinstance 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 TJExceptionAssociate the JPEG image or "abbreviated table specification" (AKA "tables-only") datastream of lengthimageSizebytes stored injpegImagewith this decompressor instance. IfjpegImagecontains 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 theparametersthat 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_SUBSAMPto the chrominance subsampling level of the source image.- Parameters:
srcImage-YUVImageinstance 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-TJScalingFactorinstance that specifies a fractional scaling factor that the decompressor supports (seeTJ.getScalingFactors()), orTJ.UNSCALEDfor 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 iMCU 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_FASTDCTis ignored when decompression scaling is enabled.
-
setCroppingRegion
public void setCroppingRegion(java.awt.Rectangle croppingRegion) throws TJExceptionSet the cropping region for partially decompressing a lossy JPEG image into a packed-pixel image.- Parameters:
croppingRegion-java.awt.Rectangleinstance that specifies a subregion of the JPEG image to decompress, orTJ.UNCROPPEDfor no cropping. The left boundary of the cropping region must be evenly divisible by the scaled iMCU width, which can be determined by callingTJScalingFactor.getScaled()with the specified scaling factor (seesetScalingFactor()) and the iMCU 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. UnlesscroppingRegionisTJ.UNCROPPED, the JPEG header must be read (seesetSourceImage(byte[], int)) prior to calling this method.- Throws:
TJException
-
getSubsamp
@Deprecated public int getSubsamp()
Deprecated.Useinstead.get(TJ.PARAM_SUBSAMP)
-
getColorspace
@Deprecated public int getColorspace()
Deprecated.Useinstead.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 TJExceptionDecompress 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_STOPONWARNINGis set.)- Parameters:
dstBuf- buffer that will receive the packed-pixel decompressed/decoded image. This buffer should normally bepitch * destinationHeightbytes in size. However, the buffer may also be larger, in which case thex,y, andpitchparameters 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, thendestinationHeightis 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, thendestinationHeightis 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)destinationWidthis 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, thendestinationWidthis 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 TJExceptionDeprecated.- Throws:
TJException
-
decompress8
public byte[] decompress8(int pitch, int pixelFormat) throws TJExceptionDecompress 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 TJExceptionDeprecated.- Throws:
TJException
-
decompress12
public void decompress12(short[] dstBuf, int x, int y, int pitch, int pixelFormat) throws TJExceptionDecompress 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_STOPONWARNINGis set.)- Parameters:
dstBuf- buffer that will receive the packed-pixel decompressed image. This buffer should normally bepitch * destinationHeightsamples in size. However, the buffer may also be larger, in which case thex,y, andpitchparameters 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, thendestinationHeightis 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, thendestinationHeightis 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)destinationWidthis 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, thendestinationWidthis 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 TJExceptionDecompress 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 a 12-bit-per-sample packed-pixel decompressed image.
- Throws:
TJException
-
decompress16
public void decompress16(short[] dstBuf, int x, int y, int pitch, int pixelFormat) throws TJExceptionDecompress 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_STOPONWARNINGis set.)- Parameters:
dstBuf- buffer that will receive the packed-pixel decompressed image. This buffer should normally bepitch * jpegHeightsamples in size. However, the buffer may also be larger, in which case thex,y, andpitchparameters 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 TJExceptionDecompress 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 a 16-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 givenYUVImageinstance. 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_STOPONWARNINGis set.)- Parameters:
dstImage-YUVImageinstance that will receive the planar YUV decompressed image. The level of subsampling specified in thisYUVImageinstance must match that of the JPEG image, and the width and height specified in theYUVImageinstance 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 aYUVImageinstance 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.) Ifstridesis 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
YUVImageinstance 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 aYUVImageinstance 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
YUVImageinstance 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 TJExceptionDecompress 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_STOPONWARNINGis set.)- Parameters:
dstBuf- buffer that will receive the packed-pixel decompressed/decoded image. This buffer should normally bestride * destinationHeightpixels in size. However, the buffer may also be larger, in which case thex,y, andpitchparameters 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, thendestinationHeightis 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, thendestinationHeightis 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, thendestinationWidthis 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, thendestinationWidthis 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 TJExceptionDeprecated.- Throws:
TJException
-
decompress8
public void decompress8(java.awt.image.BufferedImage dstImage) throws TJExceptionDecompress 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 givenBufferedImageinstance.NOTE: The destination image is fully recoverable if this method throws a non-fatal
TJException(unlessTJ.PARAM_STOPONWARNINGis set.)- Parameters:
dstImage- aBufferedImageinstance that will receive the packed-pixel decompressed/decoded image. If the source image is a lossy JPEG image, then the width and height of theBufferedImageinstance 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 theBufferedImageinstance 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 TJExceptionDeprecated.- Throws:
TJException
-
decompress8
public java.awt.image.BufferedImage decompress8(int bufferedImageType) throws TJExceptionDecompress the 8-bit-per-sample JPEG source image or decode the planar YUV source image associated with this decompressor instance and return aBufferedImageinstance containing the 8-bit-per-sample packed-pixel decompressed/decoded image.- Parameters:
bufferedImageType- the image type of theBufferedImageinstance that will be created (for instance,BufferedImage.TYPE_INT_RGB)- Returns:
- a
BufferedImageinstance 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 TJExceptionDeprecated.- Throws:
TJException
-
close
public void close() throws TJExceptionFree the native structures associated with this decompressor instance.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
TJException
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
-