int EncodeBGRAtoWebP(
const uint8_t* bgra,
int width,
int height,
int stride,
float quality,
int lossless,
uint8_t** output,
size_t* outputSize);
- Encodes a BGRA format image into WebP.
- Set
lossless = 1 for lossless encoding, and 0 for lossy encoding.
- The
quality parameter is only applicable during lossy encoding (ranging from 0 to 100).
- Returns
1 on success, or 0 on failure.
int EncodeRGBAtoWebP(
const uint8_t* rgba,
int width,
int height,
int stride,
float quality,
int lossless,
uint8_t** output,
size_t* outputSize);
- The RGBA format variant of the encoder.
- The functional specifications are identical to the BGRA version.
void FreeWebP(uint8_t* data);
- Frees the memory allocated by the encoding functions.
- CRITICAL: This function must always be called after processing to prevent memory leaks.
- The
output parameter is a pointer-to-pointer (e.g., out IntPtr in C#) used to receive the allocated memory address.
- The
output buffer is allocated internally by the libwebp library.
- Ensure
FreeWebP is always executed after usage to properly release memory.
- The
stride parameter represents the data width of a single row in bytes.
- For 4-channel (RGBA/BGRA) images, the
stride is typically calculated as width * 4.
- Providing an incorrect or mismatched pixel format will result in a corrupted output image.