comparison src/image.c @ 106975:62f86ca36527

Use png_sig_cmp to allow linking with libpng 1.4.0. * image.c (png_load): Use png_sig_cmp instead of the obsolete png_check_sig, which has been removed in libpng 1.4.
author Chong Yidong <cyd@stupidchicken.com>
date Sun, 24 Jan 2010 18:03:13 -0500
parents 1d1d5d9bd884
children 9c0ed2d6731a f969130f2bb4
comparison
equal deleted inserted replaced
106974:1c559638a806 106975:62f86ca36527
31 #if defined HAVE_LIBPNG_PNG_H 31 #if defined HAVE_LIBPNG_PNG_H
32 # include <libpng/png.h> 32 # include <libpng/png.h>
33 #else 33 #else
34 # include <png.h> 34 # include <png.h>
35 #endif 35 #endif
36 #endif 36 #endif
37 37
38 #include <setjmp.h> 38 #include <setjmp.h>
39 39
40 /* This makes the fields of a Display accessible, in Xlib header files. */ 40 /* This makes the fields of a Display accessible, in Xlib header files. */
41 41
3049 { 3049 {
3050 char *invertedBits; 3050 char *invertedBits;
3051 int nbytes, i; 3051 int nbytes, i;
3052 /* Windows mono bitmaps are reversed compared with X. */ 3052 /* Windows mono bitmaps are reversed compared with X. */
3053 invertedBits = bits; 3053 invertedBits = bits;
3054 nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR 3054 nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR
3055 * img->height; 3055 * img->height;
3056 bits = (char *) alloca(nbytes); 3056 bits = (char *) alloca(nbytes);
3057 for (i = 0; i < nbytes; i++) 3057 for (i = 0; i < nbytes; i++)
3058 bits[i] = XBM_BIT_SHUFFLE (invertedBits[i]); 3058 bits[i] = XBM_BIT_SHUFFLE (invertedBits[i]);
3059 } 3059 }
5557 5557
5558 #ifdef HAVE_NTGUI 5558 #ifdef HAVE_NTGUI
5559 /* PNG library details. */ 5559 /* PNG library details. */
5560 5560
5561 DEF_IMGLIB_FN (png_get_io_ptr); 5561 DEF_IMGLIB_FN (png_get_io_ptr);
5562 DEF_IMGLIB_FN (png_check_sig); 5562 DEF_IMGLIB_FN (png_sig_cmp);
5563 DEF_IMGLIB_FN (png_create_read_struct); 5563 DEF_IMGLIB_FN (png_create_read_struct);
5564 DEF_IMGLIB_FN (png_create_info_struct); 5564 DEF_IMGLIB_FN (png_create_info_struct);
5565 DEF_IMGLIB_FN (png_destroy_read_struct); 5565 DEF_IMGLIB_FN (png_destroy_read_struct);
5566 DEF_IMGLIB_FN (png_set_read_fn); 5566 DEF_IMGLIB_FN (png_set_read_fn);
5567 DEF_IMGLIB_FN (png_set_sig_bytes); 5567 DEF_IMGLIB_FN (png_set_sig_bytes);
5588 /* Try loading libpng under probable names. */ 5588 /* Try loading libpng under probable names. */
5589 if (!(library = w32_delayed_load (libraries, Qpng))) 5589 if (!(library = w32_delayed_load (libraries, Qpng)))
5590 return 0; 5590 return 0;
5591 5591
5592 LOAD_IMGLIB_FN (library, png_get_io_ptr); 5592 LOAD_IMGLIB_FN (library, png_get_io_ptr);
5593 LOAD_IMGLIB_FN (library, png_check_sig); 5593 LOAD_IMGLIB_FN (library, png_sig_cmp);
5594 LOAD_IMGLIB_FN (library, png_create_read_struct); 5594 LOAD_IMGLIB_FN (library, png_create_read_struct);
5595 LOAD_IMGLIB_FN (library, png_create_info_struct); 5595 LOAD_IMGLIB_FN (library, png_create_info_struct);
5596 LOAD_IMGLIB_FN (library, png_destroy_read_struct); 5596 LOAD_IMGLIB_FN (library, png_destroy_read_struct);
5597 LOAD_IMGLIB_FN (library, png_set_read_fn); 5597 LOAD_IMGLIB_FN (library, png_set_read_fn);
5598 LOAD_IMGLIB_FN (library, png_set_sig_bytes); 5598 LOAD_IMGLIB_FN (library, png_set_sig_bytes);
5613 return 1; 5613 return 1;
5614 } 5614 }
5615 #else 5615 #else
5616 5616
5617 #define fn_png_get_io_ptr png_get_io_ptr 5617 #define fn_png_get_io_ptr png_get_io_ptr
5618 #define fn_png_check_sig png_check_sig 5618 #define fn_png_sig_cmp png_sig_cmp
5619 #define fn_png_create_read_struct png_create_read_struct 5619 #define fn_png_create_read_struct png_create_read_struct
5620 #define fn_png_create_info_struct png_create_info_struct 5620 #define fn_png_create_info_struct png_create_info_struct
5621 #define fn_png_destroy_read_struct png_destroy_read_struct 5621 #define fn_png_destroy_read_struct png_destroy_read_struct
5622 #define fn_png_set_read_fn png_set_read_fn 5622 #define fn_png_set_read_fn png_set_read_fn
5623 #define fn_png_set_sig_bytes png_set_sig_bytes 5623 #define fn_png_set_sig_bytes png_set_sig_bytes
5760 return 0; 5760 return 0;
5761 } 5761 }
5762 5762
5763 /* Check PNG signature. */ 5763 /* Check PNG signature. */
5764 if (fread (sig, 1, sizeof sig, fp) != sizeof sig 5764 if (fread (sig, 1, sizeof sig, fp) != sizeof sig
5765 || !fn_png_check_sig (sig, sizeof sig)) 5765 || fn_png_sig_cmp (sig, 0, sizeof sig))
5766 { 5766 {
5767 image_error ("Not a PNG file: `%s'", file, Qnil); 5767 image_error ("Not a PNG file: `%s'", file, Qnil);
5768 UNGCPRO; 5768 UNGCPRO;
5769 fclose (fp); 5769 fclose (fp);
5770 return 0; 5770 return 0;
5777 tbr.len = SBYTES (specified_data); 5777 tbr.len = SBYTES (specified_data);
5778 tbr.index = 0; 5778 tbr.index = 0;
5779 5779
5780 /* Check PNG signature. */ 5780 /* Check PNG signature. */
5781 if (tbr.len < sizeof sig 5781 if (tbr.len < sizeof sig
5782 || !fn_png_check_sig (tbr.bytes, sizeof sig)) 5782 || fn_png_sig_cmp (tbr.bytes, 0, sizeof sig))
5783 { 5783 {
5784 image_error ("Not a PNG image: `%s'", img->spec, Qnil); 5784 image_error ("Not a PNG image: `%s'", img->spec, Qnil);
5785 UNGCPRO; 5785 UNGCPRO;
5786 return 0; 5786 return 0;
5787 } 5787 }