diff options
| author | Watson Wheeler <git@tazy.dev> | 2026-06-28 20:08:06 +1000 |
|---|---|---|
| committer | Watson Wheeler <git@tazy.dev> | 2026-06-28 20:08:06 +1000 |
| commit | dae2785adc70ddb625780952dbbc085fc1114ca1 (patch) | |
| tree | 78889195090f012cdf603158dd83b238abaa49b1 | |
| parent | 776e8e082d00af3919618e57aac1b89d76a9454f (diff) | |
wip! palette chunk writingstaging/write_palette_chunk
| -rw-r--r-- | include/tinyff/image/png.h | 5 | ||||
| -rw-r--r-- | src/format/image/png.c | 8 |
2 files changed, 10 insertions, 3 deletions
diff --git a/include/tinyff/image/png.h b/include/tinyff/image/png.h index 91ec477..5488d37 100644 --- a/include/tinyff/image/png.h +++ b/include/tinyff/image/png.h @@ -65,9 +65,6 @@ typedef struct { } ff_png_chunk_handler; // Handler declarations -// Massive W.I.P - -// Required by definition ff_result ff_png_header_handler(ff_ctx* ctx, uint8_t *buf, size_t len, ff_png_ctx* png_ctx); // IHDR ff_result ff_png_palette_handler(ff_ctx* ctx, uint8_t *buf, size_t len, ff_png_ctx* png_ctx); // PLTE ff_result ff_png_data_handler(ff_ctx* ctx, uint8_t *buf, size_t len, ff_png_ctx* png_ctx); // IDAT @@ -83,6 +80,8 @@ extern const ff_png_chunk_handler ff_png_chunk_handlers[]; // Encoding helpers ff_result ff_write_chunk(ff_stream *stream, const char *type, uint8_t *buf, size_t len); +// Ancillary chunks encoding helpers +ff_result ff_write_plte_chunk(ff_ctx *ctx, ff_stream *stream, ff_png_ctx *png_ctx); ff_result ff_png_isvalid(ff_ctx* ctx, ff_stream *stream); ff_result ff_open_png(ff_ctx* ctx, ff_stream *stream, ff_png_ctx **out_ctx, ff_flag require_valid); diff --git a/src/format/image/png.c b/src/format/image/png.c index 535c539..94454d6 100644 --- a/src/format/image/png.c +++ b/src/format/image/png.c @@ -528,6 +528,14 @@ ff_result ff_encode_png(ff_ctx *ctx, ff_png_ctx *png_ctx, ff_stream *stream) return FF_RESULT_WARN_NO_IMPL; } +ff_result ff_write_plte_chunk(ff_ctx *ctx, ff_stream *stream, ff_png_ctx *png_ctx) +{ + uint8_t* pltebuf = ctx->allocator.ff_alloc(png_ctx->palette_size * 3) + for (uint8_t entry = 0; entry < png_ctx->palette_size; entry += 4) { + + } +} + ff_result ff_png_normalize(ff_ctx *ctx, ff_png_ctx *png_ctx, ff_image_ctx **out_data, ff_flag consume) { if (png_ctx->bit_depth != 8) return FF_RESULT_WARN_NO_IMPL; |
