diff options
| author | Garden <gardendistrict0x0@outlook.com> | 2025-12-18 21:14:42 +1100 |
|---|---|---|
| committer | Garden <gardendistrict0x0@outlook.com> | 2025-12-18 21:14:42 +1100 |
| commit | a65f99a64e1937411a9268213c55f1b030df7af5 (patch) | |
| tree | 2f20a154cb9b564a0646cc5fa56bbc8e80cc6f2a /include/tinyff/image | |
| parent | d43248b74af0bece228e9b80251cd3512e878ca9 (diff) | |
feat(png): Validate signiture header
Diffstat (limited to 'include/tinyff/image')
| -rw-r--r-- | include/tinyff/image/png.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/include/tinyff/image/png.h b/include/tinyff/image/png.h new file mode 100644 index 0000000..caed675 --- /dev/null +++ b/include/tinyff/image/png.h @@ -0,0 +1,29 @@ +#ifndef PNG_H +#define PNG_H + +#include <stdint.h> +#include <stdio.h> +#include <stdbool.h> +#include <string.h> + +#include "tinyff/result.h" + +static const unsigned char PNG_SIGNATURE[8] = { + 0x89, 'P', 'N', 'G', 0x0D, 0x0A, 0x1A, 0x0A +}; + +typedef struct { + FILE *raw; + uint32_t width; + uint32_t height; + uint8_t bit_depth; + uint8_t color_type; + uint8_t *pixels; + size_t count_pixels; + bool valid; +} ff_png_ctx; + +ff_result ff_png_isvalid(FILE *file); +ff_png_ctx *ff_open_png(const char *filepath); + +#endif |
