Move png_set_swap later in PNG write or it is ignored (fixes 16bpc PNGs)
diff --git a/apps/shared/avifpng.c b/apps/shared/avifpng.c index 87dab49..933d0e4 100644 --- a/apps/shared/avifpng.c +++ b/apps/shared/avifpng.c
@@ -177,10 +177,6 @@ } } - if (rgbDepth > 8) { - png_set_swap(png); - } - png_set_IHDR( png, info, avif->width, avif->height, rgbDepth, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); if (avif->profileFormat == AVIF_PROFILE_FORMAT_ICC) { @@ -197,6 +193,10 @@ rowPointers[y] = &rgb.pixels[y * rgb.rowBytes]; } + if (rgbDepth > 8) { + png_set_swap(png); + } + png_write_image(png, rowPointers); png_write_end(png, NULL);