Graphics & compute

image.h

Encode, decode, and place JPEG images in four-channel pixel buffers.

C++23 mc/image.h
#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().

Jump to a declaration · 5

Free functions & types

Functions

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[].

cCreateJPEG

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().

cCreateJPEG_BGRA

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.

cAddImage

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.

cAddJPEG

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.