1#ifndef MATCHA_IMGCONV_H
2#define MATCHA_IMGCONV_H
3
4#include <stddef.h>
5
6// ImageResult holds the output of decode_to_png.
7typedef struct {
8 unsigned char* png_data; // PNG-encoded bytes (caller must free)
9 size_t png_len; // Length of png_data
10 int width; // Image width in pixels
11 int height; // Image height in pixels
12 int ok; // 1 on success, 0 on failure
13} ImageResult;
14
15// decode_to_png takes raw image bytes (JPEG, PNG, BMP, GIF, etc.),
16// decodes them, and re-encodes as PNG. Supports any format that
17// stb_image can decode.
18ImageResult decode_to_png(const unsigned char* data, size_t len);
19
20// free_image_result frees the PNG data inside an ImageResult.
21void free_image_result(ImageResult* r);
22
23// image_dimensions returns only the width and height of an image without
24// fully decoding pixel data. Faster than decode_to_png when you only need
25// dimensions. Returns 1 on success, 0 on failure.
26int image_dimensions(const unsigned char* data, size_t len, int* width, int* height);
27
28#endif