Fix tilegen compilation under mingw32

Order of linking the SDL libs and some missing Windows libraries.
Remove the SDL dependency from the rltiles tool.

Since the tool only needs to load PNG images, it doesn't really need
SDL; we can instead directly call libpng. This should make
cross-compilation easier and even reduces the code size a bit, since
libpng can do the palette expansion for us.
Handle a return value and introduce a constant.
Close the file in the libpng error handler.
Use the most recent libpng signature check for tilegen

The png_check_sig() function is obsoleted for png_sig_cmp in recent
libpng.