TCL_EncodeAndWritePicture

# TCL_EncodeAndWritePicture(Ex)

## Definition

  `#include <twl/tcl.h>`

      TCLResult TCL_EncodeAndWritePicture( TCLAccessor* pAccessor ,
                                           const void* imageBuffer ,
                                           u8* jpegBuffer ,
                                           u32 jpegBufferSize ,
                                           u8* workBuffer ,
                                           u32 quality ,
                                           u32 option ,
                                           FSResult* pFSResult );

      TCLResult TCL_EncodeAndWritePictureEx( TCLAccessor* pAccessor ,
                                             const void* imageBuffer ,
                                             u8* jpegBuffer ,
                                             u32 jpegBufferSize ,
                                             u8* workBuffer ,
                                             u32 quality ,
                                             u32 option ,
                                             u8* makerNoteBuffer ,
                                             u16 makerNoteBufferSize ,
                                             FSResult* pFSResult );

## Arguments

pAccessor | Accessor
imageBuffer | Source image buffer
jpegBuffer | JPEG image buffer
jpegBufferSize | Size of the JPEG image buffer
workBuffer | JPEG encoding work buffer
quality | JPEG encoding quality
option | JPEG encoding option
makerNoteBuffer | User maker note buffer
makerNoteBufferSize | User maker note buffer size
pFSResult | Processing result when an error has been generated by an FS function inside this function

## Return Values

Processing result

## Description

Encodes the source image data in JPEG and saves the data. Internally calls the `SSP_StartJpegEncoderLite` function.

It is necessary for the source image to have VGA dimensions.

The work buffer should allocate the size determined by the `TCL_GetJpegEncoderBufferSize` function.

After encoding succeeds, saves to the JPEG image's next save path and overwrites the management file.

If this function returns `TCL_RESULT_ERROR_NO_NEXT_INDEX`, the JPEG image cannot be saved because of a path restriction. Note that this error is also returned when `TCL_CalcNumEnableToTakePictures` is greater than 0.

The accessor must be initialized by the `TCL_LoadTable` or `TCL_CreateTable` function.

If the encoding process failed because `jpegBufferSize` was small, `quality` was high, or for some other reason, the function will automatically lower `quality` internally and continue to retry until encoding is successful. If even lowering `quality` to its limit does not result in success, `TCL_RESULT_ERROR_OTHER` is returned.

## See Also

`TCL_GetJpegEncoderBufferSize`

## Revision History

2009/04/30 Changed the SSP function that is called internally.
2009/04/16 Added information on behavior when internal encoding fails.
2008/12/05 Initial version.

CONFIDENTIAL