emote2ss

Animated webp to spritesheets converting tool
git clone git://bsandro.tech/emote2ss
Log | Files | Refs

commit b1092ca1a469424fbf124705bdd1715fd8078d44
parent 1da27ed72e6a3e526f1a55978e8e8240e8fee607
Author: bsandro <email@bsandro.tech>
Date:   Mon,  8 May 2023 02:30:46 +0300

Sample vertical tiles dump

Diffstat:
Msrc/main.c | 12+++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/main.c b/src/main.c @@ -8,6 +8,7 @@ #include "webp/demux.h" #include <stdbool.h> #include <stdlib.h> +#include <strings.h> #include <assert.h> #define NUM_CHANNELS 4 @@ -152,11 +153,20 @@ void write_webp(const char *fname, AnimatedImage *img) { FILE *fp = fopen(fname, "wb"); assert(fp!=NULL); uint8_t *out; + size_t frame_size = img->width * img->height * sizeof(uint32_t); + size_t frames_size = frame_size * img->frame_count; + uint8_t *merged = malloc(frames_size); + assert(merged!=NULL); + bzero(merged, frames_size); + for (uint32_t i=0; i< img->frame_count; ++i) { + memcpy(merged+frame_size*i, img->frames[i].rgba, frame_size); + } int stride = img->width * sizeof(uint32_t); - size_t encoded = WebPEncodeLosslessRGBA(img->frames[0].rgba, img->width, img->height, stride, &out); + size_t encoded = WebPEncodeLosslessRGBA(merged, img->width, img->height*img->frame_count, stride, &out); printf("size: %lu, encoded: %lu\n", img->width*img->height*sizeof(uint32_t), encoded); size_t written = fwrite(out, sizeof(uint8_t), encoded, fp); assert(written==encoded); + free(merged); fclose(fp); }