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 stored in  jpegImagewith the newly created instance. | 
| TJDecompressor(byte[] jpegImage,
              int imageSize)Create a TurboJPEG decompressor instance and associate the JPEG source
 image of length  imageSizebytes stored injpegImagewith the newly created instance. | 
| TJDecompressor(YUVImage yuvImage)Create a TurboJPEG decompressor instance and associate the YUV planar
 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 YUV source image associated
 with this decompressor instance and output a 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 YUV source image associated
 with this decompressor instance and output a 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 YUV source image associated
 with this decompressor instance and output a 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 YUV source image associated
 with this decompressor instance and return a  BufferedImageinstance containing the decompressed/decoded image. | 
| byte[] | decompress(int desiredWidth,
          int pitch,
          int desiredHeight,
          int pixelFormat,
          int flags)Decompress the JPEG source image associated with this decompressor
 instance and return a buffer containing the 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 pad,
               int desiredHeight,
               int flags)Decompress the JPEG source image associated with this decompressor
 instance into a unified YUV planar image buffer 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 YUV planar 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 image 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 of length  imageSizebytes stored injpegImagewith this decompressor instance. | 
| void | setSourceImage(YUVImage srcImage)Associate the specified YUV planar 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 - JPEG image buffer (size of the JPEG image 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 - JPEG image buffer.  This buffer is not modified.imageSize - size of the JPEG image (in bytes)TJExceptionpublic TJDecompressor(YUVImage yuvImage) throws TJException
yuvImage with the newly created
 instance.yuvImage - YUVImage instance containing a YUV planar
 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.  This image will
 be used as the source image for subsequent decompress operations.jpegImage - JPEG image buffer.  This buffer is not modified.imageSize - size of the JPEG image (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 YUV planar 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 output image is fully recoverable if this method throws a
 non-fatal TJException (unless
 TJ.FLAG_STOPONWARNING is specified.)
dstBuf - buffer that will receive the 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 line of the destination image.  Normally, this
 should be set to scaledWidth * TJ.pixelSize(pixelFormat) if
 the destination image is unpadded, but you can use this to, for instance,
 pad each line of the destination image to a 4-byte boundary 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.pixelSize(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 an RGB or grayscale image.  This method cannot be
 used to decompress JPEG source images with the CMYK or YCCK colorspace.
 
 NOTE: The YUV planar output 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 YUV planar
 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 TurboJPEG 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 an RGB or
 grayscale 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 line in the corresponding plane of the output image.  Setting the
 stride for any plane to 0 is the same as setting it to the scaled
 component width of the plane.  If strides is NULL, then the
 strides for all planes will be set to their respective scaled component
 widths.  You can adjust the strides in order to add an arbitrary amount of
 line 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_*TJExceptionpublic YUVImage decompressToYUV(int desiredWidth, int pad, 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 an RGB or grayscale
 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.)pad - the width of each line in each plane of the YUV image will be
 padded to the nearest multiple of this number of bytes (must be a power of
 2.)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_*TJException@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 output image is fully recoverable if this method throws a
 non-fatal TJException (unless
 TJ.FLAG_STOPONWARNING is specified.)
dstBuf - buffer that will receive the 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 line of 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 output 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 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 TurboJPEG 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 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
 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