From ca6c21ebb80a34b03cdf60bf722f2d2a8ebff0bf Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Tue, 1 Oct 2024 18:10:52 -0500 Subject: [PATCH] add saving and loading qoi --- scripts/engine.js | 2 +- source/engine/texture.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/engine.js b/scripts/engine.js index c1bd80d..a4a5869 100644 --- a/scripts/engine.js +++ b/scripts/engine.js @@ -137,7 +137,7 @@ json.doc = { }; Resources.scripts = ["jsoc", "jsc", "jso", "js"]; -Resources.images = ["png", "gif", "jpg", "jpeg"]; +Resources.images = ["qoi", "png", "gif", "jpg", "jpeg"]; Resources.sounds = ["wav", "flac", "mp3", "qoa"]; Resources.is_image = function (path) { var ext = path.ext(); diff --git a/source/engine/texture.c b/source/engine/texture.c index 848ce05..268e2b5 100644 --- a/source/engine/texture.c +++ b/source/engine/texture.c @@ -314,6 +314,13 @@ void texture_save(texture *tex, const char *file) stbi_write_tga(file, tex->width, tex->height, 4, tex->data); else if (!strcmp(ext, ".jpg") || !strcmp(ext, ".jpeg")) stbi_write_jpg(file, tex->width, tex->height, 4, tex->data, 5); + else if (!strcmp(ext, ".qoi")) + qoi_write(file, tex->data, &(qoi_desc) { + .width = tex->width, + .height = tex->height, + .channels = 4, + .colorspace = QOI_SRGB + }); } // copy texture src to dest