emote2ss

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

commit 1da27ed72e6a3e526f1a55978e8e8240e8fee607
parent a677ba2b55d3d73f42a1d62b56a7c9d5a9cf5378
Author: bsandro <[email protected]>
Date:   Fri,  5 May 2023 01:45:48 +0300

test generate output webp with 1st frame

Diffstat:
Msrc/main.c | 16++++++++++++++++
1 file changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/main.c b/src/main.c @@ -4,6 +4,7 @@ #include <stdio.h> #include "webp/decode.h" +#include "webp/encode.h" #include "webp/demux.h" #include <stdbool.h> #include <stdlib.h> @@ -147,6 +148,18 @@ int read_webp(const char *fname, AnimatedImage *anim) { return 0; } +void write_webp(const char *fname, AnimatedImage *img) { + FILE *fp = fopen(fname, "wb"); + assert(fp!=NULL); + uint8_t *out; + int stride = img->width * sizeof(uint32_t); + size_t encoded = WebPEncodeLosslessRGBA(img->frames[0].rgba, img->width, img->height, 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); + fclose(fp); +} + int main(int argc, const char **argv) { atexit(print_webp_version); @@ -155,6 +168,9 @@ 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); } }