cReadJPEG
unsigned char* cReadJPEG(void* jpeg, size_t bytes, size_t& width, size_t& height);
Decodes JPEG bytes and returns the image dimensions. The returned pixel array must be deleted with delete[].
Graphics & compute
Encode, decode, and place JPEG images in four-channel pixel buffers.
#include <mc/image.h>On little-endian hosts, normal pixels are tightly packed RGBA; cCreateJPEG_BGRA accepts BGRA input. Image dimensions are in pixels.
Decoded images use new[] and must be released with delete[]. Encoded JPEG buffers must be released with free().
unsigned char* cReadJPEG(void* jpeg, size_t bytes, size_t& width, size_t& height);
Decodes JPEG bytes and returns the image dimensions. The returned pixel array must be deleted with delete[].
unsigned char* cCreateJPEG(unsigned char* src, size_t width, size_t height, int quality, size_t& bytes);
Encodes pixels at JPEG quality 0–100 and writes the returned byte count. Release the result with free().
unsigned char* cCreateJPEG_BGRA(unsigned char* src, size_t width, size_t height, int quality, size_t& bytes);
Like cCreateJPEG(), accepting BGRA pixels on little-endian hosts.
void cAddImage(unsigned char* dst, unsigned char* src, size_t dstWidth, size_t dstHeight, size_t x, size_t y, size_t width, size_t height);
Copies source pixels into the destination at (x,y). The placed image must fit the destination.
void cAddJPEG(unsigned char* dst, unsigned char* jpeg, size_t dstWidth, size_t dstHeight, size_t bytes, size_t x, size_t y);
Decodes a JPEG and places it into the destination at (x,y); the decoded image must fit.