public class TJDecompressor
extends java.lang.Object
implements java.io.Closeable
| Modifier and Type | Field and Description | 
|---|---|
| protected long | handle | 
| protected byte[] | jpegBuf | 
| protected int | jpegBufSize | 
| protected int | jpegColorspace | 
| protected int | jpegHeight | 
| protected int | jpegSubsamp | 
| protected int | jpegWidth | 
| protected YUVImage | yuvImage | 
| Constructor and 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 in  jpegImagewith 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 length  imageSizebytes stored injpegImagewith the newly created instance. | 
| TJDecompressor(YUVImage yuvImage)Create a TurboJPEG decompressor instance and associate the planar YUV
 source image stored in  yuvImagewith the newly created
 instance. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | close()Free the native structures associated with this decompressor instance. | 
| void | decompress(java.awt.image.BufferedImage dstImage,
          int flags)Decompress the JPEG source image or decode the planar YUV source image
 associated with this decompressor instance and output a packed-pixel
 decompressed/decoded image to the given  BufferedImageinstance. | 
| void | decompress(byte[] dstBuf,
          int desiredWidth,
          int pitch,
          int desiredHeight,
          int pixelFormat,
          int flags)Deprecated. 
 | 
| void | decompress(byte[] dstBuf,
          int x,
          int y,
          int desiredWidth,
          int pitch,
          int desiredHeight,
          int pixelFormat,
          int flags)Decompress the JPEG source image or decode the planar YUV source image
 associated with this decompressor instance and output a packed-pixel
 grayscale, RGB, or CMYK image to the given destination buffer. | 
| void | decompress(int[] dstBuf,
          int x,
          int y,
          int desiredWidth,
          int stride,
          int desiredHeight,
          int pixelFormat,
          int flags)Decompress the JPEG source image or decode the planar YUV source image
 associated with this decompressor instance and output a packed-pixel
 grayscale, RGB, or CMYK image to the given destination buffer. | 
| java.awt.image.BufferedImage | decompress(int desiredWidth,
          int desiredHeight,
          int bufferedImageType,
          int flags)Decompress the JPEG source image or decode the planar YUV source image
 associated with this decompressor instance and return a
  BufferedImageinstance containing the packed-pixel
 decompressed/decoded image. | 
| byte[] | decompress(int desiredWidth,
          int pitch,
          int desiredHeight,
          int pixelFormat,
          int flags)Decompress the JPEG source image or decode the planar YUV source image
 associated with this decompressor instance and return a buffer containing
 the packed-pixel decompressed image. | 
| void | decompressToYUV(byte[] dstBuf,
               int flags)Deprecated. 
 Use  decompressToYUV(YUVImage, int)instead. | 
| byte[] | decompressToYUV(int flags)Deprecated. 
 Use  decompressToYUV(int, int, int, int)instead. | 
| YUVImage | decompressToYUV(int desiredWidth,
               int[] strides,
               int desiredHeight,
               int flags)Decompress the JPEG source image associated with this decompressor
 instance into a set of Y, U (Cb), and V (Cr) image planes and return a
  YUVImageinstance containing the decompressed image planes. | 
| YUVImage | decompressToYUV(int desiredWidth,
               int align,
               int desiredHeight,
               int flags)Decompress the JPEG source image associated with this decompressor
 instance into a unified planar YUV image and return a  YUVImageinstance containing the decompressed image. | 
| void | decompressToYUV(YUVImage dstImage,
               int flags)Decompress the JPEG source image associated with this decompressor
 instance into a planar YUV image and store it in the given
  YUVImageinstance. | 
| protected void | finalize() | 
| int | getColorspace()Returns the colorspace used in the source image (JPEG or YUV) associated
 with this decompressor instance. | 
| 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)Returns the height of the largest scaled-down image that the TurboJPEG
 decompressor can generate without exceeding the desired image width and
 height. | 
| int | getScaledWidth(int desiredWidth,
              int desiredHeight)Returns the width of the largest scaled-down image that the TurboJPEG
 decompressor can generate without exceeding the desired image width and
 height. | 
| int | getSubsamp()Returns the level of chrominance subsampling used in the source image
 (JPEG or YUV) associated with this decompressor instance. | 
| int | getWidth()Returns the width of the source image (JPEG or YUV) associated with this
 decompressor instance. | 
| void | setJPEGImage(byte[] jpegImage,
            int imageSize)Deprecated. 
 Use  setSourceImage(byte[], int)instead. | 
| void | setSourceImage(byte[] jpegImage,
              int imageSize)Associate the JPEG image or "abbreviated table specification" (AKA
 "tables-only") datastream of length  imageSizebytes stored injpegImagewith this decompressor instance. | 
| void | setSourceImage(YUVImage srcImage)Associate the specified planar YUV source image with this decompressor
 instance. | 
protected long handle
protected byte[] jpegBuf
protected int jpegBufSize
protected YUVImage yuvImage
protected int jpegWidth
protected int jpegHeight
protected int jpegSubsamp
protected int jpegColorspace
public TJDecompressor()
               throws TJException
TJExceptionpublic TJDecompressor(byte[] jpegImage)
               throws TJException
jpegImage with the newly created instance.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.TJExceptionpublic TJDecompressor(byte[] jpegImage,
              int imageSize)
               throws TJException
imageSize bytes stored in jpegImage
 with the newly created instance.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)TJExceptionpublic TJDecompressor(YUVImage yuvImage) throws TJException
yuvImage with the newly created
 instance.yuvImage - YUVImage instance containing a planar YUV source
 image to be decoded.  This image is not modified.TJExceptionpublic void setSourceImage(byte[] jpegImage,
                  int imageSize)
                    throws TJException
imageSize bytes stored in
 jpegImage with this decompressor instance.  If
 jpegImage 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.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)TJException@Deprecated
public void setJPEGImage(byte[] jpegImage,
                           int imageSize)
                  throws TJException
setSourceImage(byte[], int) instead.TJExceptionpublic void setSourceImage(YUVImage srcImage)
srcImage - YUVImage instance containing a planar YUV source
 image to be decoded.  This image is not modified.public int getWidth()
public int getHeight()
public int getSubsamp()
TJ.SAMP_*.public int getColorspace()
TJ.CS_*.  If the
 source image is YUV, then this always returns TJ.CS_YCbCr.public byte[] getJPEGBuf()
public int getJPEGSize()
public int getScaledWidth(int desiredWidth,
                 int desiredHeight)
desiredWidth - desired width (in pixels) of the decompressed image.
 Setting this to 0 is the same as setting it to the width of the JPEG
 image.  (In other words, the width will not be considered when determining
 the scaled image size.)desiredHeight - desired height (in pixels) of the decompressed image.
 Setting this to 0 is the same as setting it to the height of the JPEG
 image.  (In other words, the height will not be considered when
 determining the scaled image size.)public int getScaledHeight(int desiredWidth,
                  int desiredHeight)
desiredWidth - desired width (in pixels) of the decompressed image.
 Setting this to 0 is the same as setting it to the width of the JPEG
 image.  (In other words, the width will not be considered when determining
 the scaled image size.)desiredHeight - desired height (in pixels) of the decompressed image.
 Setting this to 0 is the same as setting it to the height of the JPEG
 image.  (In other words, the height will not be considered when
 determining the scaled image size.)public void decompress(byte[] dstBuf,
              int x,
              int y,
              int desiredWidth,
              int pitch,
              int desiredHeight,
              int pixelFormat,
              int flags)
                throws TJException
 NOTE: The destination image is fully recoverable if this method throws a
 non-fatal TJException (unless
 TJ.FLAG_STOPONWARNING is specified.)
dstBuf - buffer that will receive the packed-pixel
 decompressed/decoded image.  If the source image is a JPEG image, then
 this buffer should normally be pitch * scaledHeight bytes in
 size, where scaledHeight can be determined by calling
 scalingFactor.getScaled(jpegHeight)
 with one of the scaling factors returned from TJ.getScalingFactors()
 or by calling getScaledHeight(int, int).  If the source image is a YUV
 image, then this buffer should normally be pitch * height
 bytes in size, where height is the height of the YUV image.
 However, the buffer may also be larger than the dimensions of the source
 image, in which case the x, y, and
 pitch parameters can be used to specify the region into which
 the source image should be decompressed/decoded.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/decodeddesiredWidth - If the source image is a JPEG image, then this
 specifies the desired width (in pixels) of the decompressed image (or
 image region.)  If the desired destination image dimensions are different
 than the source image dimensions, then TurboJPEG will use scaling in the
 JPEG decompressor to generate the largest possible image that will fit
 within the desired dimensions.  Setting this to 0 is the same as setting
 it to the width of the JPEG image.  (In other words, the width will not be
 considered when determining the scaled image size.)  This parameter is
 ignored if the source image is a YUV image.pitch - bytes per row in the destination image.  Normally this should
 be set to scaledWidth *
 TJ.getPixelSize(pixelFormat),
 if the destination image will be unpadded.  However, you can use this to,
 for instance, pad each row of the destination image to the nearest
 multiple of 4 bytes or to decompress/decode the source image into a region
 of a larger image.  NOTE: if the source image is a JPEG image, then
 scaledWidth can be determined by calling
 scalingFactor.getScaled(jpegWidth)
 or by calling getScaledWidth(int, int).  If the source image is a YUV
 image, then scaledWidth is the width of the YUV image.
 Setting this parameter to 0 is the equivalent of setting it to
 scaledWidth *
 TJ.getPixelSize(pixelFormat).desiredHeight - If the source image is a JPEG image, then this
 specifies the desired height (in pixels) of the decompressed image (or
 image region.)  If the desired destination image dimensions are different
 than the source image dimensions, then TurboJPEG will use scaling in the
 JPEG decompressor to generate the largest possible image that will fit
 within the desired dimensions.  Setting this to 0 is the same as setting
 it to the height of the JPEG image.  (In other words, the height will not
 be considered when determining the scaled image size.)  This parameter is
 ignored if the source image is a YUV image.pixelFormat - pixel format of the decompressed/decoded image (one of
 TJ.PF_*)flags - the bitwise OR of one or more of
 TJ.FLAG_*TJException@Deprecated
public void decompress(byte[] dstBuf,
                         int desiredWidth,
                         int pitch,
                         int desiredHeight,
                         int pixelFormat,
                         int flags)
                throws TJException
decompress(byte[], int, int, int, int, int, int, int) instead.TJExceptionpublic byte[] decompress(int desiredWidth,
                int pitch,
                int desiredHeight,
                int pixelFormat,
                int flags)
                  throws TJException
desiredWidth - see
 decompress(byte[], int, int, int, int, int, int, int)
 for descriptionpitch - see
 decompress(byte[], int, int, int, int, int, int, int)
 for descriptiondesiredHeight - see
 decompress(byte[], int, int, int, int, int, int, int)
 for descriptionpixelFormat - pixel format of the decompressed image (one of
 TJ.PF_*)flags - the bitwise OR of one or more of
 TJ.FLAG_*TJExceptionpublic void decompressToYUV(YUVImage dstImage, int flags) throws TJException
YUVImage 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 (unless
 TJ.FLAG_STOPONWARNING is specified.)
dstImage - YUVImage instance that will receive the planar YUV
 decompressed image.  The level of subsampling specified in this
 YUVImage instance must match that of the JPEG image, and the width
 and height specified in the YUVImage instance must match one of
 the scaled image sizes that the decompressor is capable of generating from
 the JPEG source image.flags - the bitwise OR of one or more of
 TJ.FLAG_*TJException@Deprecated
public void decompressToYUV(byte[] dstBuf,
                              int flags)
                     throws TJException
decompressToYUV(YUVImage, int) instead.TJExceptionpublic YUVImage decompressToYUV(int desiredWidth, int[] strides, int desiredHeight, int flags) throws TJException
YUVImage 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.desiredWidth - desired width (in pixels) of the YUV image.  If the
 desired image dimensions are different than the dimensions of the JPEG
 image being decompressed, then TurboJPEG will use scaling in the JPEG
 decompressor to generate the largest possible image that will fit within
 the desired dimensions.  Setting this to 0 is the same as setting it to
 the width of the JPEG image.  (In other words, the width will not be
 considered when determining the scaled image size.)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
 (see YUVImage.)  If strides 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.desiredHeight - desired height (in pixels) of the YUV image.  If the
 desired image dimensions are different than the dimensions of the JPEG
 image being decompressed, then TurboJPEG will use scaling in the JPEG
 decompressor to generate the largest possible image that will fit within
 the desired dimensions.  Setting this to 0 is the same as setting it to
 the height of the JPEG image.  (In other words, the height will not be
 considered when determining the scaled image size.)flags - the bitwise OR of one or more of
 TJ.FLAG_*YUVImage instance containing the decompressed image
 planesTJExceptionpublic YUVImage decompressToYUV(int desiredWidth, int align, int desiredHeight, int flags) throws TJException
YUVImage
 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.desiredWidth - desired width (in pixels) of the YUV image.  If the
 desired image dimensions are different than the dimensions of the JPEG
 image being decompressed, then TurboJPEG will use scaling in the JPEG
 decompressor to generate the largest possible image that will fit within
 the desired dimensions.  Setting this to 0 is the same as setting it to
 the width of the JPEG image.  (In other words, the width will not be
 considered when determining the scaled image size.)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.)desiredHeight - desired height (in pixels) of the YUV image.  If the
 desired image dimensions are different than the dimensions of the JPEG
 image being decompressed, then TurboJPEG will use scaling in the JPEG
 decompressor to generate the largest possible image that will fit within
 the desired dimensions.  Setting this to 0 is the same as setting it to
 the height of the JPEG image.  (In other words, the height will not be
 considered when determining the scaled image size.)flags - the bitwise OR of one or more of
 TJ.FLAG_*YUVImage instance containing the unified planar YUV
 decompressed imageTJException@Deprecated
public byte[] decompressToYUV(int flags)
                       throws TJException
decompressToYUV(int, int, int, int) instead.TJExceptionpublic void decompress(int[] dstBuf,
              int x,
              int y,
              int desiredWidth,
              int stride,
              int desiredHeight,
              int pixelFormat,
              int flags)
                throws TJException
 NOTE: The destination image is fully recoverable if this method throws a
 non-fatal TJException (unless
 TJ.FLAG_STOPONWARNING is specified.)
dstBuf - buffer that will receive the packed-pixel
 decompressed/decoded image.  If the source image is a JPEG image, then
 this buffer should normally be stride * scaledHeight pixels
 in size, where scaledHeight can be determined by calling
 scalingFactor.getScaled(jpegHeight)
 with one of the scaling factors returned from TJ.getScalingFactors()
 or by calling getScaledHeight(int, int).  If the source image is a YUV
 image, then this buffer should normally be stride * height
 pixels in size, where height is the height of the YUV image.
 However, the buffer may also be larger than the dimensions of the JPEG
 image, in which case the x, y, and
 stride 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 decompressed/decodedy - y offset (in pixels) of the region in the destination image into
 which the source image should be decompressed/decodeddesiredWidth - If the source image is a JPEG image, then this
 specifies the desired width (in pixels) of the decompressed image (or
 image region.)  If the desired destination image dimensions are different
 than the source image dimensions, then TurboJPEG will use scaling in the
 JPEG decompressor to generate the largest possible image that will fit
 within the desired dimensions.  Setting this to 0 is the same as setting
 it to the width of the JPEG image.  (In other words, the width will not be
 considered when determining the scaled image size.)  This parameter is
 ignored if the source image is a YUV image.stride - pixels per row in the destination image.  Normally this
 should be set to scaledWidth, but you can use this to, for
 instance, decompress the JPEG image into a region of a larger image.
 NOTE: if the source image is a JPEG image, then scaledWidth
 can be determined by calling
 scalingFactor.getScaled(jpegWidth)
 or by calling getScaledWidth(int, int).  If the source image is a YUV
 image, then scaledWidth is the width of the YUV image.
 Setting this parameter to 0 is the equivalent of setting it to
 scaledWidth.desiredHeight - If the source image is a JPEG image, then this
 specifies the desired height (in pixels) of the decompressed image (or
 image region.)  If the desired destination image dimensions are different
 than the source image dimensions, then TurboJPEG will use scaling in the
 JPEG decompressor to generate the largest possible image that will fit
 within the desired dimensions.  Setting this to 0 is the same as setting
 it to the height of the JPEG image.  (In other words, the height will not
 be considered when determining the scaled image size.)  This parameter is
 ignored if the source image is a YUV image.pixelFormat - pixel format of the decompressed image (one of
 TJ.PF_*)flags - the bitwise OR of one or more of
 TJ.FLAG_*TJExceptionpublic void decompress(java.awt.image.BufferedImage dstImage,
              int flags)
                throws TJException
BufferedImage
 instance.
 
 NOTE: The destination image is fully recoverable if this method throws a
 non-fatal TJException (unless
 TJ.FLAG_STOPONWARNING is specified.)
dstImage - a BufferedImage instance that will receive
 the packed-pixel decompressed/decoded image.  If the source image is a
 JPEG image, then the width and height of the BufferedImage
 instance must match one of the scaled image sizes that the decompressor is
 capable of generating from the JPEG image.  If the source image is a YUV
 image, then the width and height of the BufferedImage
 instance must match the width and height of the YUV image.flags - the bitwise OR of one or more of
 TJ.FLAG_*TJExceptionpublic java.awt.image.BufferedImage decompress(int desiredWidth,
                                      int desiredHeight,
                                      int bufferedImageType,
                                      int flags)
                                        throws TJException
BufferedImage instance containing the packed-pixel
 decompressed/decoded image.desiredWidth - see
 decompress(byte[], int, int, int, int, int, int, int) for
 descriptiondesiredHeight - see
 decompress(byte[], int, int, int, int, int, int, int) for
 descriptionbufferedImageType - the image type of the BufferedImage
 instance that will be created (for instance,
 BufferedImage.TYPE_INT_RGB)flags - the bitwise OR of one or more of
 TJ.FLAG_*BufferedImage instance containing the packed-pixel
 decompressed/decoded image.TJExceptionpublic void close()
           throws TJException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableTJExceptionprotected void finalize()
                 throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable