[PATCH] windowscodecs: Handle old libpng.so using distros (as SLE 10)

Marcus Meissner marcus at jet.franken.de
Sat Feb 27 16:13:21 CST 2010


Hi,

libpng.so.3 did not have it yet, so check for the function name
too via autoconf.

(We could even link directly ... libpng is common enough?)

Ciao, Marcus
---
 configure.ac                   |   12 ++++++++++++
 dlls/windowscodecs/pngformat.c |   12 ++++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index f7cf4b9..6d4d2b4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1419,6 +1419,12 @@ dnl **** Check for libpng ****
 if test "$ac_cv_header_png_h" = "yes"
 then
     WINE_CHECK_SONAME(png,png_create_read_struct,,,-lm -lz,[[libpng[[0-9]]*]])
+    AC_CHECK_LIB(png,png_set_gray_1_2_4_to_8,
+	[AC_DEFINE(HAVE_PNG_SET_GRAY_1_2_4_TO_8,1,[Define if libpng has the png_set_gray_1_2_4_to_8 functions])]
+	,,-lm -lz)
+    AC_CHECK_LIB(png,png_set_expand_gray_1_2_4_to_8,
+	[AC_DEFINE(HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8,1,[Define if libpng has the png_set_expand_gray_1_2_4_to_8 functions])]
+	,,-lm -lz)
 elif test -n "$X_CFLAGS" -a "x$with_png" != "xno"
 then
     dnl libpng is in the X directory on Mac OS X
@@ -1431,6 +1437,12 @@ then
     then
         AC_SUBST(PNGINCL,"$X_CFLAGS")
         WINE_CHECK_SONAME(png,png_create_read_struct,,,[$X_LIBS -lm -lz],[[libpng[[0-9]]*]])
+        AC_CHECK_LIB(png,png_set_gray_1_2_4_to_8,
+		[AC_DEFINE(HAVE_PNG_SET_GRAY_1_2_4_TO_8,1,[Define if libpng has the png_set_gray_1_2_4_to_8 functions])]
+		,,[$X_LIBS -lm -lz])
+        AC_CHECK_LIB(png,png_set_expand_gray_1_2_4_to_8,
+		[AC_DEFINE(HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8,1,[Define if libpng has the png_set_expand_gray_1_2_4_to_8 functions])]
+		,,[$X_LIBS -lm -lz])
     fi
 fi
 WINE_WARNING_WITH(png,[test "x$ac_cv_lib_soname_png" = "x"],
diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c
index 482ea90..22b37b0 100644
--- a/dlls/windowscodecs/pngformat.c
+++ b/dlls/windowscodecs/pngformat.c
@@ -60,7 +60,11 @@ MAKE_FUNCPTR(png_get_PLTE);
 MAKE_FUNCPTR(png_get_tRNS);
 MAKE_FUNCPTR(png_set_bgr);
 MAKE_FUNCPTR(png_set_error_fn);
+#if HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8
 MAKE_FUNCPTR(png_set_expand_gray_1_2_4_to_8);
+#else
+MAKE_FUNCPTR(png_set_gray_1_2_4_to_8);
+#endif
 MAKE_FUNCPTR(png_set_filler);
 MAKE_FUNCPTR(png_set_gray_to_rgb);
 MAKE_FUNCPTR(png_set_IHDR);
@@ -103,7 +107,11 @@ static void *load_libpng(void)
         LOAD_FUNCPTR(png_get_tRNS);
         LOAD_FUNCPTR(png_set_bgr);
         LOAD_FUNCPTR(png_set_error_fn);
+#if HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8
         LOAD_FUNCPTR(png_set_expand_gray_1_2_4_to_8);
+#else
+        LOAD_FUNCPTR(png_set_gray_1_2_4_to_8);
+#endif
         LOAD_FUNCPTR(png_set_filler);
         LOAD_FUNCPTR(png_set_gray_to_rgb);
         LOAD_FUNCPTR(png_set_IHDR);
@@ -306,7 +314,11 @@ static HRESULT WINAPI PngDecoder_Initialize(IWICBitmapDecoder *iface, IStream *p
         {
             if (bit_depth < 8)
             {
+#if HAVE_PNG_SET_EXPAND_GRAY_1_2_4_TO_8
                 ppng_set_expand_gray_1_2_4_to_8(This->png_ptr);
+#else
+                ppng_set_gray_1_2_4_to_8(This->png_ptr);
+#endif
                 bit_depth = 8;
             }
             ppng_set_gray_to_rgb(This->png_ptr);
-- 
1.5.6



More information about the wine-patches mailing list