Files
kryon/cmd/k2b/k2b_stb.c
T
waozi ddcf455dd3 k2b: decode png/jpg/bmp/webp and embed as cartridge pixels
stb_image (vendored with raylib) decodes referenced Picture() files at
compile time; decoded RGBA8 goes in as kind 0 and renders through
texture_rgba in every engine. KRAW stays for hand-made raw pixels;
undecodable files (wav/ogg/fonts) remain opaque kind 2 blobs for
host-side unpacking. Verified: png cartridge renders after the source
file is deleted.
2026-08-16 21:42:09 -03:00

24 lines
505 B
C

#include "k2b_stb.h"
#define STB_IMAGE_IMPLEMENTATION
#define STBI_NO_PSD
#define STBI_NO_TGA
#define STBI_NO_GIF
#define STBI_NO_HDR
#define STBI_NO_PIC
#define STBI_NO_PNM
#include "../../vendor/raylib/src/external/stb_image.h"
#include <stdlib.h>
int
k2b_decode_image(const char *file, unsigned char **rgba, int *w, int *h)
{
int n;
if(file == NULL || rgba == NULL || w == NULL || h == NULL)
return -1;
*rgba = stbi_load(file, w, h, &n, 4);
return *rgba != NULL ? 0 : -1;
}