From 93520564a4aae6a25420f083eb1c7d73372a4ca0 Mon Sep 17 00:00:00 2001 From: TazyFoundSoup Date: Sun, 15 Feb 2026 17:19:12 +1100 Subject: feat(png): Add handler for tRNS ancillary chunk in PNG processing --- include/tinyff/image/png.h | 5 ++++- src/format/image/png.c | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/tinyff/image/png.h b/include/tinyff/image/png.h index 0b0bb3b..3d68fec 100644 --- a/include/tinyff/image/png.h +++ b/include/tinyff/image/png.h @@ -82,6 +82,9 @@ ff_result ff_png_palette_handler(uint8_t *buf, size_t len, ff_png_ctx* ctx); // ff_result ff_png_data_handler(uint8_t *buf, size_t len, ff_png_ctx* ctx); // IDAT ff_result ff_png_end_handler(uint8_t *buf, size_t len, ff_png_ctx* ctx); // IEND +// Ancillary chunks +ff_result ff_png_trans_handler(uint8_t *buf, size_t len, ff_png_ctx* ctx); // tRNS + const ff_png_chunk_handler ff_png_chunk_handlers[] = { {"IHDR", ff_png_header_handler}, @@ -90,7 +93,7 @@ const ff_png_chunk_handler ff_png_chunk_handlers[] = { {"PLTE", ff_png_palette_handler}, // From now on, the handlers will be for ancillary chunks - + {"tRNS", ff_png_trans_handler}, {NULL, NULL} // Terminator }; diff --git a/src/format/image/png.c b/src/format/image/png.c index 162d5ee..d883863 100644 --- a/src/format/image/png.c +++ b/src/format/image/png.c @@ -309,4 +309,9 @@ ff_result ff_png_end_handler(uint8_t *buf, size_t len, ff_png_ctx *ctx) ff_dprintf("png: all chunks received\n"); return FF_RESULT_OK; -} \ No newline at end of file +} + +ff_result ff_png_trans_handler(uint8_t *buf, size_t len, ff_png_ctx *ctx) +{ + ff_dprintf("png: PLTE chunk received (len=%zu)\n", len); +} -- cgit v1.2.3