From 0e9034b86f554ed85457af216990a68665d3e24d Mon Sep 17 00:00:00 2001 From: David Korth Date: Mon, 14 Jun 2021 21:44:40 -0400 Subject: [PATCH] [doc] md-plte-adjust.c: APNGs have an acTL chunk before PLTE. FIXME: The first palette entry in APNGs appears to be unused and has low bits set... --- doc/md-plte-adjust.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/md-plte-adjust.c b/doc/md-plte-adjust.c index 913d48508..a692fd5c7 100644 --- a/doc/md-plte-adjust.c +++ b/doc/md-plte-adjust.c @@ -154,6 +154,13 @@ int main(int argc, char *argv[]) // Read the PLTE header. (Must be the first chunk after IHDR.) size = fread(&buf.plte, 1, sizeof(buf.plte), f_png); + if (size == sizeof(buf.plte) && !memcmp(buf.plte.magic, "acTL", 4)) { + // acTL. This is an APNG. + // PLTE should be immediately after it. + // FIXME: First color seems to be unused and has low bits set... + fseek(f_png, 8+4, SEEK_CUR); + size = fread(&buf.plte, 1, sizeof(buf.plte), f_png); + } if (size != sizeof(buf.plte) || memcmp(buf.plte.magic, "PLTE", 4) != 0) { fclose(f_png); fprintf(stderr, "*** ERROR reading PNG file '%s': PLTE chunk is invalid or missing.\n",