diff options
author | dec05eba <dec05eba@protonmail.com> | 2025-02-22 01:05:29 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2025-02-22 01:05:29 +0100 |
commit | 000da7d64044c4ea2a1679c2864252fee9895d48 (patch) | |
tree | dadeb51a2c1aeab844cbe5eb074a926905eff6d4 /include/image_writer.h | |
parent | fe4cd2bb0e244c568b24ed1c39a19497c41cb2f9 (diff) |
Make image output lossy (use stb image writer), also significantly improves performance for jpeg
Diffstat (limited to 'include/image_writer.h')
-rw-r--r-- | include/image_writer.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/include/image_writer.h b/include/image_writer.h new file mode 100644 index 0000000..79f549e --- /dev/null +++ b/include/image_writer.h @@ -0,0 +1,31 @@ +#ifndef GSR_IMAGE_WRITER_H +#define GSR_IMAGE_WRITER_H + +#include <stdbool.h> + +typedef struct gsr_egl gsr_egl; + +typedef enum { + GSR_IMAGE_FORMAT_JPEG, + GSR_IMAGE_FORMAT_PNG +} gsr_image_format; + +typedef enum { + GSR_IMAGE_WRITER_SOURCE_OPENGL +} gsr_image_writer_source; + +typedef struct { + gsr_image_writer_source source; + gsr_egl *egl; + int width; + int height; + unsigned int texture; +} gsr_image_writer; + +bool gsr_image_writer_init(gsr_image_writer *self, gsr_image_writer_source source, gsr_egl *egl, int width, int height); +void gsr_image_writer_deinit(gsr_image_writer *self); + +/* Quality is between 1 and 100 where 100 is the max quality. Quality doesn't apply to lossless formats */ +bool gsr_image_writer_write_to_file(gsr_image_writer *self, const char *filepath, gsr_image_format image_format, int quality); + +#endif /* GSR_IMAGE_WRITER_H */ |