]> code.delx.au - gnu-emacs/blobdiff - src/image.c
Merge changes from emacs-23 branch
[gnu-emacs] / src / image.c
index 07f573ca893aab1a6ce891629bd6894746c7fcac..41c9cb8f5348e1d1e80dc2abe40ad6eb39ed6cf6 100644 (file)
@@ -94,6 +94,11 @@ typedef struct w32_bitmap_record Bitmap_Record;
    without modifying lots of files).  */
 extern void x_query_colors (struct frame *f, XColor *colors, int ncolors);
 extern void x_query_color (struct frame *f, XColor *color);
+
+/* Version of libpng that we were compiled with, or -1 if no PNG
+   support was compiled in.  This is tested by w32-win.el to correctly
+   set up the alist used to search for PNG libraries.  */
+Lisp_Object Qlibpng_version;
 #endif /* HAVE_NTGUI */
 
 #ifdef HAVE_NS
@@ -5523,6 +5528,12 @@ init_png_functions (Lisp_Object libraries)
 
 #endif /* HAVE_NTGUI */
 
+/* libpng before 1.4.0 didn't have png_jmpbuf; v1.4.0 and later
+   deprecate direct access to png_ptr fields.  */
+#ifndef png_jmpbuf
+# define png_jmpbuf(PTR)  ((PTR)->jmpbuf)
+#endif
+
 /* Error and warning handlers installed when the PNG library
    is initialized.  */
 
@@ -5530,8 +5541,10 @@ static void
 my_png_error (png_struct *png_ptr, const char *msg)
 {
   xassert (png_ptr != NULL);
+  /* Avoid compiler warning about deprecated direct access to
+     png_ptr's fields in libpng versions 1.4.x.  */
   image_error ("PNG error: %s", build_string (msg), Qnil);
-  longjmp (png_ptr->jmpbuf, 1);
+  longjmp (png_jmpbuf (png_ptr), 1);
 }
 
 
@@ -5693,7 +5706,7 @@ png_load (struct frame *f, struct image *img)
 
   /* Set error jump-back.  We come back here when the PNG library
      detects an error.  */
-  if (setjmp (png_ptr->jmpbuf))
+  if (setjmp (png_jmpbuf (png_ptr)))
     {
     error:
       if (png_ptr)
@@ -8776,6 +8789,16 @@ non-numeric, there is no explicit limit on the size of images.  */);
   staticpro (&QCpt_height);
 #endif /* HAVE_GHOSTSCRIPT */
 
+#ifdef HAVE_NTGUI
+  Qlibpng_version = intern_c_string ("libpng-version");
+  staticpro (&Qlibpng_version);
+#if HAVE_PNG
+  SET_SYMBOL_VAL (XSYMBOL (Qlibpng_version), make_number (PNG_LIBPNG_VER));
+#else
+  SET_SYMBOL_VAL (XSYMBOL (Qlibpng_version), make_number (-1));
+#endif
+#endif
+
 #if defined (HAVE_XPM) || defined (HAVE_NS)
   Qxpm = intern_c_string ("xpm");
   staticpro (&Qxpm);