After upgrade, PNG fails to load

I have recently upgraded my game to the latest version of SDL, and since then a number of PNGs fail to load.

The code is simply:
SDL_RWops *rw = SDL_RWFromFile(libfile[n].name, “rb”);
SDL_Surface *s1 = IMG_LoadPNG_RW(rw);
The PNG is here:

This results in a nullpointer, and SDL_GetError simply tells me it fails to load, but doesn’t say why. Notably, in earlier versions of SDL this did work. Most other PNGs still work fine, but about 10% of them do not. Is there something unusual about this PNG that people can see? Or am I doing something wrong?

FWIW, it does load successfully using SDL_stbimage rather than SDL_image.

I assume you are running on windows.

If I build SDL2_image against the included libpng-1.6.32, showimage
program errors with: “libpng error: IDAT: chunk data is too large”
If I replace libpng-1.6.32 with 1.6.35 (latest official release yet), then
Iet a warning “libpng warning: iCCP: known incorrect sRGB profile”,
but no errors and the image displays Ok.

So, we should update the libpng version included in SDL2_image.
sigh… (94.2 KB) (92.6 KB)

@Radiant: IF you are on windows, try replacing libpng16-16.dll from the correct (x64 or x86)
attachment above and try again.

Yes, it’s windows. Thanks for the quick response, I’ll try this today.

@Radiant: I tried it myself on windows, reproduced your issue and the
replacement png dlls fixed it for me. Waiting for your response to push
to the official repository.

As for the reason for the failures, libpng-1.6.32-to-1.6.33 changelog
mentions the following:

- Compute a larger limit on IDAT because some applications write
  a deflate buffer for each row 

So it is an issue in older libpng-1.6.

I confirm that it works now. Thank you for your help.

You’re welcome. The code repository has the updated libraries now.