add saving and loading qoi

This commit is contained in:
John Alanbrook 2024-10-01 18:10:52 -05:00
parent dbaf482385
commit ca6c21ebb8
2 changed files with 8 additions and 1 deletions

View file

@ -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();

View file

@ -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