// jpge.h - C++ class for JPEG compression. // Public Domain or Apache 2.0, Richard Geldreich <[email protected]> // Alex Evans: Added RGBA support, linear memory allocator. #ifndef JPEG_ENCODER_H #define JPEG_ENCODER_H namespace jpge { uint8; int16; int32; uint16; uint32; uint; // JPEG chroma subsampling factors. Y_ONLY (grayscale images) and H2V2 (color images) are the most common. enum subsampling_t { … }; // JPEG compression parameters structure. struct params { … }; // Writes JPEG image to a file. // num_channels must be 1 (Y) or 3 (RGB), image pitch must be width*num_channels. bool compress_image_to_jpeg_file(const char* pFilename, int width, int height, int num_channels, const uint8* pImage_data, const params& comp_params = params()); // Writes JPEG image to memory buffer. // On entry, buf_size is the size of the output buffer pointed at by pBuf, which should be at least ~1024 bytes. // If return value is true, buf_size will be set to the size of the compressed data. bool compress_image_to_jpeg_file_in_memory(void* pBuf, int& buf_size, int width, int height, int num_channels, const uint8* pImage_data, const params& comp_params = params()); // Output stream abstract class - used by the jpeg_encoder class to write to the output stream. // put_buf() is generally called with len==JPGE_OUT_BUF_SIZE bytes, but for headers it'll be called with smaller amounts. class output_stream { … }; // Lower level jpeg_encoder class - useful if more control is needed than the above helper functions. class jpeg_encoder { … }; } // namespace jpge #endif // JPEG_ENCODER