Commit f7d7c238 authored by Manish Singh's avatar Manish Singh Committed by Manish Singh

don't use long deprecated libpng API, and drop support for ancient libpng

2006-04-23  Manish Singh  <yosh@gimp.org>

        * plug-ins/common/png.c: don't use long deprecated libpng API, and
        drop support for ancient libpng versions. Fixes bug #339402.

        * configure.in: use pkg-config to detect libpng. This means we now
        require at least libpng 1.2.2, but that's over four years old, so
        that shouldn't be that big a deal.
parent 9508618a
2006-04-23 Manish Singh <yosh@gimp.org>
* plug-ins/common/png.c: don't use long deprecated libpng API, and
drop support for ancient libpng versions. Fixes bug #339402.
* configure.in: use pkg-config to detect libpng. This means we now
require at least libpng 1.2.2, but that's over four years old, so
that shouldn't be that big a deal.
2006-04-23 Sven Neumann <sven@gimp.org>
* app/widgets/gimpviewabledialog.c: added "viewable" as a property.
......
......@@ -1031,35 +1031,16 @@ AC_SUBST(PSP)
have_libpng=no
AC_ARG_WITH(libpng, [ --without-libpng build without PNG support])
if test x$with_libpng != xno; then
have_libpng=yes
if test x$with_libpng != xno && test -z "$LIBPNG" && test -n "$LIBZ"; then
AC_CHECK_LIB(png, png_read_info,
[AC_CHECK_HEADER(png.h,
png_ok=yes,
png_ok=no)],
[have_libpng="no (PNG library not found)"], -lz -lm)
if test "$png_ok" = yes; then
AC_MSG_CHECKING([for png_structp in png.h])
AC_TRY_COMPILE([#include <png.h>],
[png_structp pp; png_infop info; png_colorp cmap; png_create_read_struct;],
png_ok=yes,
png_ok=no)
AC_MSG_RESULT($png_ok)
if test "$png_ok" = yes; then
PNG='png$(EXEEXT)'; LIBPNG="-lpng $LIBZ"
else
have_libpng="no (PNG library is too old)"
fi
else
have_libpng="no (PNG header file not found)"
fi
fi
if test x$with_libpng != xno && test -z "$LIBPNG"; then
PKG_CHECK_MODULES(PNG, libpng,
PNG='png$(EXEEXT)'
LIBPNG="$PNG_LIBS",
[have_libpng="no (libpng not found)"
AC_MSG_ERROR([
*** Checks for PNG library failed. You can build without it by passing
*** --without-libpng to configure but you won't be able to use PNGs then.])
fi
*** Checks for PNG library failed. You can build without it by passing
*** --without-libpng to configure but you won't be able to use PNGs then.])])
fi
AC_SUBST(PNG)
AC_SUBST(LIBPNG)
......
......@@ -683,20 +683,8 @@ load_image (const gchar *filename,
png_textp text;
gint num_texts;
/*
* PNG 0.89 and newer have a sane, forwards compatible constructor.
* Some SGI IRIX users will not have a new enough version though
*/
#if PNG_LIBPNG_VER > 88
pp = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
info = png_create_info_struct (pp);
#else
pp = (png_structp) calloc (sizeof (png_struct), 1);
png_read_init (pp);
info = (png_infop) calloc (sizeof (png_info), 1);
#endif /* PNG_LIBPNG_VER > 88 */
if (setjmp (pp->jmpbuf))
{
......@@ -773,7 +761,6 @@ load_image (const gchar *filename,
* Special handling for INDEXED + tRNS (transparency palette)
*/
#if PNG_LIBPNG_VER > 99
if (png_get_valid (pp, info, PNG_INFO_tRNS) &&
info->color_type == PNG_COLOR_TYPE_PALETTE)
{
......@@ -790,9 +777,6 @@ load_image (const gchar *filename,
{
trns = 0;
}
#else
trns = 0;
#endif /* PNG_LIBPNG_VER > 99 */
/*
* Update the info structures after the transformations take effect
......@@ -859,7 +843,6 @@ load_image (const gchar *filename,
* due to a bug in libpng-1.0.6, see png-implement for details
*/
#if PNG_LIBPNG_VER > 99
if (png_get_valid (pp, info, PNG_INFO_gAMA))
{
GimpParasite *parasite;
......@@ -929,7 +912,6 @@ load_image (const gchar *filename,
}
}
#endif /* PNG_LIBPNG_VER > 99 */
gimp_image_set_filename (image, filename);
......@@ -942,7 +924,6 @@ load_image (const gchar *filename,
if (info->color_type & PNG_COLOR_MASK_PALETTE)
{
#if PNG_LIBPNG_VER > 99
if (png_get_valid (pp, info, PNG_INFO_tRNS))
{
for (empty = 0; empty < 256 && alpha[empty] == 0; ++empty)
......@@ -959,11 +940,6 @@ load_image (const gchar *filename,
gimp_image_set_colormap (image, (guchar *) info->palette,
info->num_palette);
}
#else
gimp_image_set_colormap (image, (guchar *) info->palette,
info->num_palette);
#endif /* PNG_LIBPNG_VER > 99 */
}
/*
......@@ -1095,7 +1071,7 @@ load_image (const gchar *filename,
* Done with the file...
*/
png_read_destroy (pp, info, NULL);
png_destroy_read_struct (&pp, &info, NULL);
g_free (pixel);
g_free (pixels);
......@@ -1225,20 +1201,8 @@ save_image (const gchar *filename,
}
}
/*
* PNG 0.89 and newer have a sane, forwards compatible constructor.
* Some SGI IRIX users will not have a new enough version though
*/
#if PNG_LIBPNG_VER > 88
pp = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
info = png_create_info_struct (pp);
#else
pp = (png_structp) calloc (sizeof (png_struct), 1);
png_write_init (pp);
info = (png_infop) calloc (sizeof (png_info), 1);
#endif /* PNG_LIBPNG_VER > 88 */
if (setjmp (pp->jmpbuf))
{
......@@ -1356,7 +1320,6 @@ save_image (const gchar *filename,
/* All this stuff is optional extras, if the user is aiming for smallest
possible file size she can turn them all off */
#if PNG_LIBPNG_VER > 99
if (pngvals.bkgd)
{
GimpRGB color;
......@@ -1422,8 +1385,6 @@ save_image (const gchar *filename,
png_set_tIME (pp, info, &mod_time);
}
#endif /* PNG_LIBPNG_VER > 99 */
#if defined(PNG_iCCP_SUPPORTED)
{
GimpParasite *profile_parasite;
......@@ -1553,7 +1514,7 @@ save_image (const gchar *filename,
}
png_write_end (pp, info);
png_write_destroy (pp);
png_destroy_write_struct (&pp, &info);
g_free (pixel);
g_free (pixels);
......@@ -1618,8 +1579,6 @@ respin_cmap (png_structp pp,
colors = 1;
}
#if PNG_LIBPNG_VER > 99
cols = drawable->width;
rows = drawable->height;
numpixels = cols * rows;
......@@ -1684,12 +1643,6 @@ respin_cmap (png_structp pp,
}
g_free (pixels);
#else
info->valid |= PNG_INFO_PLTE;
info->palette = (png_colorp) before;
info->num_palette = colors;
#endif /* PNG_LIBPNG_VER > 99 */
}
static gboolean
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment