From 686ad262141126d5cd40fd71f368eab1bbec14aa Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Thu, 12 May 2022 20:05:10 +0300
Subject: [PATCH] Don't link miniz if we have a hard dependency on libpng.
c.f.: https://github.com/libsdl-org/SDL_image/pull/232 .
---
IMG_png.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/IMG_png.c b/IMG_png.c
index d93ec66..462fe2f 100644
--- a/IMG_png.c
+++ b/IMG_png.c
@@ -679,6 +679,7 @@ static int IMG_SavePNG_RW_libpng(SDL_Surface *surface, SDL_RWops *dst, int freed
#endif /* USE_LIBPNG */
+#if defined(LOAD_PNG_DYNAMIC) || !defined(WANT_LIBPNG)
/* Replace C runtime functions with SDL C runtime functions for building on Windows */
#define MINIZ_NO_STDIO
#define MINIZ_NO_TIME
@@ -729,6 +730,7 @@ static int IMG_SavePNG_RW_miniz(SDL_Surface *surface, SDL_RWops *dst, int freeds
}
return result;
}
+#endif /* LOAD_PNG_DYNAMIC || !WANT_LIBPNG */
#endif /* SAVE_PNG */
@@ -752,7 +754,11 @@ int IMG_SavePNG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst)
}
}
#endif
+#if defined(LOAD_PNG_DYNAMIC) || !defined(WANT_LIBPNG)
return IMG_SavePNG_RW_miniz(surface, dst, freedst);
+#else
+ return -1;
+#endif
#else
return IMG_SetError("SDL_image built without PNG save support");