diff options
| author | TazyFoundSoup <gardendistrict0x0@outlook.com> | 2026-01-14 14:24:01 +1100 |
|---|---|---|
| committer | TazyFoundSoup <gardendistrict0x0@outlook.com> | 2026-01-14 14:24:01 +1100 |
| commit | 7041bdaeff0456f549ffed48f3c8bc442193b0ce (patch) | |
| tree | e4b790ec0fbb599e23ee0c0a18952d5a039a3fb8 /src/format | |
| parent | fbf406c34adb0a65924f15a1f0e5142e695b36ad (diff) | |
feat(png): Implement chunk handlers for IHDR and IDAT
Diffstat (limited to 'src/format')
| -rw-r--r-- | src/format/image/png.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/format/image/png.c b/src/format/image/png.c index d177819..8662fa2 100644 --- a/src/format/image/png.c +++ b/src/format/image/png.c @@ -55,13 +55,15 @@ ff_result ff_open_png(const char *filepath, ff_png_ctx **out_ctx) return FF_RESULT_OK; } -void ff_png_header_handler(uint8_t *buf, size_t len, ff_png_ctx *ctx) +// Handlers + +ff_result ff_png_header_handler(uint8_t *buf, size_t len, ff_png_ctx *ctx) { ff_dprintf("png: IHDR chunk received (len=%zu)\n", len); if (len != 13) { ff_dprintf("png: invalid IHDR length\n"); - return; + return FF_RESULT_ERROR_INVALID_FILE; } uint32_t w = get_big_endian(buf); @@ -81,4 +83,24 @@ void ff_png_header_handler(uint8_t *buf, size_t len, ff_png_ctx *ctx) ctx->color_type = buf[9]; ff_dprintf("png: IHDR stored in context\n"); + + return FF_RESULT_OK; +} + +ff_result ff_png_data_handler(uint8_t *buf, size_t len, ff_png_ctx *ctx) +{ + ff_dprintf("png: IDAT chunk received (len=%zu)\n", len); + + // For now, compression handling is not implemented + // and instead will assume data is uncompressed + + ff_dprintf("png: IDAT handler WIP - data is assumed uncompressed\n"); + ff_dprintf("png: IDAT handler WIP - expect undefined behavior\n"); + + // We will need to loop over all the scanlines and apply filters + // But im too lazy to do that right now + // TODO implement + + + return FF_RESULT_WARN_NO_IMPL; }
\ No newline at end of file |
