emote2ss

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

commit 567246aa23201c1cc237439516d864c31025bff4
parent c5cfc4dafcd131df9c4bbd70bcb134a70ce43b89
Author: bsandro <[email protected]>
Date:   Wed,  5 Jul 2023 02:14:05 +0300

transitional commit (moving to another pc)

Diffstat:
Msrc/main.c | 15++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/main.c b/src/main.c @@ -149,18 +149,21 @@ int read_webp(const char *fname, AnimatedImage *anim) { return 0; } -void write_webp(const char *fname, AnimatedImage *img) { +void write_webp(const char *fname, AnimatedImage *img, int cols, int rows) { + // validate that we have enough space in resulting picture for all the frames + assert(rows*cols >= (int)img->frame_count); 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; + size_t img_size = frame_size * img->frame_count; size_t line_size = img->width * sizeof(uint32_t); size_t full_line = line_size * img->frame_count; - uint8_t *merged = malloc(frames_size); + uint8_t *merged = malloc(img_size); assert(merged!=NULL); - bzero(merged, frames_size); + bzero(merged, img_size); for (int y = 0; y < img->height; ++y) { + //int cur_cols = for (uint32_t i = 0; i < img->frame_count; ++i) { memcpy(merged+y*full_line+i*line_size, img->frames[i].rgba+line_size*y, line_size); } @@ -184,9 +187,7 @@ int main(int argc, const char **argv) { AnimatedImage img = {0}; assert(read_webp(argv[i], &img) == 0); printf("dimensions: %dx%d\nframes: %d\n", img.width, img.height, img.frame_count); - - // dump 1st frame to test stuff - write_webp("test01.webp", &img); + write_webp("test01.webp", &img, 6, 2); } }