public final class TJ
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
CS_CMYK
CMYK colorspace
|
static int |
CS_GRAY
Grayscale colorspace
|
static int |
CS_RGB
RGB colorspace
|
static int |
CS_YCbCr
YCbCr colorspace
|
static int |
CS_YCCK
YCCK colorspace
|
static int |
ERR_FATAL
The error was fatal and non-recoverable.
|
static int |
ERR_WARNING
The error was non-fatal and recoverable, but the destination image may
still be corrupt.
|
static int |
FLAG_ACCURATEDCT
Use the most accurate DCT/IDCT algorithm available.
|
static int |
FLAG_BOTTOMUP
Rows in the packed-pixel source/destination image are stored in bottom-up
(Windows, OpenGL) order rather than in top-down (X11) order.
|
static int |
FLAG_FASTDCT
Use the fastest DCT/IDCT algorithm available.
|
static int |
FLAG_FASTUPSAMPLE
When decompressing an image that was generated using chrominance
subsampling, use the fastest chrominance upsampling algorithm available.
|
static int |
FLAG_FORCEMMX
Deprecated.
|
static int |
FLAG_FORCESSE
Deprecated.
|
static int |
FLAG_FORCESSE2
Deprecated.
|
static int |
FLAG_FORCESSE3
Deprecated.
|
static int |
FLAG_LIMITSCANS
Limit the number of progressive JPEG scans that the decompression and
transform operations will process.
|
static int |
FLAG_PROGRESSIVE
When compressing or transforming, generate a progressive JPEG image
instead of a single-scan JPEG image.
|
static int |
FLAG_STOPONWARNING
Immediately discontinue the current compression/decompression/transform
operation if a warning (non-fatal error) occurs.
|
static int |
NUMCS
The number of JPEG colorspaces
|
static int |
NUMERR
The number of error codes
|
static int |
NUMPF
The number of pixel formats
|
static int |
NUMSAMP
The number of chrominance subsampling options
|
static int |
PF_ABGR
ABGR pixel format
|
static int |
PF_ARGB
ARGB pixel format
|
static int |
PF_BGR
BGR pixel format
|
static int |
PF_BGRA
BGRA pixel format
|
static int |
PF_BGRX
BGRX pixel format
|
static int |
PF_CMYK
CMYK pixel format
|
static int |
PF_GRAY
Grayscale pixel format
|
static int |
PF_RGB
RGB pixel format
|
static int |
PF_RGBA
RGBA pixel format
|
static int |
PF_RGBX
RGBX pixel format
|
static int |
PF_XBGR
XBGR pixel format
|
static int |
PF_XRGB
XRGB pixel format
|
static int |
SAMP_411
4:1:1 chrominance subsampling
|
static int |
SAMP_420
4:2:0 chrominance subsampling
|
static int |
SAMP_422
4:2:2 chrominance subsampling
|
static int |
SAMP_440
4:4:0 chrominance subsampling
|
static int |
SAMP_444
4:4:4 chrominance subsampling (no chrominance subsampling)
|
static int |
SAMP_GRAY
Grayscale
|
| Modifier and Type | Method and Description |
|---|---|
static int |
bufSize(int width,
int height,
int jpegSubsamp)
Returns the maximum size of the buffer (in bytes) required to hold a JPEG
image with the given width, height, and level of chrominance subsampling.
|
static int |
bufSizeYUV(int width,
int height,
int subsamp)
Deprecated.
Use
bufSizeYUV(int, int, int, int) instead. |
static int |
bufSizeYUV(int width,
int align,
int height,
int subsamp)
Returns the size of the buffer (in bytes) required to hold a unified
planar YUV image with the given width, height, and level of chrominance
subsampling.
|
static int |
getAlphaOffset(int pixelFormat)
For the given pixel format, returns the number of bytes that the alpha
component is offset from the start of the pixel.
|
static int |
getBlueOffset(int pixelFormat)
For the given pixel format, returns the number of bytes that the blue
component is offset from the start of the pixel.
|
static int |
getGreenOffset(int pixelFormat)
For the given pixel format, returns the number of bytes that the green
component is offset from the start of the pixel.
|
static int |
getMCUHeight(int subsamp)
Returns the iMCU height for the given level of chrominance subsampling.
|
static int |
getMCUWidth(int subsamp)
Returns the iMCU width for the given level of chrominance subsampling.
|
static int |
getPixelSize(int pixelFormat)
Returns the pixel size (in bytes) for the given pixel format.
|
static int |
getRedOffset(int pixelFormat)
For the given pixel format, returns the number of bytes that the red
component is offset from the start of the pixel.
|
static TJScalingFactor[] |
getScalingFactors()
Returns a list of fractional scaling factors that the JPEG decompressor
supports.
|
static int |
planeHeight(int componentID,
int height,
int subsamp)
Returns the plane height of a YUV image plane with the given parameters.
|
static int |
planeSizeYUV(int componentID,
int width,
int stride,
int height,
int subsamp)
Returns the size of the buffer (in bytes) required to hold a YUV image
plane with the given parameters.
|
static int |
planeWidth(int componentID,
int width,
int subsamp)
Returns the plane width of a YUV image plane with the given parameters.
|
public static final int NUMSAMP
public static final int SAMP_444
The JPEG or YUV image will contain one chrominance component for every pixel in the source image.
public static final int SAMP_422
The JPEG or YUV image will contain one chrominance component for every 2x1 block of pixels in the source image.
public static final int SAMP_420
The JPEG or YUV image will contain one chrominance component for every 2x2 block of pixels in the source image.
public static final int SAMP_GRAY
The JPEG or YUV image will contain no chrominance components.
public static final int SAMP_440
The JPEG or YUV image will contain one chrominance component for every 1x2 block of pixels in the source image.
NOTE: 4:4:0 subsampling is not fully accelerated in libjpeg-turbo.
public static final int SAMP_411
The JPEG or YUV image will contain one chrominance component for every 4x1 block of pixels in the source image. All else being equal, a JPEG image with 4:1:1 subsampling is almost exactly the same size as a JPEG image with 4:2:0 subsampling, and in the aggregate, both subsampling methods produce approximately the same perceptual quality. However, 4:1:1 is better able to reproduce sharp horizontal features.
NOTE: 4:1:1 subsampling is not fully accelerated in libjpeg-turbo.
public static final int NUMPF
public static final int PF_RGB
The red, green, and blue components in the image are stored in 3-byte pixels in the order R, G, B from lowest to highest byte address within each pixel.
public static final int PF_BGR
The red, green, and blue components in the image are stored in 3-byte pixels in the order B, G, R from lowest to highest byte address within each pixel.
public static final int PF_RGBX
The red, green, and blue components in the image are stored in 4-byte pixels in the order R, G, B from lowest to highest byte address within each pixel. The X component is ignored when compressing/encoding and undefined when decompressing/decoding.
public static final int PF_BGRX
The red, green, and blue components in the image are stored in 4-byte pixels in the order B, G, R from lowest to highest byte address within each pixel. The X component is ignored when compressing/encoding and undefined when decompressing/decoding.
public static final int PF_XBGR
The red, green, and blue components in the image are stored in 4-byte pixels in the order R, G, B from highest to lowest byte address within each pixel. The X component is ignored when compressing/encoding and undefined when decompressing/decoding.
public static final int PF_XRGB
The red, green, and blue components in the image are stored in 4-byte pixels in the order B, G, R from highest to lowest byte address within each pixel. The X component is ignored when compressing/encoding and undefined when decompressing/decoding.
public static final int PF_GRAY
Each 1-byte pixel represents a luminance (brightness) level from 0 to 255.
public static final int PF_RGBA
This is the same as PF_RGBX, except that when
decompressing/decoding, the X byte is guaranteed to be 0xFF, which can be
interpreted as an opaque alpha channel.
public static final int PF_BGRA
This is the same as PF_BGRX, except that when
decompressing/decoding, the X byte is guaranteed to be 0xFF, which can be
interpreted as an opaque alpha channel.
public static final int PF_ABGR
This is the same as PF_XBGR, except that when
decompressing/decoding, the X byte is guaranteed to be 0xFF, which can be
interpreted as an opaque alpha channel.
public static final int PF_ARGB
This is the same as PF_XRGB, except that when
decompressing/decoding, the X byte is guaranteed to be 0xFF, which can be
interpreted as an opaque alpha channel.
public static final int PF_CMYK
Unlike RGB, which is an additive color model used primarily for
display, CMYK (Cyan/Magenta/Yellow/Key) is a subtractive color model used
primarily for printing. In the CMYK color model, the value of each color
component typically corresponds to an amount of cyan, magenta, yellow, or
black ink that is applied to a white background. In order to convert
between CMYK and RGB, it is necessary to use a color management system
(CMS.) A CMS will attempt to map colors within the printer's gamut to
perceptually similar colors in the display's gamut and vice versa, but the
mapping is typically not 1:1 or reversible, nor can it be defined with a
simple formula. Thus, such a conversion is out of scope for a codec
library. However, the TurboJPEG API allows for compressing packed-pixel
CMYK images into YCCK JPEG images (see CS_YCCK) and decompressing
YCCK JPEG images into packed-pixel CMYK images.
public static final int NUMCS
public static final int CS_RGB
When generating the JPEG image, the R, G, and B components in the sourceimage are reordered into image planes, but no colorspace conversion or subsampling is performed. RGB JPEG images can be decompressed to packed-pixel images with any of the extended RGB or grayscale pixel formats, but they cannot be decompressed to planar YUV images.
public static final int CS_YCbCr
YCbCr is not an absolute colorspace but rather a mathematical transformation of RGB designed solely for storage and transmission. YCbCr images must be converted to RGB before they can be displayed. In the YCbCr colorspace, the Y (luminance) component represents the black & white portion of the original image, and the Cb and Cr (chrominance) components represent the color portion of the original image. Historically, the analog equivalent of this transformation allowed the same signal to be displayed to both black & white and color televisions, but JPEG images use YCbCr primarily because it allows the color data to be optionally subsampled in order to reduce network and disk usage. YCbCr is the most common JPEG colorspace, and YCbCr JPEG images can be generated from and decompressed to packed-pixel images with any of the extended RGB or grayscale pixel formats. YCbCr JPEG images can also be generated from and decompressed to planar YUV images.
public static final int CS_GRAY
The JPEG image retains only the luminance data (Y component), and any color data from the source image is discarded. Grayscale JPEG images can be generated from and decompressed to packed-pixel images with any of the extended RGB or grayscale pixel formats, or they can be generated from and decompressed to planar YUV images.
public static final int CS_CMYK
When generating the JPEG image, the C, M, Y, and K components in the source image are reordered into image planes, but no colorspace conversion or subsampling is performed. CMYK JPEG images can only be decompressed to packed-pixel images with the CMYK pixel format.
public static final int CS_YCCK
YCCK (AKA "YCbCrK") is not an absolute colorspace but rather a mathematical transformation of CMYK designed solely for storage and transmission. It is to CMYK as YCbCr is to RGB. CMYK pixels can be reversibly transformed into YCCK, and as with YCbCr, the chrominance components in the YCCK pixels can be subsampled without incurring major perceptual loss. YCCK JPEG images can only be generated from and decompressed to packed-pixel images with the CMYK pixel format.
public static final int FLAG_BOTTOMUP
@Deprecated public static final int FLAG_FORCEMMX
@Deprecated public static final int FLAG_FORCESSE
@Deprecated public static final int FLAG_FORCESSE2
@Deprecated public static final int FLAG_FORCESSE3
public static final int FLAG_FASTUPSAMPLE
public static final int FLAG_FASTDCT
public static final int FLAG_ACCURATEDCT
public static final int FLAG_STOPONWARNING
NOTE: Due to the design of the TurboJPEG Java API, only certain methods
(specifically, TJDecompressor.decompress*() methods
with a void return type) will complete and leave the destination image in
a fully recoverable state after a non-fatal error occurs.
public static final int FLAG_PROGRESSIVE
public static final int FLAG_LIMITSCANS
public static final int NUMERR
public static final int ERR_WARNING
NOTE: Due to the design of the TurboJPEG Java API, only certain methods
(specifically, TJDecompressor.decompress*() methods
with a void return type) will complete and leave the destination image in
a fully recoverable state after a non-fatal error occurs.
public static final int ERR_FATAL
public static int getMCUWidth(int subsamp)
In a typical JPEG image, 8x8 blocks of DCT coefficients for each component are interleaved in a single scan. If the image uses chrominance subsampling, then multiple luminance blocks are stored together, followed by a single block for each chrominance component. The minimum set of full-resolution luminance block(s) and corresponding (possibly subsampled) chrominance blocks necessary to represent at least one DCT block per component is called a "Minimum Coded Unit" or "MCU". (For example, an MCU in an interleaved JPEG image that uses 4:2:2 subsampling consists of two luminance blocks followed by one block for each chrominance component.) In a non-interleaved JPEG image, each component is stored in a separate scan, and an MCU is a single DCT block, so we use the term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in an interleaved JPEG image. For the common case of interleaved JPEG images, an iMCU is the same as an MCU.
subsamp - the level of chrominance subsampling (one of
SAMP_*)public static int getMCUHeight(int subsamp)
In a typical JPEG image, 8x8 blocks of DCT coefficients for each component are interleaved in a single scan. If the image uses chrominance subsampling, then multiple luminance blocks are stored together, followed by a single block for each chrominance component. The minimum set of full-resolution luminance block(s) and corresponding (possibly subsampled) chrominance blocks necessary to represent at least one DCT block per component is called a "Minimum Coded Unit" or "MCU". (For example, an MCU in an interleaved JPEG image that uses 4:2:2 subsampling consists of two luminance blocks followed by one block for each chrominance component.) In a non-interleaved JPEG image, each component is stored in a separate scan, and an MCU is a single DCT block, so we use the term "iMCU" (interleaved MCU) to refer to the equivalent of an MCU in an interleaved JPEG image. For the common case of interleaved JPEG images, an iMCU is the same as an MCU.
subsamp - the level of chrominance subsampling (one of
SAMP_*)public static int getPixelSize(int pixelFormat)
pixelFormat - the pixel format (one of PF_*)public static int getRedOffset(int pixelFormat)
TJ.PF_BGRX is stored in char pixel[],
then the red component is pixel[TJ.getRedOffset(TJ.PF_BGRX)].pixelFormat - the pixel format (one of PF_*)public static int getGreenOffset(int pixelFormat)
TJ.PF_BGRX is stored in char pixel[],
then the green component is
pixel[TJ.getGreenOffset(TJ.PF_BGRX)].pixelFormat - the pixel format (one of PF_*)public static int getBlueOffset(int pixelFormat)
TJ.PF_BGRX is stored in char pixel[],
then the blue component is
pixel[TJ.getBlueOffset(TJ.PF_BGRX)].pixelFormat - the pixel format (one of PF_*)public static int getAlphaOffset(int pixelFormat)
TJ.PF_BGRA is stored in char pixel[],
then the alpha component is
pixel[TJ.getAlphaOffset(TJ.PF_BGRA)].pixelFormat - the pixel format (one of PF_*)public static int bufSize(int width,
int height,
int jpegSubsamp)
width - the width (in pixels) of the JPEG imageheight - the height (in pixels) of the JPEG imagejpegSubsamp - the level of chrominance subsampling to be used when
generating the JPEG image (one of TJ.SAMP_*)public static int bufSizeYUV(int width,
int align,
int height,
int subsamp)
width - the width (in pixels) of the YUV imagealign - row alignment (in bytes) of the YUV image (must be a power of
2.) Setting this parameter to n specifies that each row in each plane of
the YUV image will be padded to the nearest multiple of n bytes
(1 = unpadded.)height - the height (in pixels) of the YUV imagesubsamp - the level of chrominance subsampling used in the YUV
image (one of TJ.SAMP_*)@Deprecated
public static int bufSizeYUV(int width,
int height,
int subsamp)
bufSizeYUV(int, int, int, int) instead.public static int planeSizeYUV(int componentID,
int width,
int stride,
int height,
int subsamp)
componentID - ID number of the image plane (0 = Y, 1 = U/Cb,
2 = V/Cr)width - width (in pixels) of the YUV image. NOTE: This is the width
of the whole image, not the plane width.stride - bytes per row in the image plane.height - height (in pixels) of the YUV image. NOTE: This is the
height of the whole image, not the plane height.subsamp - the level of chrominance subsampling used in the YUV
image (one of TJ.SAMP_*)public static int planeWidth(int componentID,
int width,
int subsamp)
YUVImage for a description of plane width.componentID - ID number of the image plane (0 = Y, 1 = U/Cb,
2 = V/Cr)width - width (in pixels) of the YUV imagesubsamp - the level of chrominance subsampling used in the YUV image
(one of TJ.SAMP_*)public static int planeHeight(int componentID,
int height,
int subsamp)
YUVImage for a description of plane height.componentID - ID number of the image plane (0 = Y, 1 = U/Cb,
2 = V/Cr)height - height (in pixels) of the YUV imagesubsamp - the level of chrominance subsampling used in the YUV image
(one of TJ.SAMP_*)public static TJScalingFactor[] getScalingFactors()