|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.libjpegturbo.turbojpeg.TJCompressor
public class TJCompressor
TurboJPEG compressor
Constructor Summary | |
---|---|
TJCompressor()
Create a TurboJPEG compressor instance. |
|
TJCompressor(byte[] srcImage,
int width,
int pitch,
int height,
int pixelFormat)
Create a TurboJPEG compressor instance and associate the uncompressed source image stored in srcImage with the newly-created
instance. |
|
TJCompressor(byte[] srcImage,
int x,
int y,
int width,
int pitch,
int height,
int pixelFormat)
Create a TurboJPEG compressor instance and associate the uncompressed source image stored in srcImage with the newly-created
instance. |
Method Summary | |
---|---|
void |
close()
Free the native structures associated with this compressor instance. |
void |
compress(java.awt.image.BufferedImage srcImage,
byte[] dstBuf,
int flags)
Compress the uncompressed source image stored in srcImage
and output a JPEG image to the given destination buffer. |
byte[] |
compress(java.awt.image.BufferedImage srcImage,
int flags)
Compress the uncompressed source image stored in srcImage
and return a buffer containing a JPEG image. |
void |
compress(byte[] dstBuf,
int flags)
Compress the uncompressed source image associated with this compressor instance and output a JPEG image to the given destination buffer. |
byte[] |
compress(int flags)
Compress the uncompressed 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)
Encode the uncompressed source image stored in srcImage
and output a YUV planar image to the given destination buffer. |
byte[] |
encodeYUV(java.awt.image.BufferedImage srcImage,
int flags)
Encode the uncompressed source image stored in srcImage
and return a buffer containing a YUV planar image. |
void |
encodeYUV(byte[] dstBuf,
int flags)
Encode the uncompressed source image associated with this compressor instance and output a YUV planar image to the given destination buffer. |
byte[] |
encodeYUV(int flags)
Encode the uncompressed source image associated with this compressor instance and return a buffer containing a YUV planar image. |
protected void |
finalize()
|
int |
getCompressedSize()
Returns the size of the image (in bytes) generated by the most recent compress/encode operation. |
void |
setJPEGQuality(int quality)
Set the JPEG image quality level for subsequent compress operations. |
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 an uncompressed source image with this compressor instance. |
void |
setSourceImageYUV(byte[] srcImage,
int width,
int pad,
int height)
Associate an uncompressed YUV planar source image with this compressor instance. |
void |
setSubsamp(int newSubsamp)
Set the level of chrominance subsampling for subsequent compress/encode operations. |
void |
setYUVPad(int pad)
Set the plane padding for subsequent YUV encode operations. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TJCompressor() throws java.lang.Exception
java.lang.Exception
public TJCompressor(byte[] srcImage, int width, int pitch, int height, int pixelFormat) throws java.lang.Exception
srcImage
with the newly-created
instance.
srcImage
- 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_*
)
java.lang.Exception
public TJCompressor(byte[] srcImage, int x, int y, int width, int pitch, int height, int pixelFormat) throws java.lang.Exception
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_*
)
java.lang.Exception
Method Detail |
---|
public void setSourceImage(byte[] srcImage, int x, int y, int width, int pitch, int height, int pixelFormat) throws java.lang.Exception
srcImage
- image buffer containing RGB, grayscale, or CMYK pixels to
be compressedx
- x offset (in pixels) of the region from which the JPEG image
should be compressed, relative to the start of srcImage
.y
- y offset (in pixels) of the region from which the JPEG image
should be compressed, relative to the start of srcImage
.width
- width (in pixels) of the region in the source image from
which the JPEG image should be compressed.pitch
- bytes per line of the source image. Normally, this should be
width * TJ.pixelSize(pixelFormat)
if the source image is
unpadded, but you can use this parameter to, for instance, specify that
the scanlines in the source image are padded to a 4-byte boundary or to
compress a JPEG image from a region of a larger source image. You can
also be clever and use this parameter to skip lines, etc. Setting this
parameter to 0 is the equivalent of setting it to width *
TJ.pixelSize(pixelFormat)
.height
- height (in pixels) of the region in the source image from
which the JPEG image should be compressed.pixelFormat
- pixel format of the source image (one of
TJ.PF_*
)
java.lang.Exception
@Deprecated public void setSourceImage(byte[] srcImage, int width, int pitch, int height, int pixelFormat) throws java.lang.Exception
setSourceImage(byte[], int, int, int, int, int, int)
instead.
java.lang.Exception
public void setSourceImageYUV(byte[] srcImage, int width, int pad, int height) throws java.lang.Exception
srcImage
- image buffer containing a YUV planar image to be
compressed. The Y, U (Cb), and V (Cr) image planes should be stored
sequentially in the buffer, and the size of each plane is determined by
the specified width, height, and padding, as well as the level of
chrominance subsampling (specified using setSubsamp(int)
.) If the
chrominance components are subsampled along the horizontal dimension, then
the width of the luminance plane should be padded to the nearest multiple
of 2 (same goes for the height of the luminance plane, if the chrominance
components are subsampled along the vertical dimension.) This is
irrespective of any additional padding specified in the pad
parameter.width
- width (in pixels) of the source imagepad
- the line padding used in the source image. For instance, if
each line in each plane of the YUV image is padded to the nearest multiple
of 4 bytes, then pad
should be set to 4.height
- height (in pixels) of the source image
java.lang.Exception
public void setSubsamp(int newSubsamp) throws java.lang.Exception
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: When compressing a YUV planar image into a JPEG image, this method also specifies the level of chrominance subsampling used in the source image.
newSubsamp
- the new level of chrominance subsampling (one of
TJ.SAMP_*
)
java.lang.Exception
public void setJPEGQuality(int quality) throws java.lang.Exception
quality
- the new JPEG image quality level (1 to 100, 1 = worst,
100 = best)
java.lang.Exception
public void compress(byte[] dstBuf, int flags) throws java.lang.Exception
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 image width, height, and level of chrominance subsampling.flags
- the bitwise OR of one or more of TJ.FLAG_*
java.lang.Exception
public byte[] compress(int flags) throws java.lang.Exception
flags
- the bitwise OR of one or more of TJ.FLAG_*
getCompressedSize()
to obtain the size of the JPEG image.
java.lang.Exception
public void compress(java.awt.image.BufferedImage srcImage, byte[] dstBuf, int flags) throws java.lang.Exception
srcImage
and output a JPEG image to the given destination buffer.
srcImage
- a BufferedImage
instance containing RGB or
grayscale pixels to be compresseddstBuf
- buffer that will receive the JPEG image. Use
TJ.bufSize(int, int, int)
to determine the maximum size for this buffer based on
the image width, height, and level of chrominance subsampling.flags
- the bitwise OR of one or more of TJ.FLAG_*
java.lang.Exception
public byte[] compress(java.awt.image.BufferedImage srcImage, int flags) throws java.lang.Exception
srcImage
and return a buffer containing a JPEG image.
srcImage
- a BufferedImage
instance containing RGB or
grayscale pixels to be compressedflags
- the bitwise OR of one or more of TJ.FLAG_*
getCompressedSize()
to obtain the size of the JPEG image.
java.lang.Exception
public void setYUVPad(int pad) throws java.lang.Exception
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.) The default padding is 4 bytes, which generates
images suitable for direct video display.
java.lang.Exception
public void encodeYUV(byte[] dstBuf, int flags) throws java.lang.Exception
NOTE: Technically, the JPEG format uses the YCbCr colorspace, but per the convention of the digital video community, the TurboJPEG API uses "YUV" to refer to an image format consisting of Y, Cb, and Cr image planes.
dstBuf
- buffer that will receive the YUV planar image. Use
TJ.bufSizeYUV(int, int, int, int)
to determine the appropriate size for this buffer
based on the image width, height, and level of chrominance subsampling.flags
- the bitwise OR of one or more of TJ.FLAG_*
java.lang.Exception
public byte[] encodeYUV(int flags) throws java.lang.Exception
encodeYUV(byte[], int)
for more detail.
flags
- the bitwise OR of one or more of TJ.FLAG_*
java.lang.Exception
public void encodeYUV(java.awt.image.BufferedImage srcImage, byte[] dstBuf, int flags) throws java.lang.Exception
srcImage
and output a YUV planar image to the given destination buffer. See
encodeYUV(byte[], int)
for more detail.
srcImage
- a BufferedImage
instance containing RGB or
grayscale pixels to be encodeddstBuf
- buffer that will receive the YUV planar image. Use
TJ.bufSizeYUV(int, int, int, int)
to determine the appropriate size for this buffer
based on the image width, height, and level of chrominance subsampling.flags
- the bitwise OR of one or more of TJ.FLAG_*
java.lang.Exception
public byte[] encodeYUV(java.awt.image.BufferedImage srcImage, int flags) throws java.lang.Exception
srcImage
and return a buffer containing a YUV planar image. See
encodeYUV(byte[], int)
for more detail.
srcImage
- a BufferedImage
instance containing RGB or
grayscale pixels to be encodedflags
- the bitwise OR of one or more of TJ.FLAG_*
java.lang.Exception
public int getCompressedSize()
public void close() throws java.lang.Exception
java.lang.Exception
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |