summaryrefslogtreecommitdiff
path: root/src/format/image/png.c
diff options
context:
space:
mode:
authorWatson Wheeler <git@tazy.dev>2026-06-28 12:50:28 +1000
committerWatson Wheeler <git@tazy.dev>2026-07-02 19:38:13 +1000
commitfbededceb274a0578a4b13d6e8373ab79665d79b (patch)
treec5deb9d824575959f82043929c3385c180e77f02 /src/format/image/png.c
parent1a05bd20de2a252a892d2c2bbfe45cf584a0e370 (diff)
fix(png): fix png chunk writer's writing order
It now prints it in the way the spec intends (length, type, data, crc) Signed-off-by: Watson Wheeler <git@tazy.dev>
Diffstat (limited to 'src/format/image/png.c')
-rw-r--r--src/format/image/png.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/format/image/png.c b/src/format/image/png.c
index 781c462..dba6b70 100644
--- a/src/format/image/png.c
+++ b/src/format/image/png.c
@@ -477,11 +477,11 @@ ff_result ff_close_png(ff_ctx* ctx, ff_png_ctx *png_ctx)
ff_result ff_write_chunk(ff_stream *stream, const char *type, uint8_t *buf, size_t len)
{
- stream->write(type, 4, stream->user);
-
- uint32_t be_len = (uint32_t)len;
- stream->write(&be_len, 4, stream->user);
+ uint8_t be_len[4];
+ ff_write_be32(be_len, (uint32_t)len);
+ stream->write(be_len, 4, stream->user);
+ stream->write(type, 4, stream->user);
stream->write(buf, len, stream->user);
uint32_t zero_crc = 0;