diff -r 4775357cca4c IMG_png.c --- a/IMG_png.c Tue Sep 12 01:10:25 2017 -0700 +++ b/IMG_png.c Wed Sep 13 10:31:40 2017 +0200 @@ -101,6 +101,7 @@ void (*png_set_packing) (png_structp png_ptr); void (*png_set_read_fn) (png_structp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn); void (*png_set_strip_16) (png_structp png_ptr); + int (*png_set_interlace_handling) (png_structp png_ptr); int (*png_sig_cmp) (png_const_bytep sig, png_size_t start, png_size_t num_to_check); #ifndef LIBPNG_VERSION_12 jmp_buf* (*png_set_longjmp_fn) (png_structp, png_longjmp_ptr, size_t); @@ -242,6 +243,13 @@ SDL_UnloadObject(lib.handle); return -1; } + lib.png_set_interlace_handling = + (void (*) (png_structp)) + SDL_LoadFunction(lib.handle, "png_set_interlace_handling"); + if ( lib.png_set_interlace_handling == NULL ) { + SDL_UnloadObject(lib.handle); + return -1; + } lib.png_sig_cmp = (int (*) (png_const_bytep, png_size_t, png_size_t)) SDL_LoadFunction(lib.handle, "png_sig_cmp"); @@ -350,6 +358,7 @@ lib.png_set_packing = png_set_packing; lib.png_set_read_fn = png_set_read_fn; lib.png_set_strip_16 = png_set_strip_16; + lib.png_set_interlace_handling = png_set_interlace_handling; lib.png_sig_cmp = png_sig_cmp; #ifndef LIBPNG_VERSION_12 lib.png_set_longjmp_fn = png_set_longjmp_fn; @@ -484,6 +493,9 @@ /* tell libpng to strip 16 bit/color files down to 8 bits/color */ lib.png_set_strip_16(png_ptr) ; + /* tell libpng to de-interlace (if the image is interlaced) */ + lib.png_set_interlace_handling(png_ptr) ; + /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single * byte into separate bytes (useful for paletted and grayscale images). */