#include <cafe/jpeg.h>

    void               *pDestBuf,
    u32                 destBufSize,
    u32                *pActualDestSize,
    const u32          *pTexBuf,
    const JPEGImageDim *pTexDim,
    s32                 quality,
    void               *pWorkArea,
    u32                 workAreaSize);


pDestBuf The start address of the buffer used to store the JPEG binary to be encoded. Be sure to specify a large enough buffer if you do not know the size of the JPEG data to be encoded.
destBufSize The size of pDestBuf.
pActualDestSize The size of the JPEG binary to be encoded.
pTexBuf The start address of the buffer used to store the surface image to be encoded. The format of the surface image must conform to the GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM specification of GX2SurfaceFormat. Behavior is undefined for invalid surface image.
pTexDim The address of the JPEGImageDim object that includes the width, height, and number of colors of the pTexBuf surface image to be encoded.
quality The compressed image quality in the range from 1 to 100. In general, the greater this value is, the better the image quality, but the lower the compression rate. The JPEG_STATUS_ARGS error code is returned if the input value is invalid.
pWorkArea The start address of the temporary buffer used to decode JPEG binary.
workAreaSize The size of pWorkArea.

Return Values

JPEG_STATUS_OK Function completed successfully.
Any other value Abnormal exit.


Encodes the surface image accepted as input and outputs the corresponding JPEG binary.

When encoding surface image brought from GX2 rendering system, the surface must be tiled with GX2_TILE_MODE_LINEAR_ALIGNED or GX2_TILE_MODE_LINEAR_SPECIAL specification, and have no padding and no swizzling. In a case where surface image to be encoded is configured with different specifications, the surface must be converted to fit above constraints of JPEG encoder using GX2CopySurface by specifying GX2_TILE_MODE_LINEAR_SPECIAL to tileMode of GX2Surface. As this API converts tilling mode to GX2_TILE_MODE_LINEAR_SPECIAL using CPU, not GPU, this conversion should be slower than one to other tilling mode. It is given that the surface buffer pTexBuf and its dimension pTexDim will not be modified.

For more information, refer to the GX2Surface related pages listed in the See Also section of this topic.

Do Not Call From

Multiple threads This function is not thread-safe.

See Also

GX2 Surface APIs
GX2 Surface Copying, Resizing, Re-Formatting, etc.
GX2 Texture APIs
GX2 Texture Swizzle APIs

Revision History

2013/06/03 Changed argument order of API and Added notion about constant arguments.
2013/05/08 Automated cleanup pass.
2013/05/06 Link GX2 related references in the See Also section.
2013/02/19 Replaced words 'texture' with 'surface'. Appended description for use with GX2.
2011/08/08 Initial version.