/* stb_image and its resize for image.zig, static here (a static pardes * links a zstbi beside them), their memory image.zig's: the job's on a * worker, else the pane's arena; both are freed whole. */ #include #include void *pa_image_mem(size_t n); void *pa_image_remem(void *p, size_t old, size_t n); #define STBI_MALLOC(n) pa_image_mem(n) #define STBI_REALLOC_SIZED(p, old, n) pa_image_remem(p, old, n) #define STBI_FREE(p) ((void)(p)) #define STBIR_MALLOC(n, c) ((void)(c), pa_image_mem(n)) #define STBIR_FREE(p, c) ((void)(p), (void)(c)) #define STBI_NO_STDIO #define STBI_NO_HDR #define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_RESIZE_IMPLEMENTATION #define STB_IMAGE_STATIC #define STB_IMAGE_RESIZE_STATIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-function" #include "stb_image.h" #include "stb_image_resize.h" #pragma GCC diagnostic pop int pa_image_info(const unsigned char *b, int n, int *w, int *h) { int c; return stbi_info_from_memory(b, n, w, h, &c); } unsigned char *pa_image_load(const unsigned char *b, int n, int *w, int *h) { int c; return stbi_load_from_memory(b, n, w, h, &c, 4); } int pa_image_resize(const unsigned char *in, int w, int h, unsigned char *out, int nw, int nh) { return stbir_resize_uint8(in, w, h, 0, out, nw, nh, 0, 4); }