public class TJCompressor
extends java.lang.Object
implements java.io.Closeable
| Constructor and Description | 
|---|
| TJCompressor()Create a TurboJPEG compressor instance. | 
| TJCompressor(java.awt.image.BufferedImage srcImage,
            int x,
            int y,
            int width,
            int height)Create a TurboJPEG compressor instance and associate the packed-pixel
 source image stored in  srcImagewith the newly created
 instance. | 
| TJCompressor(byte[] srcImage,
            int width,
            int pitch,
            int height,
            int pixelFormat)Deprecated. 
 Use
  TJCompressor(byte[], int, int, int, int, int, int)instead. | 
| TJCompressor(byte[] srcImage,
            int x,
            int y,
            int width,
            int pitch,
            int height,
            int pixelFormat)Create a TurboJPEG compressor instance and associate the packed-pixel
 source image stored in  srcImagewith the newly created
 instance. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | close()Free the native structures associated with this compressor instance. | 
| void | compress(java.awt.image.BufferedImage srcImage,
        byte[] dstBuf,
        int flags)Deprecated. 
 Use
  setSourceImage(BufferedImage, int, int, int, int)andcompress(byte[], int)instead. | 
| byte[] | compress(java.awt.image.BufferedImage srcImage,
        int flags)Deprecated. 
 Use
  setSourceImage(BufferedImage, int, int, int, int)andcompress(int)instead. | 
| void | compress(byte[] dstBuf,
        int flags)Compress the packed-pixel or planar YUV source image associated with this
 compressor instance and output a JPEG image to the given destination
 buffer. | 
| byte[] | compress(int flags)Compress the packed-pixel or planar YUV source image associated with this
 compressor instance and return a buffer containing a JPEG image. | 
| void | encodeYUV(java.awt.image.BufferedImage srcImage,
         byte[] dstBuf,
         int flags)Deprecated. 
 Use
  setSourceImage(BufferedImage, int, int, int, int)andencodeYUV(byte[], int)instead. | 
| byte[] | encodeYUV(java.awt.image.BufferedImage srcImage,
         int flags)Deprecated. 
 Use
  setSourceImage(BufferedImage, int, int, int, int)andencodeYUV(int, int)instead. | 
| void | encodeYUV(byte[] dstBuf,
         int flags)Deprecated. 
 Use  encodeYUV(YUVImage, int)instead. | 
| byte[] | encodeYUV(int flags)Deprecated. 
 Use  encodeYUV(int, int)instead. | 
| YUVImage | encodeYUV(int[] strides,
         int flags)Encode the packed-pixel source image associated with this compressor
 instance into separate Y, U (Cb), and V (Cr) image planes and return a
  YUVImageinstance containing the encoded image planes. | 
| YUVImage | encodeYUV(int align,
         int flags)Encode the packed-pixel source image associated with this compressor
 instance into a unified planar YUV image and return a  YUVImageinstance containing the encoded image. | 
| void | encodeYUV(YUVImage dstImage,
         int flags)Encode the packed-pixel source image associated with this compressor
 instance into a planar YUV image and store it in the given
  YUVImageinstance. | 
| protected void | finalize() | 
| int | getCompressedSize()Returns the size of the image (in bytes) generated by the most recent
 compress operation. | 
| void | setJPEGQuality(int quality)Set the JPEG image quality level for subsequent compress operations. | 
| void | setSourceImage(java.awt.image.BufferedImage srcImage,
              int x,
              int y,
              int width,
              int height)Associate a packed-pixel RGB or grayscale source image with this
 compressor instance. | 
| void | setSourceImage(byte[] srcImage,
              int width,
              int pitch,
              int height,
              int pixelFormat)Deprecated. 
 Use
  setSourceImage(byte[], int, int, int, int, int, int)instead. | 
| void | setSourceImage(byte[] srcImage,
              int x,
              int y,
              int width,
              int pitch,
              int height,
              int pixelFormat)Associate a packed-pixel RGB, grayscale, or CMYK source image with this
 compressor instance. | 
| void | setSourceImage(YUVImage srcImage)Associate a planar YUV source image with this compressor instance. | 
| void | setSubsamp(int newSubsamp)Set the level of chrominance subsampling for subsequent compress/encode
 operations. | 
public TJCompressor()
             throws TJException
TJExceptionpublic TJCompressor(byte[] srcImage,
            int x,
            int y,
            int width,
            int pitch,
            int height,
            int pixelFormat)
             throws TJException
srcImage with the newly created
 instance.srcImage - see setSourceImage(byte[], int, int, int, int, int, int) for descriptionx - see setSourceImage(byte[], int, int, int, int, int, int) for descriptiony - see setSourceImage(byte[], int, int, int, int, int, int) for descriptionwidth - see setSourceImage(byte[], int, int, int, int, int, int) for descriptionpitch - see setSourceImage(byte[], int, int, int, int, int, int) for descriptionheight - see setSourceImage(byte[], int, int, int, int, int, int) for descriptionpixelFormat - pixel format of the source image (one of
 TJ.PF_*)TJException@Deprecated
public TJCompressor(byte[] srcImage,
                       int width,
                       int pitch,
                       int height,
                       int pixelFormat)
             throws TJException
TJCompressor(byte[], int, int, int, int, int, int) instead.TJExceptionpublic TJCompressor(java.awt.image.BufferedImage srcImage,
            int x,
            int y,
            int width,
            int height)
             throws TJException
srcImage with the newly created
 instance.srcImage - see
 setSourceImage(BufferedImage, int, int, int, int) for descriptionx - see
 setSourceImage(BufferedImage, int, int, int, int) for descriptiony - see
 setSourceImage(BufferedImage, int, int, int, int) for descriptionwidth - see
 setSourceImage(BufferedImage, int, int, int, int) for descriptionheight - see
 setSourceImage(BufferedImage, int, int, int, int) for descriptionTJExceptionpublic void setSourceImage(byte[] srcImage,
                  int x,
                  int y,
                  int width,
                  int pitch,
                  int height,
                  int pixelFormat)
                    throws TJException
srcImage - buffer containing a packed-pixel RGB, grayscale, or CMYK
 source image to be compressed or encoded.  This buffer is not modified.x - x offset (in pixels) of the region in the source image from which
 the JPEG or YUV image should be compressed/encodedy - y offset (in pixels) of the region in the source image from which
 the JPEG or YUV image should be compressed/encodedwidth - width (in pixels) of the region in the source image from
 which the JPEG or YUV image should be compressed/encodedpitch - bytes per row in the source image.  Normally this should be
 width *
 TJ.getPixelSize(pixelFormat),
 if the source image is unpadded.  However, you can use this parameter to,
 for instance, specify that the rows in the source image are padded to the
 nearest multiple of 4 bytes or to compress/encode a JPEG or YUV image from
 a region of a larger source image.  You can also be clever and use this
 parameter to skip rows, etc.  Setting this parameter to 0 is the
 equivalent of setting it to width *
 TJ.getPixelSize(pixelFormat).height - height (in pixels) of the region in the source image from
 which the JPEG or YUV image should be compressed/encodedpixelFormat - pixel format of the source image (one of
 TJ.PF_*)TJException@Deprecated
public void setSourceImage(byte[] srcImage,
                             int width,
                             int pitch,
                             int height,
                             int pixelFormat)
                    throws TJException
setSourceImage(byte[], int, int, int, int, int, int) instead.TJExceptionpublic void setSourceImage(java.awt.image.BufferedImage srcImage,
                  int x,
                  int y,
                  int width,
                  int height)
                    throws TJException
srcImage - a BufferedImage instance containing a
 packed-pixel RGB or grayscale source image to be compressed or encoded.
 This image is not modified.x - x offset (in pixels) of the region in the source image from which
 the JPEG or YUV image should be compressed/encodedy - y offset (in pixels) of the region in the source image from which
 the JPEG or YUV image should be compressed/encodedwidth - width (in pixels) of the region in the source image from
 which the JPEG or YUV image should be compressed/encoded (0 = use the
 width of the source image)height - height (in pixels) of the region in the source image from
 which the JPEG or YUV image should be compressed/encoded (0 = use the
 height of the source image)TJExceptionpublic void setSourceImage(YUVImage srcImage) throws TJException
srcImage - planar YUV source image to be compressed.  This image is
 not modified.TJExceptionpublic void setSubsamp(int newSubsamp)
TJ.CS_YCbCr) or from CMYK to YCCK (see TJ.CS_YCCK) as part
 of the JPEG compression process, some of the Cb and Cr (chrominance)
 components can be discarded or averaged together to produce a smaller
 image with little perceptible loss of image clarity.  (The human eye is
 more sensitive to small changes in brightness than to small changes in
 color.)  This is called "chrominance subsampling".
 
 NOTE: This method has no effect when compressing a JPEG image from a
 planar YUV source image.  In that case, the level of chrominance
 subsampling in the JPEG image is determined by the source image.
 Furthermore, this method has no effect when encoding to a pre-allocated
 YUVImage instance.  In that case, the level of chrominance
 subsampling is determined by the destination image.
newSubsamp - the level of chrominance subsampling to use in
 subsequent compress/encode oeprations (one of
 TJ.SAMP_*)public void setJPEGQuality(int quality)
quality - the new JPEG image quality level (1 to 100, 1 = worst,
 100 = best)public void compress(byte[] dstBuf,
            int flags)
              throws TJException
dstBuf - buffer that will receive the JPEG image.  Use
 TJ.bufSize(int, int, int) to determine the maximum size for this buffer based on
 the source image's width and height and the desired level of chrominance
 subsampling.flags - the bitwise OR of one or more of
 TJ.FLAG_*TJExceptionpublic byte[] compress(int flags)
                throws TJException
flags - the bitwise OR of one or more of
 TJ.FLAG_*getCompressedSize() to obtain the size of the JPEG image.TJException@Deprecated
public void compress(java.awt.image.BufferedImage srcImage,
                       byte[] dstBuf,
                       int flags)
              throws TJException
setSourceImage(BufferedImage, int, int, int, int) and
 compress(byte[], int) instead.TJException@Deprecated
public byte[] compress(java.awt.image.BufferedImage srcImage,
                         int flags)
                throws TJException
TJExceptionpublic void encodeYUV(YUVImage dstImage, int flags) throws TJException
YUVImage instance.  This method performs color conversion (which
 is accelerated in the libjpeg-turbo implementation) but does not execute
 any of the other steps in the JPEG compression process.  Encoding CMYK
 source images into YUV images is not supported.dstImage - YUVImage instance that will receive the planar YUV
 imageflags - the bitwise OR of one or more of
 TJ.FLAG_*TJException@Deprecated
public void encodeYUV(byte[] dstBuf,
                        int flags)
               throws TJException
encodeYUV(YUVImage, int) instead.TJExceptionpublic YUVImage encodeYUV(int align, int flags) throws TJException
YUVImage
 instance containing the encoded image.  This method performs color
 conversion (which is accelerated in the libjpeg-turbo implementation) but
 does not execute any of the other steps in the JPEG compression process.
 Encoding CMYK source images into YUV images is not supported.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.)flags - the bitwise OR of one or more of
 TJ.FLAG_*YUVImage instance containing the unified planar YUV
 encoded imageTJExceptionpublic YUVImage encodeYUV(int[] strides, int flags) throws TJException
YUVImage instance containing the encoded image planes.  This
 method performs color conversion (which is accelerated in the
 libjpeg-turbo implementation) but does not execute any of the other steps
 in the JPEG compression process.  Encoding CMYK source images into YUV
 images is not supported.strides - an array of integers, each specifying the number of bytes
 per row in the corresponding plane of the YUV source image.  Setting the
 stride for any plane to 0 is the same as setting it to the plane width
 (see YUVImage.)  If strides is null, then the strides
 for all planes will be set to their respective plane widths.  You can
 adjust the strides in order to add an arbitrary amount of row padding to
 each plane.flags - the bitwise OR of one or more of
 TJ.FLAG_*YUVImage instance containing the encoded image planesTJException@Deprecated
public byte[] encodeYUV(int flags)
                 throws TJException
encodeYUV(int, int) instead.TJException@Deprecated
public void encodeYUV(java.awt.image.BufferedImage srcImage,
                        byte[] dstBuf,
                        int flags)
               throws TJException
setSourceImage(BufferedImage, int, int, int, int) and
 encodeYUV(byte[], int) instead.TJException@Deprecated
public byte[] encodeYUV(java.awt.image.BufferedImage srcImage,
                          int flags)
                 throws TJException
TJExceptionpublic int getCompressedSize()
public 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