legacy: support up to libpng 1.6.3

This has been tested on aosp libpng 1.2.46, current libpng 1.4,
and libpng 1.6.3