diff options
| author | TazyFoundSoup <gardendistrict0x0@outlook.com> | 2025-12-19 18:19:57 +1100 |
|---|---|---|
| committer | TazyFoundSoup <gardendistrict0x0@outlook.com> | 2025-12-19 18:19:57 +1100 |
| commit | 896ec637777e5a657d8180c51c5e574b469b7eed (patch) | |
| tree | ce43d6480c7dfd6b97fe7fb15bc88afb11da4e49 /src | |
| parent | 53af2b5bcab39fb481379121c8c55da8b01d0db3 (diff) | |
fix(png): map chunk type raw value to enum in ff_next_chunk function
Diffstat (limited to 'src')
| -rw-r--r-- | src/format/image/png.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/format/image/png.c b/src/format/image/png.c index 1da687f..9c7664f 100644 --- a/src/format/image/png.c +++ b/src/format/image/png.c @@ -55,8 +55,15 @@ ff_result ff_next_chunk(FILE *file, ff_png_chunk **out_chunk) { } // Get the big endian value of the type buffer - // It needs to be mapped to the enum though - uint32_t chunk_type = get_big_endian(type_buffer); + uint32_t chunk_type_raw = get_big_endian(type_buffer); + + ff_png_chunk_type chunk_type; + + if (memcmp(chunk_type_raw, "IHDR", 4)) chunk_type = FF_PNG_CHUNK_TYPE_IHDR; + else if (memcmp(chunk_type_raw, "IDAT", 4)) chunk_type = FF_PNG_CHUNK_TYPE_IDAT; + else if (memcmp(chunk_type_raw, "IEND", 4)) chunk_type = FF_PNG_CHUNK_TYPE_IEND; + else if (memcmp(chunk_type_raw, "PLTE", 4)) chunk_type = FF_PNG_CHUNK_TYPE_PLTE; + else chunk_type = FF_PNG_CHUNK_TYPE_UNKNOWN; // 3. Read data (data_chunk_length bytes) uint32_t *data_buffer = (uint32_t *)malloc(data_chunk_length * sizeof(ff_byte)); |
