aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c932
1 files changed, 489 insertions, 443 deletions
diff --git a/src/image.c b/src/image.c
index a73a7251753..4cba8863b88 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1859,19 +1859,6 @@ mark_image_cache (struct image_cache *c)
1859 X / NS / W32 support code 1859 X / NS / W32 support code
1860 ***********************************************************************/ 1860 ***********************************************************************/
1861 1861
1862#ifdef WINDOWSNT
1863
1864/* Macro for defining functions that will be loaded from image DLLs. */
1865#define DEF_IMGLIB_FN(rettype,func,args) static rettype (FAR CDECL *fn_##func)args
1866
1867/* Macro for loading those image functions from the library. */
1868#define LOAD_IMGLIB_FN(lib,func) { \
1869 fn_##func = (void *) GetProcAddress (lib, #func); \
1870 if (!fn_##func) return 0; \
1871 }
1872
1873#endif /* WINDOWSNT */
1874
1875/* Return true if XIMG's size WIDTH x HEIGHT doesn't break the 1862/* Return true if XIMG's size WIDTH x HEIGHT doesn't break the
1876 windowing system. 1863 windowing system.
1877 WIDTH and HEIGHT must both be positive. 1864 WIDTH and HEIGHT must both be positive.
@@ -3377,12 +3364,14 @@ xpm_free_colors (Display *dpy, Colormap cmap, Pixel *pixels, int npixels, void *
3377 3364
3378/* XPM library details. */ 3365/* XPM library details. */
3379 3366
3380DEF_IMGLIB_FN (void, XpmFreeAttributes, (XpmAttributes *)); 3367DEF_DLL_FN (void, XpmFreeAttributes, (XpmAttributes *));
3381DEF_IMGLIB_FN (int, XpmCreateImageFromBuffer, (Display *, char *, xpm_XImage **, 3368DEF_DLL_FN (int, XpmCreateImageFromBuffer,
3382 xpm_XImage **, XpmAttributes *)); 3369 (Display *, char *, xpm_XImage **,
3383DEF_IMGLIB_FN (int, XpmReadFileToImage, (Display *, char *, xpm_XImage **, 3370 xpm_XImage **, XpmAttributes *));
3384 xpm_XImage **, XpmAttributes *)); 3371DEF_DLL_FN (int, XpmReadFileToImage,
3385DEF_IMGLIB_FN (void, XImageFree, (xpm_XImage *)); 3372 (Display *, char *, xpm_XImage **,
3373 xpm_XImage **, XpmAttributes *));
3374DEF_DLL_FN (void, XImageFree, (xpm_XImage *));
3386 3375
3387static bool 3376static bool
3388init_xpm_functions (void) 3377init_xpm_functions (void)
@@ -3392,22 +3381,24 @@ init_xpm_functions (void)
3392 if (!(library = w32_delayed_load (Qxpm))) 3381 if (!(library = w32_delayed_load (Qxpm)))
3393 return 0; 3382 return 0;
3394 3383
3395 LOAD_IMGLIB_FN (library, XpmFreeAttributes); 3384 LOAD_DLL_FN (library, XpmFreeAttributes);
3396 LOAD_IMGLIB_FN (library, XpmCreateImageFromBuffer); 3385 LOAD_DLL_FN (library, XpmCreateImageFromBuffer);
3397 LOAD_IMGLIB_FN (library, XpmReadFileToImage); 3386 LOAD_DLL_FN (library, XpmReadFileToImage);
3398 LOAD_IMGLIB_FN (library, XImageFree); 3387 LOAD_DLL_FN (library, XImageFree);
3399 return 1; 3388 return 1;
3400} 3389}
3401 3390
3402#endif /* WINDOWSNT */ 3391# undef XImageFree
3392# undef XpmCreateImageFromBuffer
3393# undef XpmFreeAttributes
3394# undef XpmReadFileToImage
3403 3395
3404#if defined HAVE_NTGUI && !defined WINDOWSNT 3396# define XImageFree fn_XImageFree
3405/* Glue for code below */ 3397# define XpmCreateImageFromBuffer fn_XpmCreateImageFromBuffer
3406#define fn_XpmReadFileToImage XpmReadFileToImage 3398# define XpmFreeAttributes fn_XpmFreeAttributes
3407#define fn_XpmCreateImageFromBuffer XpmCreateImageFromBuffer 3399# define XpmReadFileToImage fn_XpmReadFileToImage
3408#define fn_XImageFree XImageFree 3400
3409#define fn_XpmFreeAttributes XpmFreeAttributes 3401#endif /* WINDOWSNT */
3410#endif /* HAVE_NTGUI && !WINDOWSNT */
3411 3402
3412/* Value is true if COLOR_SYMBOLS is a valid color symbols list 3403/* Value is true if COLOR_SYMBOLS is a valid color symbols list
3413 for XPM images. Such a list must consist of conses whose car and 3404 for XPM images. Such a list must consist of conses whose car and
@@ -3624,9 +3615,9 @@ xpm_load (struct frame *f, struct image *img)
3624#endif 3615#endif
3625 /* XpmReadFileToPixmap is not available in the Windows port of 3616 /* XpmReadFileToPixmap is not available in the Windows port of
3626 libxpm. But XpmReadFileToImage almost does what we want. */ 3617 libxpm. But XpmReadFileToImage almost does what we want. */
3627 rc = fn_XpmReadFileToImage (&hdc, SDATA (file), 3618 rc = XpmReadFileToImage (&hdc, SDATA (file),
3628 &xpm_image, &xpm_mask, 3619 &xpm_image, &xpm_mask,
3629 &attrs); 3620 &attrs);
3630#else 3621#else
3631 rc = XpmReadFileToImage (FRAME_X_DISPLAY (f), SSDATA (file), 3622 rc = XpmReadFileToImage (FRAME_X_DISPLAY (f), SSDATA (file),
3632 &img->ximg, &img->mask_img, 3623 &img->ximg, &img->mask_img,
@@ -3648,9 +3639,9 @@ xpm_load (struct frame *f, struct image *img)
3648#ifdef HAVE_NTGUI 3639#ifdef HAVE_NTGUI
3649 /* XpmCreatePixmapFromBuffer is not available in the Windows port 3640 /* XpmCreatePixmapFromBuffer is not available in the Windows port
3650 of libxpm. But XpmCreateImageFromBuffer almost does what we want. */ 3641 of libxpm. But XpmCreateImageFromBuffer almost does what we want. */
3651 rc = fn_XpmCreateImageFromBuffer (&hdc, SDATA (buffer), 3642 rc = XpmCreateImageFromBuffer (&hdc, SDATA (buffer),
3652 &xpm_image, &xpm_mask, 3643 &xpm_image, &xpm_mask,
3653 &attrs); 3644 &attrs);
3654#else 3645#else
3655 rc = XpmCreateImageFromBuffer (FRAME_X_DISPLAY (f), SSDATA (buffer), 3646 rc = XpmCreateImageFromBuffer (FRAME_X_DISPLAY (f), SSDATA (buffer),
3656 &img->ximg, &img->mask_img, 3647 &img->ximg, &img->mask_img,
@@ -3699,7 +3690,7 @@ xpm_load (struct frame *f, struct image *img)
3699 img->pixmap = xpm_image->bitmap; 3690 img->pixmap = xpm_image->bitmap;
3700 /* XImageFree in libXpm frees XImage struct without destroying 3691 /* XImageFree in libXpm frees XImage struct without destroying
3701 the bitmap, which is what we want. */ 3692 the bitmap, which is what we want. */
3702 fn_XImageFree (xpm_image); 3693 XImageFree (xpm_image);
3703 } 3694 }
3704 if (xpm_mask && xpm_mask->bitmap) 3695 if (xpm_mask && xpm_mask->bitmap)
3705 { 3696 {
@@ -3713,7 +3704,7 @@ xpm_load (struct frame *f, struct image *img)
3713 SelectObject (hdc, old_obj); 3704 SelectObject (hdc, old_obj);
3714 3705
3715 img->mask = xpm_mask->bitmap; 3706 img->mask = xpm_mask->bitmap;
3716 fn_XImageFree (xpm_mask); 3707 XImageFree (xpm_mask);
3717 DeleteDC (hdc); 3708 DeleteDC (hdc);
3718 } 3709 }
3719 3710
@@ -3737,11 +3728,7 @@ xpm_load (struct frame *f, struct image *img)
3737 eassert (img->width > 0 && img->height > 0); 3728 eassert (img->width > 0 && img->height > 0);
3738 3729
3739 /* The call to XpmFreeAttributes below frees attrs.alloc_pixels. */ 3730 /* The call to XpmFreeAttributes below frees attrs.alloc_pixels. */
3740#ifdef HAVE_NTGUI
3741 fn_XpmFreeAttributes (&attrs);
3742#else
3743 XpmFreeAttributes (&attrs); 3731 XpmFreeAttributes (&attrs);
3744#endif /* HAVE_NTGUI */
3745 3732
3746#ifdef HAVE_X_WINDOWS 3733#ifdef HAVE_X_WINDOWS
3747 /* Maybe fill in the background field while we have ximg handy. */ 3734 /* Maybe fill in the background field while we have ximg handy. */
@@ -5535,39 +5522,42 @@ png_image_p (Lisp_Object object)
5535 5522
5536#if defined HAVE_PNG && !defined HAVE_NS 5523#if defined HAVE_PNG && !defined HAVE_NS
5537 5524
5538#ifdef WINDOWSNT 5525# ifdef WINDOWSNT
5539/* PNG library details. */ 5526/* PNG library details. */
5540 5527
5541DEF_IMGLIB_FN (png_voidp, png_get_io_ptr, (png_structp)); 5528DEF_DLL_FN (png_voidp, png_get_io_ptr, (png_structp));
5542DEF_IMGLIB_FN (int, png_sig_cmp, (png_bytep, png_size_t, png_size_t)); 5529DEF_DLL_FN (int, png_sig_cmp, (png_bytep, png_size_t, png_size_t));
5543DEF_IMGLIB_FN (png_structp, png_create_read_struct, (png_const_charp, png_voidp, 5530DEF_DLL_FN (png_structp, png_create_read_struct,
5544 png_error_ptr, png_error_ptr)); 5531 (png_const_charp, png_voidp, png_error_ptr, png_error_ptr));
5545DEF_IMGLIB_FN (png_infop, png_create_info_struct, (png_structp)); 5532DEF_DLL_FN (png_infop, png_create_info_struct, (png_structp));
5546DEF_IMGLIB_FN (void, png_destroy_read_struct, (png_structpp, png_infopp, png_infopp)); 5533DEF_DLL_FN (void, png_destroy_read_struct,
5547DEF_IMGLIB_FN (void, png_set_read_fn, (png_structp, png_voidp, png_rw_ptr)); 5534 (png_structpp, png_infopp, png_infopp));
5548DEF_IMGLIB_FN (void, png_set_sig_bytes, (png_structp, int)); 5535DEF_DLL_FN (void, png_set_read_fn, (png_structp, png_voidp, png_rw_ptr));
5549DEF_IMGLIB_FN (void, png_read_info, (png_structp, png_infop)); 5536DEF_DLL_FN (void, png_set_sig_bytes, (png_structp, int));
5550DEF_IMGLIB_FN (png_uint_32, png_get_IHDR, (png_structp, png_infop, 5537DEF_DLL_FN (void, png_read_info, (png_structp, png_infop));
5551 png_uint_32 *, png_uint_32 *, 5538DEF_DLL_FN (png_uint_32, png_get_IHDR,
5552 int *, int *, int *, int *, int *)); 5539 (png_structp, png_infop, png_uint_32 *, png_uint_32 *,
5553DEF_IMGLIB_FN (png_uint_32, png_get_valid, (png_structp, png_infop, png_uint_32)); 5540 int *, int *, int *, int *, int *));
5554DEF_IMGLIB_FN (void, png_set_strip_16, (png_structp)); 5541DEF_DLL_FN (png_uint_32, png_get_valid, (png_structp, png_infop, png_uint_32));
5555DEF_IMGLIB_FN (void, png_set_expand, (png_structp)); 5542DEF_DLL_FN (void, png_set_strip_16, (png_structp));
5556DEF_IMGLIB_FN (void, png_set_gray_to_rgb, (png_structp)); 5543DEF_DLL_FN (void, png_set_expand, (png_structp));
5557DEF_IMGLIB_FN (void, png_set_background, (png_structp, png_color_16p, 5544DEF_DLL_FN (void, png_set_gray_to_rgb, (png_structp));
5558 int, int, double)); 5545DEF_DLL_FN (void, png_set_background,
5559DEF_IMGLIB_FN (png_uint_32, png_get_bKGD, (png_structp, png_infop, png_color_16p *)); 5546 (png_structp, png_color_16p, int, int, double));
5560DEF_IMGLIB_FN (void, png_read_update_info, (png_structp, png_infop)); 5547DEF_DLL_FN (png_uint_32, png_get_bKGD,
5561DEF_IMGLIB_FN (png_byte, png_get_channels, (png_structp, png_infop)); 5548 (png_structp, png_infop, png_color_16p *));
5562DEF_IMGLIB_FN (png_size_t, png_get_rowbytes, (png_structp, png_infop)); 5549DEF_DLL_FN (void, png_read_update_info, (png_structp, png_infop));
5563DEF_IMGLIB_FN (void, png_read_image, (png_structp, png_bytepp)); 5550DEF_DLL_FN (png_byte, png_get_channels, (png_structp, png_infop));
5564DEF_IMGLIB_FN (void, png_read_end, (png_structp, png_infop)); 5551DEF_DLL_FN (png_size_t, png_get_rowbytes, (png_structp, png_infop));
5565DEF_IMGLIB_FN (void, png_error, (png_structp, png_const_charp)); 5552DEF_DLL_FN (void, png_read_image, (png_structp, png_bytepp));
5566 5553DEF_DLL_FN (void, png_read_end, (png_structp, png_infop));
5567#if (PNG_LIBPNG_VER >= 10500) 5554DEF_DLL_FN (void, png_error, (png_structp, png_const_charp));
5568DEF_IMGLIB_FN (void, png_longjmp, (png_structp, int)) PNG_NORETURN; 5555
5569DEF_IMGLIB_FN (jmp_buf *, png_set_longjmp_fn, (png_structp, png_longjmp_ptr, size_t)); 5556# if (PNG_LIBPNG_VER >= 10500)
5570#endif /* libpng version >= 1.5 */ 5557DEF_DLL_FN (void, png_longjmp, (png_structp, int)) PNG_NORETURN;
5558DEF_DLL_FN (jmp_buf *, png_set_longjmp_fn,
5559 (png_structp, png_longjmp_ptr, size_t));
5560# endif /* libpng version >= 1.5 */
5571 5561
5572static bool 5562static bool
5573init_png_functions (void) 5563init_png_functions (void)
@@ -5577,87 +5567,107 @@ init_png_functions (void)
5577 if (!(library = w32_delayed_load (Qpng))) 5567 if (!(library = w32_delayed_load (Qpng)))
5578 return 0; 5568 return 0;
5579 5569
5580 LOAD_IMGLIB_FN (library, png_get_io_ptr); 5570 LOAD_DLL_FN (library, png_get_io_ptr);
5581 LOAD_IMGLIB_FN (library, png_sig_cmp); 5571 LOAD_DLL_FN (library, png_sig_cmp);
5582 LOAD_IMGLIB_FN (library, png_create_read_struct); 5572 LOAD_DLL_FN (library, png_create_read_struct);
5583 LOAD_IMGLIB_FN (library, png_create_info_struct); 5573 LOAD_DLL_FN (library, png_create_info_struct);
5584 LOAD_IMGLIB_FN (library, png_destroy_read_struct); 5574 LOAD_DLL_FN (library, png_destroy_read_struct);
5585 LOAD_IMGLIB_FN (library, png_set_read_fn); 5575 LOAD_DLL_FN (library, png_set_read_fn);
5586 LOAD_IMGLIB_FN (library, png_set_sig_bytes); 5576 LOAD_DLL_FN (library, png_set_sig_bytes);
5587 LOAD_IMGLIB_FN (library, png_read_info); 5577 LOAD_DLL_FN (library, png_read_info);
5588 LOAD_IMGLIB_FN (library, png_get_IHDR); 5578 LOAD_DLL_FN (library, png_get_IHDR);
5589 LOAD_IMGLIB_FN (library, png_get_valid); 5579 LOAD_DLL_FN (library, png_get_valid);
5590 LOAD_IMGLIB_FN (library, png_set_strip_16); 5580 LOAD_DLL_FN (library, png_set_strip_16);
5591 LOAD_IMGLIB_FN (library, png_set_expand); 5581 LOAD_DLL_FN (library, png_set_expand);
5592 LOAD_IMGLIB_FN (library, png_set_gray_to_rgb); 5582 LOAD_DLL_FN (library, png_set_gray_to_rgb);
5593 LOAD_IMGLIB_FN (library, png_set_background); 5583 LOAD_DLL_FN (library, png_set_background);
5594 LOAD_IMGLIB_FN (library, png_get_bKGD); 5584 LOAD_DLL_FN (library, png_get_bKGD);
5595 LOAD_IMGLIB_FN (library, png_read_update_info); 5585 LOAD_DLL_FN (library, png_read_update_info);
5596 LOAD_IMGLIB_FN (library, png_get_channels); 5586 LOAD_DLL_FN (library, png_get_channels);
5597 LOAD_IMGLIB_FN (library, png_get_rowbytes); 5587 LOAD_DLL_FN (library, png_get_rowbytes);
5598 LOAD_IMGLIB_FN (library, png_read_image); 5588 LOAD_DLL_FN (library, png_read_image);
5599 LOAD_IMGLIB_FN (library, png_read_end); 5589 LOAD_DLL_FN (library, png_read_end);
5600 LOAD_IMGLIB_FN (library, png_error); 5590 LOAD_DLL_FN (library, png_error);
5601 5591
5602#if (PNG_LIBPNG_VER >= 10500) 5592# if (PNG_LIBPNG_VER >= 10500)
5603 LOAD_IMGLIB_FN (library, png_longjmp); 5593 LOAD_DLL_FN (library, png_longjmp);
5604 LOAD_IMGLIB_FN (library, png_set_longjmp_fn); 5594 LOAD_DLL_FN (library, png_set_longjmp_fn);
5605#endif /* libpng version >= 1.5 */ 5595# endif /* libpng version >= 1.5 */
5606 5596
5607 return 1; 5597 return 1;
5608} 5598}
5609#else
5610
5611#define fn_png_get_io_ptr png_get_io_ptr
5612#define fn_png_sig_cmp png_sig_cmp
5613#define fn_png_create_read_struct png_create_read_struct
5614#define fn_png_create_info_struct png_create_info_struct
5615#define fn_png_destroy_read_struct png_destroy_read_struct
5616#define fn_png_set_read_fn png_set_read_fn
5617#define fn_png_set_sig_bytes png_set_sig_bytes
5618#define fn_png_read_info png_read_info
5619#define fn_png_get_IHDR png_get_IHDR
5620#define fn_png_get_valid png_get_valid
5621#define fn_png_set_strip_16 png_set_strip_16
5622#define fn_png_set_expand png_set_expand
5623#define fn_png_set_gray_to_rgb png_set_gray_to_rgb
5624#define fn_png_set_background png_set_background
5625#define fn_png_get_bKGD png_get_bKGD
5626#define fn_png_read_update_info png_read_update_info
5627#define fn_png_get_channels png_get_channels
5628#define fn_png_get_rowbytes png_get_rowbytes
5629#define fn_png_read_image png_read_image
5630#define fn_png_read_end png_read_end
5631#define fn_png_error png_error
5632
5633#if (PNG_LIBPNG_VER >= 10500)
5634#define fn_png_longjmp png_longjmp
5635#define fn_png_set_longjmp_fn png_set_longjmp_fn
5636#endif /* libpng version >= 1.5 */
5637 5599
5638#endif /* WINDOWSNT */ 5600# undef png_create_info_struct
5601# undef png_create_read_struct
5602# undef png_destroy_read_struct
5603# undef png_error
5604# undef png_get_bKGD
5605# undef png_get_channels
5606# undef png_get_IHDR
5607# undef png_get_io_ptr
5608# undef png_get_rowbytes
5609# undef png_get_valid
5610# undef png_longjmp
5611# undef png_read_end
5612# undef png_read_image
5613# undef png_read_info
5614# undef png_read_update_info
5615# undef png_set_background
5616# undef png_set_expand
5617# undef png_set_gray_to_rgb
5618# undef png_set_longjmp_fn
5619# undef png_set_read_fn
5620# undef png_set_sig_bytes
5621# undef png_set_strip_16
5622# undef png_sig_cmp
5623
5624# define png_create_info_struct fn_png_create_info_struct
5625# define png_create_read_struct fn_png_create_read_struct
5626# define png_destroy_read_struct fn_png_destroy_read_struct
5627# define png_error fn_png_error
5628# define png_get_bKGD fn_png_get_bKGD
5629# define png_get_channels fn_png_get_channels
5630# define png_get_IHDR fn_png_get_IHDR
5631# define png_get_io_ptr fn_png_get_io_ptr
5632# define png_get_rowbytes fn_png_get_rowbytes
5633# define png_get_valid fn_png_get_valid
5634# define png_longjmp fn_png_longjmp
5635# define png_read_end fn_png_read_end
5636# define png_read_image fn_png_read_image
5637# define png_read_info fn_png_read_info
5638# define png_read_update_info fn_png_read_update_info
5639# define png_set_background fn_png_set_background
5640# define png_set_expand fn_png_set_expand
5641# define png_set_gray_to_rgb fn_png_set_gray_to_rgb
5642# define png_set_longjmp_fn fn_png_set_longjmp_fn
5643# define png_set_read_fn fn_png_set_read_fn
5644# define png_set_sig_bytes fn_png_set_sig_bytes
5645# define png_set_strip_16 fn_png_set_strip_16
5646# define png_sig_cmp fn_png_sig_cmp
5647
5648# endif /* WINDOWSNT */
5639 5649
5640/* Fast implementations of setjmp and longjmp. Although setjmp and longjmp 5650/* Fast implementations of setjmp and longjmp. Although setjmp and longjmp
5641 will do, POSIX _setjmp and _longjmp (if available) are often faster. 5651 will do, POSIX _setjmp and _longjmp (if available) are often faster.
5642 Do not use sys_setjmp, as PNG supports only jmp_buf. 5652 Do not use sys_setjmp, as PNG supports only jmp_buf.
5643 It's OK if the longjmp substitute restores the signal mask. */ 5653 It's OK if the longjmp substitute restores the signal mask. */
5644#ifdef HAVE__SETJMP 5654# ifdef HAVE__SETJMP
5645# define FAST_SETJMP(j) _setjmp (j) 5655# define FAST_SETJMP(j) _setjmp (j)
5646# define FAST_LONGJMP _longjmp 5656# define FAST_LONGJMP _longjmp
5647#else 5657# else
5648# define FAST_SETJMP(j) setjmp (j) 5658# define FAST_SETJMP(j) setjmp (j)
5649# define FAST_LONGJMP longjmp 5659# define FAST_LONGJMP longjmp
5650#endif 5660# endif
5651 5661
5652#if PNG_LIBPNG_VER < 10500 5662# if PNG_LIBPNG_VER < 10500
5653#define PNG_LONGJMP(ptr) FAST_LONGJMP ((ptr)->jmpbuf, 1) 5663# define PNG_LONGJMP(ptr) FAST_LONGJMP ((ptr)->jmpbuf, 1)
5654#define PNG_JMPBUF(ptr) ((ptr)->jmpbuf) 5664# define PNG_JMPBUF(ptr) ((ptr)->jmpbuf)
5655#else 5665# else
5656/* In libpng version 1.5, the jmpbuf member is hidden. (Bug#7908) */ 5666/* In libpng version 1.5, the jmpbuf member is hidden. (Bug#7908) */
5657#define PNG_LONGJMP(ptr) fn_png_longjmp (ptr, 1) 5667# define PNG_LONGJMP(ptr) png_longjmp (ptr, 1)
5658#define PNG_JMPBUF(ptr) \ 5668# define PNG_JMPBUF(ptr) \
5659 (*fn_png_set_longjmp_fn (ptr, FAST_LONGJMP, sizeof (jmp_buf))) 5669 (*png_set_longjmp_fn (ptr, FAST_LONGJMP, sizeof (jmp_buf)))
5660#endif 5670# endif
5661 5671
5662/* Error and warning handlers installed when the PNG library 5672/* Error and warning handlers installed when the PNG library
5663 is initialized. */ 5673 is initialized. */
@@ -5697,10 +5707,10 @@ struct png_memory_storage
5697static void 5707static void
5698png_read_from_memory (png_structp png_ptr, png_bytep data, png_size_t length) 5708png_read_from_memory (png_structp png_ptr, png_bytep data, png_size_t length)
5699{ 5709{
5700 struct png_memory_storage *tbr = fn_png_get_io_ptr (png_ptr); 5710 struct png_memory_storage *tbr = png_get_io_ptr (png_ptr);
5701 5711
5702 if (length > tbr->len - tbr->index) 5712 if (length > tbr->len - tbr->index)
5703 fn_png_error (png_ptr, "Read error"); 5713 png_error (png_ptr, "Read error");
5704 5714
5705 memcpy (data, tbr->bytes + tbr->index, length); 5715 memcpy (data, tbr->bytes + tbr->index, length);
5706 tbr->index = tbr->index + length; 5716 tbr->index = tbr->index + length;
@@ -5714,10 +5724,10 @@ png_read_from_memory (png_structp png_ptr, png_bytep data, png_size_t length)
5714static void 5724static void
5715png_read_from_file (png_structp png_ptr, png_bytep data, png_size_t length) 5725png_read_from_file (png_structp png_ptr, png_bytep data, png_size_t length)
5716{ 5726{
5717 FILE *fp = fn_png_get_io_ptr (png_ptr); 5727 FILE *fp = png_get_io_ptr (png_ptr);
5718 5728
5719 if (fread (data, 1, length, fp) < length) 5729 if (fread (data, 1, length, fp) < length)
5720 fn_png_error (png_ptr, "Read error"); 5730 png_error (png_ptr, "Read error");
5721} 5731}
5722 5732
5723 5733
@@ -5779,7 +5789,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5779 5789
5780 /* Check PNG signature. */ 5790 /* Check PNG signature. */
5781 if (fread (sig, 1, sizeof sig, fp) != sizeof sig 5791 if (fread (sig, 1, sizeof sig, fp) != sizeof sig
5782 || fn_png_sig_cmp (sig, 0, sizeof sig)) 5792 || png_sig_cmp (sig, 0, sizeof sig))
5783 { 5793 {
5784 fclose (fp); 5794 fclose (fp);
5785 image_error ("Not a PNG file: `%s'", file, Qnil); 5795 image_error ("Not a PNG file: `%s'", file, Qnil);
@@ -5801,7 +5811,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5801 5811
5802 /* Check PNG signature. */ 5812 /* Check PNG signature. */
5803 if (tbr.len < sizeof sig 5813 if (tbr.len < sizeof sig
5804 || fn_png_sig_cmp (tbr.bytes, 0, sizeof sig)) 5814 || png_sig_cmp (tbr.bytes, 0, sizeof sig))
5805 { 5815 {
5806 image_error ("Not a PNG image: `%s'", img->spec, Qnil); 5816 image_error ("Not a PNG image: `%s'", img->spec, Qnil);
5807 return 0; 5817 return 0;
@@ -5812,13 +5822,13 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5812 } 5822 }
5813 5823
5814 /* Initialize read and info structs for PNG lib. */ 5824 /* Initialize read and info structs for PNG lib. */
5815 png_ptr = fn_png_create_read_struct (PNG_LIBPNG_VER_STRING, 5825 png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING,
5816 NULL, my_png_error, 5826 NULL, my_png_error,
5817 my_png_warning); 5827 my_png_warning);
5818 if (png_ptr) 5828 if (png_ptr)
5819 { 5829 {
5820 info_ptr = fn_png_create_info_struct (png_ptr); 5830 info_ptr = png_create_info_struct (png_ptr);
5821 end_info = fn_png_create_info_struct (png_ptr); 5831 end_info = png_create_info_struct (png_ptr);
5822 } 5832 }
5823 5833
5824 c->png_ptr = png_ptr; 5834 c->png_ptr = png_ptr;
@@ -5830,7 +5840,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5830 5840
5831 if (! (info_ptr && end_info)) 5841 if (! (info_ptr && end_info))
5832 { 5842 {
5833 fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info); 5843 png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info);
5834 png_ptr = 0; 5844 png_ptr = 0;
5835 } 5845 }
5836 if (! png_ptr) 5846 if (! png_ptr)
@@ -5845,7 +5855,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5845 { 5855 {
5846 error: 5856 error:
5847 if (c->png_ptr) 5857 if (c->png_ptr)
5848 fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info); 5858 png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info);
5849 xfree (c->pixels); 5859 xfree (c->pixels);
5850 xfree (c->rows); 5860 xfree (c->rows);
5851 if (c->fp) 5861 if (c->fp)
@@ -5858,14 +5868,14 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5858 5868
5859 /* Read image info. */ 5869 /* Read image info. */
5860 if (!NILP (specified_data)) 5870 if (!NILP (specified_data))
5861 fn_png_set_read_fn (png_ptr, &tbr, png_read_from_memory); 5871 png_set_read_fn (png_ptr, &tbr, png_read_from_memory);
5862 else 5872 else
5863 fn_png_set_read_fn (png_ptr, fp, png_read_from_file); 5873 png_set_read_fn (png_ptr, fp, png_read_from_file);
5864 5874
5865 fn_png_set_sig_bytes (png_ptr, sizeof sig); 5875 png_set_sig_bytes (png_ptr, sizeof sig);
5866 fn_png_read_info (png_ptr, info_ptr); 5876 png_read_info (png_ptr, info_ptr);
5867 fn_png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 5877 png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
5868 &interlace_type, NULL, NULL); 5878 &interlace_type, NULL, NULL);
5869 5879
5870 if (! (width <= INT_MAX && height <= INT_MAX 5880 if (! (width <= INT_MAX && height <= INT_MAX
5871 && check_image_size (f, width, height))) 5881 && check_image_size (f, width, height)))
@@ -5881,7 +5891,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5881 5891
5882 /* If image contains simply transparency data, we prefer to 5892 /* If image contains simply transparency data, we prefer to
5883 construct a clipping mask. */ 5893 construct a clipping mask. */
5884 if (fn_png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) 5894 if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
5885 transparent_p = 1; 5895 transparent_p = 1;
5886 else 5896 else
5887 transparent_p = 0; 5897 transparent_p = 0;
@@ -5892,16 +5902,16 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5892 5902
5893 /* Strip more than 8 bits per channel. */ 5903 /* Strip more than 8 bits per channel. */
5894 if (bit_depth == 16) 5904 if (bit_depth == 16)
5895 fn_png_set_strip_16 (png_ptr); 5905 png_set_strip_16 (png_ptr);
5896 5906
5897 /* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha channel 5907 /* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha channel
5898 if available. */ 5908 if available. */
5899 fn_png_set_expand (png_ptr); 5909 png_set_expand (png_ptr);
5900 5910
5901 /* Convert grayscale images to RGB. */ 5911 /* Convert grayscale images to RGB. */
5902 if (color_type == PNG_COLOR_TYPE_GRAY 5912 if (color_type == PNG_COLOR_TYPE_GRAY
5903 || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) 5913 || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
5904 fn_png_set_gray_to_rgb (png_ptr); 5914 png_set_gray_to_rgb (png_ptr);
5905 5915
5906 /* Handle alpha channel by combining the image with a background 5916 /* Handle alpha channel by combining the image with a background
5907 color. Do this only if a real alpha channel is supplied. For 5917 color. Do this only if a real alpha channel is supplied. For
@@ -5927,24 +5937,24 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5927 bg.green = color.green >> shift; 5937 bg.green = color.green >> shift;
5928 bg.blue = color.blue >> shift; 5938 bg.blue = color.blue >> shift;
5929 5939
5930 fn_png_set_background (png_ptr, &bg, 5940 png_set_background (png_ptr, &bg,
5931 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); 5941 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
5932 } 5942 }
5933 } 5943 }
5934 5944
5935 /* Update info structure. */ 5945 /* Update info structure. */
5936 fn_png_read_update_info (png_ptr, info_ptr); 5946 png_read_update_info (png_ptr, info_ptr);
5937 5947
5938 /* Get number of channels. Valid values are 1 for grayscale images 5948 /* Get number of channels. Valid values are 1 for grayscale images
5939 and images with a palette, 2 for grayscale images with transparency 5949 and images with a palette, 2 for grayscale images with transparency
5940 information (alpha channel), 3 for RGB images, and 4 for RGB 5950 information (alpha channel), 3 for RGB images, and 4 for RGB
5941 images with alpha channel, i.e. RGBA. If conversions above were 5951 images with alpha channel, i.e. RGBA. If conversions above were
5942 sufficient we should only have 3 or 4 channels here. */ 5952 sufficient we should only have 3 or 4 channels here. */
5943 channels = fn_png_get_channels (png_ptr, info_ptr); 5953 channels = png_get_channels (png_ptr, info_ptr);
5944 eassert (channels == 3 || channels == 4); 5954 eassert (channels == 3 || channels == 4);
5945 5955
5946 /* Number of bytes needed for one row of the image. */ 5956 /* Number of bytes needed for one row of the image. */
5947 row_bytes = fn_png_get_rowbytes (png_ptr, info_ptr); 5957 row_bytes = png_get_rowbytes (png_ptr, info_ptr);
5948 5958
5949 /* Allocate memory for the image. */ 5959 /* Allocate memory for the image. */
5950 if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *rows < height 5960 if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *rows < height
@@ -5956,8 +5966,8 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5956 rows[i] = pixels + i * row_bytes; 5966 rows[i] = pixels + i * row_bytes;
5957 5967
5958 /* Read the entire image. */ 5968 /* Read the entire image. */
5959 fn_png_read_image (png_ptr, rows); 5969 png_read_image (png_ptr, rows);
5960 fn_png_read_end (png_ptr, info_ptr); 5970 png_read_end (png_ptr, info_ptr);
5961 if (fp) 5971 if (fp)
5962 { 5972 {
5963 fclose (fp); 5973 fclose (fp);
@@ -6021,21 +6031,21 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
6021 overrode it. */ 6031 overrode it. */
6022 { 6032 {
6023 png_color_16 *bg; 6033 png_color_16 *bg;
6024 if (fn_png_get_bKGD (png_ptr, info_ptr, &bg)) 6034 if (png_get_bKGD (png_ptr, info_ptr, &bg))
6025 { 6035 {
6026 img->background = lookup_rgb_color (f, bg->red, bg->green, bg->blue); 6036 img->background = lookup_rgb_color (f, bg->red, bg->green, bg->blue);
6027 img->background_valid = 1; 6037 img->background_valid = 1;
6028 } 6038 }
6029 } 6039 }
6030 6040
6031#ifdef COLOR_TABLE_SUPPORT 6041# ifdef COLOR_TABLE_SUPPORT
6032 /* Remember colors allocated for this image. */ 6042 /* Remember colors allocated for this image. */
6033 img->colors = colors_in_color_table (&img->ncolors); 6043 img->colors = colors_in_color_table (&img->ncolors);
6034 free_color_table (); 6044 free_color_table ();
6035#endif /* COLOR_TABLE_SUPPORT */ 6045# endif /* COLOR_TABLE_SUPPORT */
6036 6046
6037 /* Clean up. */ 6047 /* Clean up. */
6038 fn_png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info); 6048 png_destroy_read_struct (&c->png_ptr, &c->info_ptr, &c->end_info);
6039 xfree (rows); 6049 xfree (rows);
6040 xfree (pixels); 6050 xfree (pixels);
6041 6051
@@ -6170,15 +6180,15 @@ jpeg_image_p (Lisp_Object object)
6170 6180
6171/* Work around a warning about HAVE_STDLIB_H being redefined in 6181/* Work around a warning about HAVE_STDLIB_H being redefined in
6172 jconfig.h. */ 6182 jconfig.h. */
6173#ifdef HAVE_STDLIB_H 6183# ifdef HAVE_STDLIB_H
6174#undef HAVE_STDLIB_H 6184# undef HAVE_STDLIB_H
6175#endif /* HAVE_STLIB_H */ 6185# endif
6176 6186
6177#if defined (HAVE_NTGUI) && !defined (__WIN32__) 6187# if defined (HAVE_NTGUI) && !defined (__WIN32__)
6178/* In older releases of the jpeg library, jpeglib.h will define boolean 6188/* In older releases of the jpeg library, jpeglib.h will define boolean
6179 differently depending on __WIN32__, so make sure it is defined. */ 6189 differently depending on __WIN32__, so make sure it is defined. */
6180#define __WIN32__ 1 6190# define __WIN32__ 1
6181#endif 6191# endif
6182 6192
6183/* rpcndr.h (via windows.h) and jpeglib.h both define boolean types. 6193/* rpcndr.h (via windows.h) and jpeglib.h both define boolean types.
6184 Some versions of jpeglib try to detect whether rpcndr.h is loaded, 6194 Some versions of jpeglib try to detect whether rpcndr.h is loaded,
@@ -6194,23 +6204,25 @@ jpeg_image_p (Lisp_Object object)
6194 different name. This name, jpeg_boolean, remains in effect through 6204 different name. This name, jpeg_boolean, remains in effect through
6195 the rest of image.c. 6205 the rest of image.c.
6196*/ 6206*/
6197#if defined CYGWIN && defined HAVE_NTGUI 6207# if defined CYGWIN && defined HAVE_NTGUI
6198#define boolean jpeg_boolean 6208# define boolean jpeg_boolean
6199#endif 6209# endif
6200#include <jpeglib.h> 6210# include <jpeglib.h>
6201#include <jerror.h> 6211# include <jerror.h>
6202 6212
6203#ifdef WINDOWSNT 6213# ifdef WINDOWSNT
6204 6214
6205/* JPEG library details. */ 6215/* JPEG library details. */
6206DEF_IMGLIB_FN (void, jpeg_CreateDecompress, (j_decompress_ptr, int, size_t)); 6216DEF_DLL_FN (void, jpeg_CreateDecompress, (j_decompress_ptr, int, size_t));
6207DEF_IMGLIB_FN (boolean, jpeg_start_decompress, (j_decompress_ptr)); 6217DEF_DLL_FN (boolean, jpeg_start_decompress, (j_decompress_ptr));
6208DEF_IMGLIB_FN (boolean, jpeg_finish_decompress, (j_decompress_ptr)); 6218DEF_DLL_FN (boolean, jpeg_finish_decompress, (j_decompress_ptr));
6209DEF_IMGLIB_FN (void, jpeg_destroy_decompress, (j_decompress_ptr)); 6219DEF_DLL_FN (void, jpeg_destroy_decompress, (j_decompress_ptr));
6210DEF_IMGLIB_FN (int, jpeg_read_header, (j_decompress_ptr, boolean)); 6220DEF_DLL_FN (int, jpeg_read_header, (j_decompress_ptr, boolean));
6211DEF_IMGLIB_FN (JDIMENSION, jpeg_read_scanlines, (j_decompress_ptr, JSAMPARRAY, JDIMENSION)); 6221DEF_DLL_FN (JDIMENSION, jpeg_read_scanlines,
6212DEF_IMGLIB_FN (struct jpeg_error_mgr *, jpeg_std_error, (struct jpeg_error_mgr *)); 6222 (j_decompress_ptr, JSAMPARRAY, JDIMENSION));
6213DEF_IMGLIB_FN (boolean, jpeg_resync_to_restart, (j_decompress_ptr, int)); 6223DEF_DLL_FN (struct jpeg_error_mgr *, jpeg_std_error,
6224 (struct jpeg_error_mgr *));
6225DEF_DLL_FN (boolean, jpeg_resync_to_restart, (j_decompress_ptr, int));
6214 6226
6215static bool 6227static bool
6216init_jpeg_functions (void) 6228init_jpeg_functions (void)
@@ -6220,37 +6232,46 @@ init_jpeg_functions (void)
6220 if (!(library = w32_delayed_load (Qjpeg))) 6232 if (!(library = w32_delayed_load (Qjpeg)))
6221 return 0; 6233 return 0;
6222 6234
6223 LOAD_IMGLIB_FN (library, jpeg_finish_decompress); 6235 LOAD_DLL_FN (library, jpeg_finish_decompress);
6224 LOAD_IMGLIB_FN (library, jpeg_read_scanlines); 6236 LOAD_DLL_FN (library, jpeg_read_scanlines);
6225 LOAD_IMGLIB_FN (library, jpeg_start_decompress); 6237 LOAD_DLL_FN (library, jpeg_start_decompress);
6226 LOAD_IMGLIB_FN (library, jpeg_read_header); 6238 LOAD_DLL_FN (library, jpeg_read_header);
6227 LOAD_IMGLIB_FN (library, jpeg_CreateDecompress); 6239 LOAD_DLL_FN (library, jpeg_CreateDecompress);
6228 LOAD_IMGLIB_FN (library, jpeg_destroy_decompress); 6240 LOAD_DLL_FN (library, jpeg_destroy_decompress);
6229 LOAD_IMGLIB_FN (library, jpeg_std_error); 6241 LOAD_DLL_FN (library, jpeg_std_error);
6230 LOAD_IMGLIB_FN (library, jpeg_resync_to_restart); 6242 LOAD_DLL_FN (library, jpeg_resync_to_restart);
6231 return 1; 6243 return 1;
6232} 6244}
6233 6245
6246# undef jpeg_CreateDecompress
6247# undef jpeg_destroy_decompress
6248# undef jpeg_finish_decompress
6249# undef jpeg_read_header
6250# undef jpeg_read_scanlines
6251# undef jpeg_resync_to_restart
6252# undef jpeg_start_decompress
6253# undef jpeg_std_error
6254
6255# define jpeg_CreateDecompress fn_jpeg_CreateDecompress
6256# define jpeg_destroy_decompress fn_jpeg_destroy_decompress
6257# define jpeg_finish_decompress fn_jpeg_finish_decompress
6258# define jpeg_read_header fn_jpeg_read_header
6259# define jpeg_read_scanlines fn_jpeg_read_scanlines
6260# define jpeg_resync_to_restart fn_jpeg_resync_to_restart
6261# define jpeg_start_decompress fn_jpeg_start_decompress
6262# define jpeg_std_error fn_jpeg_std_error
6263
6234/* Wrapper since we can't directly assign the function pointer 6264/* Wrapper since we can't directly assign the function pointer
6235 to another function pointer that was declared more completely easily. */ 6265 to another function pointer that was declared more completely easily. */
6236static boolean 6266static boolean
6237jpeg_resync_to_restart_wrapper (j_decompress_ptr cinfo, int desired) 6267jpeg_resync_to_restart_wrapper (j_decompress_ptr cinfo, int desired)
6238{ 6268{
6239 return fn_jpeg_resync_to_restart (cinfo, desired); 6269 return jpeg_resync_to_restart (cinfo, desired);
6240} 6270}
6271# undef jpeg_resync_to_restart
6272# define jpeg_resync_to_restart jpeg_resync_to_restart_wrapper
6241 6273
6242#else 6274# endif /* WINDOWSNT */
6243
6244#define fn_jpeg_CreateDecompress(a,b,c) jpeg_create_decompress (a)
6245#define fn_jpeg_start_decompress jpeg_start_decompress
6246#define fn_jpeg_finish_decompress jpeg_finish_decompress
6247#define fn_jpeg_destroy_decompress jpeg_destroy_decompress
6248#define fn_jpeg_read_header jpeg_read_header
6249#define fn_jpeg_read_scanlines jpeg_read_scanlines
6250#define fn_jpeg_std_error jpeg_std_error
6251#define jpeg_resync_to_restart_wrapper jpeg_resync_to_restart
6252
6253#endif /* WINDOWSNT */
6254 6275
6255struct my_jpeg_error_mgr 6276struct my_jpeg_error_mgr
6256{ 6277{
@@ -6358,7 +6379,7 @@ jpeg_memory_src (j_decompress_ptr cinfo, JOCTET *data, ptrdiff_t len)
6358 src->init_source = our_common_init_source; 6379 src->init_source = our_common_init_source;
6359 src->fill_input_buffer = our_memory_fill_input_buffer; 6380 src->fill_input_buffer = our_memory_fill_input_buffer;
6360 src->skip_input_data = our_memory_skip_input_data; 6381 src->skip_input_data = our_memory_skip_input_data;
6361 src->resync_to_restart = jpeg_resync_to_restart_wrapper; /* Use default method. */ 6382 src->resync_to_restart = jpeg_resync_to_restart; /* Use default method. */
6362 src->term_source = our_common_term_source; 6383 src->term_source = our_common_term_source;
6363 src->bytes_in_buffer = len; 6384 src->bytes_in_buffer = len;
6364 src->next_input_byte = data; 6385 src->next_input_byte = data;
@@ -6464,7 +6485,7 @@ jpeg_file_src (j_decompress_ptr cinfo, FILE *fp)
6464 src->mgr.init_source = our_common_init_source; 6485 src->mgr.init_source = our_common_init_source;
6465 src->mgr.fill_input_buffer = our_stdio_fill_input_buffer; 6486 src->mgr.fill_input_buffer = our_stdio_fill_input_buffer;
6466 src->mgr.skip_input_data = our_stdio_skip_input_data; 6487 src->mgr.skip_input_data = our_stdio_skip_input_data;
6467 src->mgr.resync_to_restart = jpeg_resync_to_restart_wrapper; /* Use default method. */ 6488 src->mgr.resync_to_restart = jpeg_resync_to_restart; /* Use default. */
6468 src->mgr.term_source = our_common_term_source; 6489 src->mgr.term_source = our_common_term_source;
6469 src->mgr.bytes_in_buffer = 0; 6490 src->mgr.bytes_in_buffer = 0;
6470 src->mgr.next_input_byte = NULL; 6491 src->mgr.next_input_byte = NULL;
@@ -6515,7 +6536,7 @@ jpeg_load_body (struct frame *f, struct image *img,
6515 6536
6516 /* Customize libjpeg's error handling to call my_error_exit when an 6537 /* Customize libjpeg's error handling to call my_error_exit when an
6517 error is detected. This function will perform a longjmp. */ 6538 error is detected. This function will perform a longjmp. */
6518 mgr->cinfo.err = fn_jpeg_std_error (&mgr->pub); 6539 mgr->cinfo.err = jpeg_std_error (&mgr->pub);
6519 mgr->pub.error_exit = my_error_exit; 6540 mgr->pub.error_exit = my_error_exit;
6520 if (sys_setjmp (mgr->setjmp_buffer)) 6541 if (sys_setjmp (mgr->setjmp_buffer))
6521 { 6542 {
@@ -6541,7 +6562,7 @@ jpeg_load_body (struct frame *f, struct image *img,
6541 /* Close the input file and destroy the JPEG object. */ 6562 /* Close the input file and destroy the JPEG object. */
6542 if (fp) 6563 if (fp)
6543 fclose (fp); 6564 fclose (fp);
6544 fn_jpeg_destroy_decompress (&mgr->cinfo); 6565 jpeg_destroy_decompress (&mgr->cinfo);
6545 6566
6546 /* If we already have an XImage, free that. */ 6567 /* If we already have an XImage, free that. */
6547 x_destroy_x_image (ximg); 6568 x_destroy_x_image (ximg);
@@ -6553,7 +6574,7 @@ jpeg_load_body (struct frame *f, struct image *img,
6553 6574
6554 /* Create the JPEG decompression object. Let it read from fp. 6575 /* Create the JPEG decompression object. Let it read from fp.
6555 Read the JPEG image header. */ 6576 Read the JPEG image header. */
6556 fn_jpeg_CreateDecompress (&mgr->cinfo, JPEG_LIB_VERSION, sizeof *&mgr->cinfo); 6577 jpeg_CreateDecompress (&mgr->cinfo, JPEG_LIB_VERSION, sizeof *&mgr->cinfo);
6557 6578
6558 if (NILP (specified_data)) 6579 if (NILP (specified_data))
6559 jpeg_file_src (&mgr->cinfo, fp); 6580 jpeg_file_src (&mgr->cinfo, fp);
@@ -6561,12 +6582,12 @@ jpeg_load_body (struct frame *f, struct image *img,
6561 jpeg_memory_src (&mgr->cinfo, SDATA (specified_data), 6582 jpeg_memory_src (&mgr->cinfo, SDATA (specified_data),
6562 SBYTES (specified_data)); 6583 SBYTES (specified_data));
6563 6584
6564 fn_jpeg_read_header (&mgr->cinfo, 1); 6585 jpeg_read_header (&mgr->cinfo, 1);
6565 6586
6566 /* Customize decompression so that color quantization will be used. 6587 /* Customize decompression so that color quantization will be used.
6567 Start decompression. */ 6588 Start decompression. */
6568 mgr->cinfo.quantize_colors = 1; 6589 mgr->cinfo.quantize_colors = 1;
6569 fn_jpeg_start_decompress (&mgr->cinfo); 6590 jpeg_start_decompress (&mgr->cinfo);
6570 width = img->width = mgr->cinfo.output_width; 6591 width = img->width = mgr->cinfo.output_width;
6571 height = img->height = mgr->cinfo.output_height; 6592 height = img->height = mgr->cinfo.output_height;
6572 6593
@@ -6629,14 +6650,14 @@ jpeg_load_body (struct frame *f, struct image *img,
6629 JPOOL_IMAGE, row_stride, 1); 6650 JPOOL_IMAGE, row_stride, 1);
6630 for (y = 0; y < height; ++y) 6651 for (y = 0; y < height; ++y)
6631 { 6652 {
6632 fn_jpeg_read_scanlines (&mgr->cinfo, buffer, 1); 6653 jpeg_read_scanlines (&mgr->cinfo, buffer, 1);
6633 for (x = 0; x < mgr->cinfo.output_width; ++x) 6654 for (x = 0; x < mgr->cinfo.output_width; ++x)
6634 XPutPixel (ximg, x, y, colors[buffer[0][x]]); 6655 XPutPixel (ximg, x, y, colors[buffer[0][x]]);
6635 } 6656 }
6636 6657
6637 /* Clean up. */ 6658 /* Clean up. */
6638 fn_jpeg_finish_decompress (&mgr->cinfo); 6659 jpeg_finish_decompress (&mgr->cinfo);
6639 fn_jpeg_destroy_decompress (&mgr->cinfo); 6660 jpeg_destroy_decompress (&mgr->cinfo);
6640 if (fp) 6661 if (fp)
6641 fclose (fp); 6662 fclose (fp);
6642 6663
@@ -6760,22 +6781,22 @@ tiff_image_p (Lisp_Object object)
6760 6781
6761#ifdef HAVE_TIFF 6782#ifdef HAVE_TIFF
6762 6783
6763#include <tiffio.h> 6784# include <tiffio.h>
6764 6785
6765#ifdef WINDOWSNT 6786# ifdef WINDOWSNT
6766 6787
6767/* TIFF library details. */ 6788/* TIFF library details. */
6768DEF_IMGLIB_FN (TIFFErrorHandler, TIFFSetErrorHandler, (TIFFErrorHandler)); 6789DEF_DLL_FN (TIFFErrorHandler, TIFFSetErrorHandler, (TIFFErrorHandler));
6769DEF_IMGLIB_FN (TIFFErrorHandler, TIFFSetWarningHandler, (TIFFErrorHandler)); 6790DEF_DLL_FN (TIFFErrorHandler, TIFFSetWarningHandler, (TIFFErrorHandler));
6770DEF_IMGLIB_FN (TIFF *, TIFFOpen, (const char *, const char *)); 6791DEF_DLL_FN (TIFF *, TIFFOpen, (const char *, const char *));
6771DEF_IMGLIB_FN (TIFF *, TIFFClientOpen, (const char *, const char *, thandle_t, 6792DEF_DLL_FN (TIFF *, TIFFClientOpen,
6772 TIFFReadWriteProc, TIFFReadWriteProc, 6793 (const char *, const char *, thandle_t, TIFFReadWriteProc,
6773 TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, 6794 TIFFReadWriteProc, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc,
6774 TIFFMapFileProc, TIFFUnmapFileProc)); 6795 TIFFMapFileProc, TIFFUnmapFileProc));
6775DEF_IMGLIB_FN (int, TIFFGetField, (TIFF *, ttag_t, ...)); 6796DEF_DLL_FN (int, TIFFGetField, (TIFF *, ttag_t, ...));
6776DEF_IMGLIB_FN (int, TIFFReadRGBAImage, (TIFF *, uint32, uint32, uint32 *, int)); 6797DEF_DLL_FN (int, TIFFReadRGBAImage, (TIFF *, uint32, uint32, uint32 *, int));
6777DEF_IMGLIB_FN (void, TIFFClose, (TIFF *)); 6798DEF_DLL_FN (void, TIFFClose, (TIFF *));
6778DEF_IMGLIB_FN (int, TIFFSetDirectory, (TIFF *, tdir_t)); 6799DEF_DLL_FN (int, TIFFSetDirectory, (TIFF *, tdir_t));
6779 6800
6780static bool 6801static bool
6781init_tiff_functions (void) 6802init_tiff_functions (void)
@@ -6785,28 +6806,36 @@ init_tiff_functions (void)
6785 if (!(library = w32_delayed_load (Qtiff))) 6806 if (!(library = w32_delayed_load (Qtiff)))
6786 return 0; 6807 return 0;
6787 6808
6788 LOAD_IMGLIB_FN (library, TIFFSetErrorHandler); 6809 LOAD_DLL_FN (library, TIFFSetErrorHandler);
6789 LOAD_IMGLIB_FN (library, TIFFSetWarningHandler); 6810 LOAD_DLL_FN (library, TIFFSetWarningHandler);
6790 LOAD_IMGLIB_FN (library, TIFFOpen); 6811 LOAD_DLL_FN (library, TIFFOpen);
6791 LOAD_IMGLIB_FN (library, TIFFClientOpen); 6812 LOAD_DLL_FN (library, TIFFClientOpen);
6792 LOAD_IMGLIB_FN (library, TIFFGetField); 6813 LOAD_DLL_FN (library, TIFFGetField);
6793 LOAD_IMGLIB_FN (library, TIFFReadRGBAImage); 6814 LOAD_DLL_FN (library, TIFFReadRGBAImage);
6794 LOAD_IMGLIB_FN (library, TIFFClose); 6815 LOAD_DLL_FN (library, TIFFClose);
6795 LOAD_IMGLIB_FN (library, TIFFSetDirectory); 6816 LOAD_DLL_FN (library, TIFFSetDirectory);
6796 return 1; 6817 return 1;
6797} 6818}
6798 6819
6799#else 6820# undef TIFFClientOpen
6821# undef TIFFClose
6822# undef TIFFGetField
6823# undef TIFFOpen
6824# undef TIFFReadRGBAImage
6825# undef TIFFSetDirectory
6826# undef TIFFSetErrorHandler
6827# undef TIFFSetWarningHandler
6800 6828
6801#define fn_TIFFSetErrorHandler TIFFSetErrorHandler 6829# define TIFFClientOpen fn_TIFFClientOpen
6802#define fn_TIFFSetWarningHandler TIFFSetWarningHandler 6830# define TIFFClose fn_TIFFClose
6803#define fn_TIFFOpen TIFFOpen 6831# define TIFFGetField fn_TIFFGetField
6804#define fn_TIFFClientOpen TIFFClientOpen 6832# define TIFFOpen fn_TIFFOpen
6805#define fn_TIFFGetField TIFFGetField 6833# define TIFFReadRGBAImage fn_TIFFReadRGBAImage
6806#define fn_TIFFReadRGBAImage TIFFReadRGBAImage 6834# define TIFFSetDirectory fn_TIFFSetDirectory
6807#define fn_TIFFClose TIFFClose 6835# define TIFFSetErrorHandler fn_TIFFSetErrorHandler
6808#define fn_TIFFSetDirectory TIFFSetDirectory 6836# define TIFFSetWarningHandler fn_TIFFSetWarningHandler
6809#endif /* WINDOWSNT */ 6837
6838# endif /* WINDOWSNT */
6810 6839
6811 6840
6812/* Reading from a memory buffer for TIFF images Based on the PNG 6841/* Reading from a memory buffer for TIFF images Based on the PNG
@@ -6904,11 +6933,11 @@ tiff_size_of_memory (thandle_t data)
6904 compiler error compiling tiff_handler, see Bugzilla bug #17406 6933 compiler error compiling tiff_handler, see Bugzilla bug #17406
6905 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17406). Declaring 6934 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17406). Declaring
6906 this function as external works around that problem. */ 6935 this function as external works around that problem. */
6907#if defined (__MINGW32__) && __GNUC__ == 3 6936# if defined (__MINGW32__) && __GNUC__ == 3
6908# define MINGW_STATIC 6937# define MINGW_STATIC
6909#else 6938# else
6910# define MINGW_STATIC static 6939# define MINGW_STATIC static
6911#endif 6940# endif
6912 6941
6913MINGW_STATIC void 6942MINGW_STATIC void
6914tiff_handler (const char *, const char *, const char *, va_list) 6943tiff_handler (const char *, const char *, const char *, va_list)
@@ -6927,7 +6956,7 @@ tiff_handler (const char *log_format, const char *title,
6927 add_to_log (log_format, build_string (title), 6956 add_to_log (log_format, build_string (title),
6928 make_string (buf, max (0, min (len, sizeof buf - 1)))); 6957 make_string (buf, max (0, min (len, sizeof buf - 1))));
6929} 6958}
6930#undef MINGW_STATIC 6959# undef MINGW_STATIC
6931 6960
6932static void tiff_error_handler (const char *, const char *, va_list) 6961static void tiff_error_handler (const char *, const char *, va_list)
6933 ATTRIBUTE_FORMAT_PRINTF (2, 0); 6962 ATTRIBUTE_FORMAT_PRINTF (2, 0);
@@ -6966,8 +6995,8 @@ tiff_load (struct frame *f, struct image *img)
6966 specified_file = image_spec_value (img->spec, QCfile, NULL); 6995 specified_file = image_spec_value (img->spec, QCfile, NULL);
6967 specified_data = image_spec_value (img->spec, QCdata, NULL); 6996 specified_data = image_spec_value (img->spec, QCdata, NULL);
6968 6997
6969 fn_TIFFSetErrorHandler ((TIFFErrorHandler) tiff_error_handler); 6998 TIFFSetErrorHandler ((TIFFErrorHandler) tiff_error_handler);
6970 fn_TIFFSetWarningHandler ((TIFFErrorHandler) tiff_warning_handler); 6999 TIFFSetWarningHandler ((TIFFErrorHandler) tiff_warning_handler);
6971 7000
6972 if (NILP (specified_data)) 7001 if (NILP (specified_data))
6973 { 7002 {
@@ -6978,12 +7007,12 @@ tiff_load (struct frame *f, struct image *img)
6978 image_error ("Cannot find image file `%s'", specified_file, Qnil); 7007 image_error ("Cannot find image file `%s'", specified_file, Qnil);
6979 return 0; 7008 return 0;
6980 } 7009 }
6981#ifdef WINDOWSNT 7010# ifdef WINDOWSNT
6982 file = ansi_encode_filename (file); 7011 file = ansi_encode_filename (file);
6983#endif 7012# endif
6984 7013
6985 /* Try to open the image file. */ 7014 /* Try to open the image file. */
6986 tiff = fn_TIFFOpen (SSDATA (file), "r"); 7015 tiff = TIFFOpen (SSDATA (file), "r");
6987 if (tiff == NULL) 7016 if (tiff == NULL)
6988 { 7017 {
6989 image_error ("Cannot open `%s'", file, Qnil); 7018 image_error ("Cannot open `%s'", file, Qnil);
@@ -7003,14 +7032,14 @@ tiff_load (struct frame *f, struct image *img)
7003 memsrc.len = SBYTES (specified_data); 7032 memsrc.len = SBYTES (specified_data);
7004 memsrc.index = 0; 7033 memsrc.index = 0;
7005 7034
7006 tiff = fn_TIFFClientOpen ("memory_source", "r", (thandle_t)&memsrc, 7035 tiff = TIFFClientOpen ("memory_source", "r", (thandle_t)&memsrc,
7007 tiff_read_from_memory, 7036 tiff_read_from_memory,
7008 tiff_write_from_memory, 7037 tiff_write_from_memory,
7009 tiff_seek_in_memory, 7038 tiff_seek_in_memory,
7010 tiff_close_memory, 7039 tiff_close_memory,
7011 tiff_size_of_memory, 7040 tiff_size_of_memory,
7012 tiff_mmap_memory, 7041 tiff_mmap_memory,
7013 tiff_unmap_memory); 7042 tiff_unmap_memory);
7014 7043
7015 if (!tiff) 7044 if (!tiff)
7016 { 7045 {
@@ -7024,24 +7053,24 @@ tiff_load (struct frame *f, struct image *img)
7024 { 7053 {
7025 EMACS_INT ino = XFASTINT (image); 7054 EMACS_INT ino = XFASTINT (image);
7026 if (! (TYPE_MINIMUM (tdir_t) <= ino && ino <= TYPE_MAXIMUM (tdir_t) 7055 if (! (TYPE_MINIMUM (tdir_t) <= ino && ino <= TYPE_MAXIMUM (tdir_t)
7027 && fn_TIFFSetDirectory (tiff, ino))) 7056 && TIFFSetDirectory (tiff, ino)))
7028 { 7057 {
7029 image_error ("Invalid image number `%s' in image `%s'", 7058 image_error ("Invalid image number `%s' in image `%s'",
7030 image, img->spec); 7059 image, img->spec);
7031 fn_TIFFClose (tiff); 7060 TIFFClose (tiff);
7032 return 0; 7061 return 0;
7033 } 7062 }
7034 } 7063 }
7035 7064
7036 /* Get width and height of the image, and allocate a raster buffer 7065 /* Get width and height of the image, and allocate a raster buffer
7037 of width x height 32-bit values. */ 7066 of width x height 32-bit values. */
7038 fn_TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width); 7067 TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width);
7039 fn_TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height); 7068 TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height);
7040 7069
7041 if (!check_image_size (f, width, height)) 7070 if (!check_image_size (f, width, height))
7042 { 7071 {
7043 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 7072 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
7044 fn_TIFFClose (tiff); 7073 TIFFClose (tiff);
7045 return 0; 7074 return 0;
7046 } 7075 }
7047 7076
@@ -7050,16 +7079,16 @@ tiff_load (struct frame *f, struct image *img)
7050 && image_create_x_image_and_pixmap (f, img, width, height, 0, 7079 && image_create_x_image_and_pixmap (f, img, width, height, 0,
7051 &ximg, 0))) 7080 &ximg, 0)))
7052 { 7081 {
7053 fn_TIFFClose (tiff); 7082 TIFFClose (tiff);
7054 return 0; 7083 return 0;
7055 } 7084 }
7056 7085
7057 buf = xmalloc (sizeof *buf * width * height); 7086 buf = xmalloc (sizeof *buf * width * height);
7058 7087
7059 rc = fn_TIFFReadRGBAImage (tiff, width, height, buf, 0); 7088 rc = TIFFReadRGBAImage (tiff, width, height, buf, 0);
7060 7089
7061 /* Count the number of images in the file. */ 7090 /* Count the number of images in the file. */
7062 for (count = 1; fn_TIFFSetDirectory (tiff, count); count++) 7091 for (count = 1; TIFFSetDirectory (tiff, count); count++)
7063 continue; 7092 continue;
7064 7093
7065 if (count > 1) 7094 if (count > 1)
@@ -7067,7 +7096,7 @@ tiff_load (struct frame *f, struct image *img)
7067 Fcons (make_number (count), 7096 Fcons (make_number (count),
7068 img->lisp_data)); 7097 img->lisp_data));
7069 7098
7070 fn_TIFFClose (tiff); 7099 TIFFClose (tiff);
7071 if (!rc) 7100 if (!rc)
7072 { 7101 {
7073 image_error ("Error reading TIFF image `%s'", img->spec, Qnil); 7102 image_error ("Error reading TIFF image `%s'", img->spec, Qnil);
@@ -7093,11 +7122,11 @@ tiff_load (struct frame *f, struct image *img)
7093 } 7122 }
7094 } 7123 }
7095 7124
7096#ifdef COLOR_TABLE_SUPPORT 7125# ifdef COLOR_TABLE_SUPPORT
7097 /* Remember the colors allocated for the image. Free the color table. */ 7126 /* Remember the colors allocated for the image. Free the color table. */
7098 img->colors = colors_in_color_table (&img->ncolors); 7127 img->colors = colors_in_color_table (&img->ncolors);
7099 free_color_table (); 7128 free_color_table ();
7100#endif /* COLOR_TABLE_SUPPORT */ 7129# endif /* COLOR_TABLE_SUPPORT */
7101 7130
7102 img->width = width; 7131 img->width = width;
7103 img->height = height; 7132 img->height = height;
@@ -7114,9 +7143,8 @@ tiff_load (struct frame *f, struct image *img)
7114 return 1; 7143 return 1;
7115} 7144}
7116 7145
7117#else /* HAVE_TIFF */ 7146#elif defined HAVE_NS
7118 7147
7119#ifdef HAVE_NS
7120static bool 7148static bool
7121tiff_load (struct frame *f, struct image *img) 7149tiff_load (struct frame *f, struct image *img)
7122{ 7150{
@@ -7124,9 +7152,8 @@ tiff_load (struct frame *f, struct image *img)
7124 image_spec_value (img->spec, QCfile, NULL), 7152 image_spec_value (img->spec, QCfile, NULL),
7125 image_spec_value (img->spec, QCdata, NULL)); 7153 image_spec_value (img->spec, QCdata, NULL));
7126} 7154}
7127#endif /* HAVE_NS */
7128 7155
7129#endif /* !HAVE_TIFF */ 7156#endif
7130 7157
7131 7158
7132 7159
@@ -7226,54 +7253,54 @@ gif_image_p (Lisp_Object object)
7226 7253
7227#ifdef HAVE_GIF 7254#ifdef HAVE_GIF
7228 7255
7229#if defined (HAVE_NTGUI) 7256# ifdef HAVE_NTGUI
7230 7257
7231/* winuser.h might define DrawText to DrawTextA or DrawTextW. 7258/* winuser.h might define DrawText to DrawTextA or DrawTextW.
7232 Undefine before redefining to avoid a preprocessor warning. */ 7259 Undefine before redefining to avoid a preprocessor warning. */
7233#ifdef DrawText 7260# ifdef DrawText
7234#undef DrawText 7261# undef DrawText
7235#endif 7262# endif
7236/* avoid conflict with QuickdrawText.h */ 7263/* avoid conflict with QuickdrawText.h */
7237#define DrawText gif_DrawText 7264# define DrawText gif_DrawText
7238#include <gif_lib.h> 7265# include <gif_lib.h>
7239#undef DrawText 7266# undef DrawText
7240 7267
7241/* Giflib before 5.0 didn't define these macros (used only if HAVE_NTGUI). */ 7268/* Giflib before 5.0 didn't define these macros (used only if HAVE_NTGUI). */
7242#ifndef GIFLIB_MINOR 7269# ifndef GIFLIB_MINOR
7243#define GIFLIB_MINOR 0 7270# define GIFLIB_MINOR 0
7244#endif 7271# endif
7245#ifndef GIFLIB_RELEASE 7272# ifndef GIFLIB_RELEASE
7246#define GIFLIB_RELEASE 0 7273# define GIFLIB_RELEASE 0
7247#endif 7274# endif
7248 7275
7249#else /* HAVE_NTGUI */ 7276# else /* HAVE_NTGUI */
7250 7277
7251#include <gif_lib.h> 7278# include <gif_lib.h>
7252 7279
7253#endif /* HAVE_NTGUI */ 7280# endif /* HAVE_NTGUI */
7254 7281
7255/* Giflib before 5.0 didn't define these macros. */ 7282/* Giflib before 5.0 didn't define these macros. */
7256#ifndef GIFLIB_MAJOR 7283# ifndef GIFLIB_MAJOR
7257#define GIFLIB_MAJOR 4 7284# define GIFLIB_MAJOR 4
7258#endif 7285# endif
7259 7286
7260#ifdef WINDOWSNT 7287# ifdef WINDOWSNT
7261 7288
7262/* GIF library details. */ 7289/* GIF library details. */
7263#if 5 < GIFLIB_MAJOR + (1 <= GIFLIB_MINOR) 7290# if 5 < GIFLIB_MAJOR + (1 <= GIFLIB_MINOR)
7264DEF_IMGLIB_FN (int, DGifCloseFile, (GifFileType *, int *)); 7291DEF_DLL_FN (int, DGifCloseFile, (GifFileType *, int *));
7265#else 7292# else
7266DEF_IMGLIB_FN (int, DGifCloseFile, (GifFileType *)); 7293DEF_DLL_FN (int, DGifCloseFile, (GifFileType *));
7267#endif 7294# endif
7268DEF_IMGLIB_FN (int, DGifSlurp, (GifFileType *)); 7295DEF_DLL_FN (int, DGifSlurp, (GifFileType *));
7269#if GIFLIB_MAJOR < 5 7296# if GIFLIB_MAJOR < 5
7270DEF_IMGLIB_FN (GifFileType *, DGifOpen, (void *, InputFunc)); 7297DEF_DLL_FN (GifFileType *, DGifOpen, (void *, InputFunc));
7271DEF_IMGLIB_FN (GifFileType *, DGifOpenFileName, (const char *)); 7298DEF_DLL_FN (GifFileType *, DGifOpenFileName, (const char *));
7272#else 7299# else
7273DEF_IMGLIB_FN (GifFileType *, DGifOpen, (void *, InputFunc, int *)); 7300DEF_DLL_FN (GifFileType *, DGifOpen, (void *, InputFunc, int *));
7274DEF_IMGLIB_FN (GifFileType *, DGifOpenFileName, (const char *, int *)); 7301DEF_DLL_FN (GifFileType *, DGifOpenFileName, (const char *, int *));
7275DEF_IMGLIB_FN (char *, GifErrorString, (int)); 7302DEF_DLL_FN (char *, GifErrorString, (int));
7276#endif 7303# endif
7277 7304
7278static bool 7305static bool
7279init_gif_functions (void) 7306init_gif_functions (void)
@@ -7283,27 +7310,29 @@ init_gif_functions (void)
7283 if (!(library = w32_delayed_load (Qgif))) 7310 if (!(library = w32_delayed_load (Qgif)))
7284 return 0; 7311 return 0;
7285 7312
7286 LOAD_IMGLIB_FN (library, DGifCloseFile); 7313 LOAD_DLL_FN (library, DGifCloseFile);
7287 LOAD_IMGLIB_FN (library, DGifSlurp); 7314 LOAD_DLL_FN (library, DGifSlurp);
7288 LOAD_IMGLIB_FN (library, DGifOpen); 7315 LOAD_DLL_FN (library, DGifOpen);
7289 LOAD_IMGLIB_FN (library, DGifOpenFileName); 7316 LOAD_DLL_FN (library, DGifOpenFileName);
7290#if GIFLIB_MAJOR >= 5 7317# if GIFLIB_MAJOR >= 5
7291 LOAD_IMGLIB_FN (library, GifErrorString); 7318 LOAD_DLL_FN (library, GifErrorString);
7292#endif 7319# endif
7293 return 1; 7320 return 1;
7294} 7321}
7295 7322
7296#else 7323# undef DGifCloseFile
7324# undef DGifOpen
7325# undef DGifOpenFileName
7326# undef DGifSlurp
7327# undef GifErrorString
7297 7328
7298#define fn_DGifCloseFile DGifCloseFile 7329# define DGifCloseFile fn_DGifCloseFile
7299#define fn_DGifSlurp DGifSlurp 7330# define DGifOpen fn_DGifOpen
7300#define fn_DGifOpen DGifOpen 7331# define DGifOpenFileName fn_DGifOpenFileName
7301#define fn_DGifOpenFileName DGifOpenFileName 7332# define DGifSlurp fn_DGifSlurp
7302#if 5 <= GIFLIB_MAJOR 7333# define GifErrorString fn_GifErrorString
7303# define fn_GifErrorString GifErrorString
7304#endif
7305 7334
7306#endif /* WINDOWSNT */ 7335# endif /* WINDOWSNT */
7307 7336
7308/* Reading a GIF image from memory 7337/* Reading a GIF image from memory
7309 Based on the PNG memory stuff to a certain extent. */ 7338 Based on the PNG memory stuff to a certain extent. */
@@ -7340,9 +7369,9 @@ gif_close (GifFileType *gif, int *err)
7340 int retval; 7369 int retval;
7341 7370
7342#if 5 < GIFLIB_MAJOR + (1 <= GIFLIB_MINOR) 7371#if 5 < GIFLIB_MAJOR + (1 <= GIFLIB_MINOR)
7343 retval = fn_DGifCloseFile (gif, err); 7372 retval = DGifCloseFile (gif, err);
7344#else 7373#else
7345 retval = fn_DGifCloseFile (gif); 7374 retval = DGifCloseFile (gif);
7346#if GIFLIB_MAJOR >= 5 7375#if GIFLIB_MAJOR >= 5
7347 if (err) 7376 if (err)
7348 *err = gif->Error; 7377 *err = gif->Error;
@@ -7390,18 +7419,18 @@ gif_load (struct frame *f, struct image *img)
7390 7419
7391 /* Open the GIF file. */ 7420 /* Open the GIF file. */
7392#if GIFLIB_MAJOR < 5 7421#if GIFLIB_MAJOR < 5
7393 gif = fn_DGifOpenFileName (SSDATA (file)); 7422 gif = DGifOpenFileName (SSDATA (file));
7394 if (gif == NULL) 7423 if (gif == NULL)
7395 { 7424 {
7396 image_error ("Cannot open `%s'", file, Qnil); 7425 image_error ("Cannot open `%s'", file, Qnil);
7397 return 0; 7426 return 0;
7398 } 7427 }
7399#else 7428#else
7400 gif = fn_DGifOpenFileName (SSDATA (file), &gif_err); 7429 gif = DGifOpenFileName (SSDATA (file), &gif_err);
7401 if (gif == NULL) 7430 if (gif == NULL)
7402 { 7431 {
7403 image_error ("Cannot open `%s': %s", 7432 image_error ("Cannot open `%s': %s",
7404 file, build_string (fn_GifErrorString (gif_err))); 7433 file, build_string (GifErrorString (gif_err)));
7405 return 0; 7434 return 0;
7406 } 7435 }
7407#endif 7436#endif
@@ -7421,18 +7450,18 @@ gif_load (struct frame *f, struct image *img)
7421 memsrc.index = 0; 7450 memsrc.index = 0;
7422 7451
7423#if GIFLIB_MAJOR < 5 7452#if GIFLIB_MAJOR < 5
7424 gif = fn_DGifOpen (&memsrc, gif_read_from_memory); 7453 gif = DGifOpen (&memsrc, gif_read_from_memory);
7425 if (!gif) 7454 if (!gif)
7426 { 7455 {
7427 image_error ("Cannot open memory source `%s'", img->spec, Qnil); 7456 image_error ("Cannot open memory source `%s'", img->spec, Qnil);
7428 return 0; 7457 return 0;
7429 } 7458 }
7430#else 7459#else
7431 gif = fn_DGifOpen (&memsrc, gif_read_from_memory, &gif_err); 7460 gif = DGifOpen (&memsrc, gif_read_from_memory, &gif_err);
7432 if (!gif) 7461 if (!gif)
7433 { 7462 {
7434 image_error ("Cannot open memory source `%s': %s", 7463 image_error ("Cannot open memory source `%s': %s",
7435 img->spec, build_string (fn_GifErrorString (gif_err))); 7464 img->spec, build_string (GifErrorString (gif_err)));
7436 return 0; 7465 return 0;
7437 } 7466 }
7438#endif 7467#endif
@@ -7447,7 +7476,7 @@ gif_load (struct frame *f, struct image *img)
7447 } 7476 }
7448 7477
7449 /* Read entire contents. */ 7478 /* Read entire contents. */
7450 rc = fn_DGifSlurp (gif); 7479 rc = DGifSlurp (gif);
7451 if (rc == GIF_ERROR || gif->ImageCount <= 0) 7480 if (rc == GIF_ERROR || gif->ImageCount <= 0)
7452 { 7481 {
7453 image_error ("Error reading `%s'", img->spec, Qnil); 7482 image_error ("Error reading `%s'", img->spec, Qnil);
@@ -7681,7 +7710,7 @@ gif_load (struct frame *f, struct image *img)
7681 if (gif_close (gif, &gif_err) == GIF_ERROR) 7710 if (gif_close (gif, &gif_err) == GIF_ERROR)
7682 { 7711 {
7683#if 5 <= GIFLIB_MAJOR 7712#if 5 <= GIFLIB_MAJOR
7684 char *error_text = fn_GifErrorString (gif_err); 7713 char *error_text = GifErrorString (gif_err);
7685 7714
7686 if (error_text) 7715 if (error_text)
7687 image_error ("Error closing `%s': %s", 7716 image_error ("Error closing `%s': %s",
@@ -8593,7 +8622,7 @@ and `imagemagick-types-inhibit'. */)
8593 SVG 8622 SVG
8594 ***********************************************************************/ 8623 ***********************************************************************/
8595 8624
8596#if defined (HAVE_RSVG) 8625#ifdef HAVE_RSVG
8597 8626
8598/* Function prototypes. */ 8627/* Function prototypes. */
8599 8628
@@ -8641,11 +8670,11 @@ static const struct image_keyword svg_format[SVG_LAST] =
8641 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} 8670 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}
8642}; 8671};
8643 8672
8644#if defined HAVE_NTGUI && defined WINDOWSNT 8673# if defined HAVE_NTGUI && defined WINDOWSNT
8645static bool init_svg_functions (void); 8674static bool init_svg_functions (void);
8646#else 8675# else
8647#define init_svg_functions NULL 8676#define init_svg_functions NULL
8648#endif 8677# endif
8649 8678
8650/* Structure describing the image type `svg'. Its the same type of 8679/* Structure describing the image type `svg'. Its the same type of
8651 structure defined for all image formats, handled by emacs image 8680 structure defined for all image formats, handled by emacs image
@@ -8679,32 +8708,34 @@ svg_image_p (Lisp_Object object)
8679 return fmt[SVG_FILE].count + fmt[SVG_DATA].count == 1; 8708 return fmt[SVG_FILE].count + fmt[SVG_DATA].count == 1;
8680} 8709}
8681 8710
8682#include <librsvg/rsvg.h> 8711# include <librsvg/rsvg.h>
8683 8712
8684#ifdef WINDOWSNT 8713# ifdef WINDOWSNT
8685 8714
8686/* SVG library functions. */ 8715/* SVG library functions. */
8687DEF_IMGLIB_FN (RsvgHandle *, rsvg_handle_new, (void)); 8716DEF_DLL_FN (RsvgHandle *, rsvg_handle_new, (void));
8688DEF_IMGLIB_FN (void, rsvg_handle_get_dimensions, (RsvgHandle *, RsvgDimensionData *)); 8717DEF_DLL_FN (void, rsvg_handle_get_dimensions,
8689DEF_IMGLIB_FN (gboolean, rsvg_handle_write, (RsvgHandle *, const guchar *, gsize, GError **)); 8718 (RsvgHandle *, RsvgDimensionData *));
8690DEF_IMGLIB_FN (gboolean, rsvg_handle_close, (RsvgHandle *, GError **)); 8719DEF_DLL_FN (gboolean, rsvg_handle_write,
8691DEF_IMGLIB_FN (GdkPixbuf *, rsvg_handle_get_pixbuf, (RsvgHandle *)); 8720 (RsvgHandle *, const guchar *, gsize, GError **));
8692DEF_IMGLIB_FN (void, rsvg_handle_set_base_uri, (RsvgHandle *, const char *)); 8721DEF_DLL_FN (gboolean, rsvg_handle_close, (RsvgHandle *, GError **));
8693 8722DEF_DLL_FN (GdkPixbuf *, rsvg_handle_get_pixbuf, (RsvgHandle *));
8694DEF_IMGLIB_FN (int, gdk_pixbuf_get_width, (const GdkPixbuf *)); 8723DEF_DLL_FN (void, rsvg_handle_set_base_uri, (RsvgHandle *, const char *));
8695DEF_IMGLIB_FN (int, gdk_pixbuf_get_height, (const GdkPixbuf *)); 8724
8696DEF_IMGLIB_FN (guchar *, gdk_pixbuf_get_pixels, (const GdkPixbuf *)); 8725DEF_DLL_FN (int, gdk_pixbuf_get_width, (const GdkPixbuf *));
8697DEF_IMGLIB_FN (int, gdk_pixbuf_get_rowstride, (const GdkPixbuf *)); 8726DEF_DLL_FN (int, gdk_pixbuf_get_height, (const GdkPixbuf *));
8698DEF_IMGLIB_FN (GdkColorspace, gdk_pixbuf_get_colorspace, (const GdkPixbuf *)); 8727DEF_DLL_FN (guchar *, gdk_pixbuf_get_pixels, (const GdkPixbuf *));
8699DEF_IMGLIB_FN (int, gdk_pixbuf_get_n_channels, (const GdkPixbuf *)); 8728DEF_DLL_FN (int, gdk_pixbuf_get_rowstride, (const GdkPixbuf *));
8700DEF_IMGLIB_FN (gboolean, gdk_pixbuf_get_has_alpha, (const GdkPixbuf *)); 8729DEF_DLL_FN (GdkColorspace, gdk_pixbuf_get_colorspace, (const GdkPixbuf *));
8701DEF_IMGLIB_FN (int, gdk_pixbuf_get_bits_per_sample, (const GdkPixbuf *)); 8730DEF_DLL_FN (int, gdk_pixbuf_get_n_channels, (const GdkPixbuf *));
8702 8731DEF_DLL_FN (gboolean, gdk_pixbuf_get_has_alpha, (const GdkPixbuf *));
8703#if ! GLIB_CHECK_VERSION (2, 36, 0) 8732DEF_DLL_FN (int, gdk_pixbuf_get_bits_per_sample, (const GdkPixbuf *));
8704DEF_IMGLIB_FN (void, g_type_init, (void)); 8733
8705#endif 8734# if ! GLIB_CHECK_VERSION (2, 36, 0)
8706DEF_IMGLIB_FN (void, g_object_unref, (gpointer)); 8735DEF_DLL_FN (void, g_type_init, (void));
8707DEF_IMGLIB_FN (void, g_error_free, (GError *)); 8736# endif
8737DEF_DLL_FN (void, g_object_unref, (gpointer));
8738DEF_DLL_FN (void, g_error_free, (GError *));
8708 8739
8709Lisp_Object Qgdk_pixbuf, Qglib, Qgobject; 8740Lisp_Object Qgdk_pixbuf, Qglib, Qgobject;
8710 8741
@@ -8724,56 +8755,71 @@ init_svg_functions (void)
8724 return 0; 8755 return 0;
8725 } 8756 }
8726 8757
8727 LOAD_IMGLIB_FN (library, rsvg_handle_new); 8758 LOAD_DLL_FN (library, rsvg_handle_new);
8728 LOAD_IMGLIB_FN (library, rsvg_handle_get_dimensions); 8759 LOAD_DLL_FN (library, rsvg_handle_get_dimensions);
8729 LOAD_IMGLIB_FN (library, rsvg_handle_write); 8760 LOAD_DLL_FN (library, rsvg_handle_write);
8730 LOAD_IMGLIB_FN (library, rsvg_handle_close); 8761 LOAD_DLL_FN (library, rsvg_handle_close);
8731 LOAD_IMGLIB_FN (library, rsvg_handle_get_pixbuf); 8762 LOAD_DLL_FN (library, rsvg_handle_get_pixbuf);
8732 LOAD_IMGLIB_FN (library, rsvg_handle_set_base_uri); 8763 LOAD_DLL_FN (library, rsvg_handle_set_base_uri);
8733 8764
8734 LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_width); 8765 LOAD_DLL_FN (gdklib, gdk_pixbuf_get_width);
8735 LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_height); 8766 LOAD_DLL_FN (gdklib, gdk_pixbuf_get_height);
8736 LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_pixels); 8767 LOAD_DLL_FN (gdklib, gdk_pixbuf_get_pixels);
8737 LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_rowstride); 8768 LOAD_DLL_FN (gdklib, gdk_pixbuf_get_rowstride);
8738 LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_colorspace); 8769 LOAD_DLL_FN (gdklib, gdk_pixbuf_get_colorspace);
8739 LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_n_channels); 8770 LOAD_DLL_FN (gdklib, gdk_pixbuf_get_n_channels);
8740 LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_has_alpha); 8771 LOAD_DLL_FN (gdklib, gdk_pixbuf_get_has_alpha);
8741 LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_bits_per_sample); 8772 LOAD_DLL_FN (gdklib, gdk_pixbuf_get_bits_per_sample);
8742 8773
8743#if ! GLIB_CHECK_VERSION (2, 36, 0) 8774# if ! GLIB_CHECK_VERSION (2, 36, 0)
8744 LOAD_IMGLIB_FN (gobject, g_type_init); 8775 LOAD_DLL_FN (gobject, g_type_init);
8745#endif 8776# endif
8746 LOAD_IMGLIB_FN (gobject, g_object_unref); 8777 LOAD_DLL_FN (gobject, g_object_unref);
8747 LOAD_IMGLIB_FN (glib, g_error_free); 8778 LOAD_DLL_FN (glib, g_error_free);
8748 8779
8749 return 1; 8780 return 1;
8750} 8781}
8751 8782
8752#else
8753/* The following aliases for library functions allow dynamic loading 8783/* The following aliases for library functions allow dynamic loading
8754 to be used on some platforms. */ 8784 to be used on some platforms. */
8755#define fn_rsvg_handle_new rsvg_handle_new
8756#define fn_rsvg_handle_get_dimensions rsvg_handle_get_dimensions
8757#define fn_rsvg_handle_write rsvg_handle_write
8758#define fn_rsvg_handle_close rsvg_handle_close
8759#define fn_rsvg_handle_get_pixbuf rsvg_handle_get_pixbuf
8760#define fn_rsvg_handle_set_base_uri rsvg_handle_set_base_uri
8761
8762#define fn_gdk_pixbuf_get_width gdk_pixbuf_get_width
8763#define fn_gdk_pixbuf_get_height gdk_pixbuf_get_height
8764#define fn_gdk_pixbuf_get_pixels gdk_pixbuf_get_pixels
8765#define fn_gdk_pixbuf_get_rowstride gdk_pixbuf_get_rowstride
8766#define fn_gdk_pixbuf_get_colorspace gdk_pixbuf_get_colorspace
8767#define fn_gdk_pixbuf_get_n_channels gdk_pixbuf_get_n_channels
8768#define fn_gdk_pixbuf_get_has_alpha gdk_pixbuf_get_has_alpha
8769#define fn_gdk_pixbuf_get_bits_per_sample gdk_pixbuf_get_bits_per_sample
8770 8785
8771#if ! GLIB_CHECK_VERSION (2, 36, 0) 8786# undef gdk_pixbuf_get_bits_per_sample
8772#define fn_g_type_init g_type_init 8787# undef gdk_pixbuf_get_colorspace
8773#endif 8788# undef gdk_pixbuf_get_has_alpha
8774#define fn_g_object_unref g_object_unref 8789# undef gdk_pixbuf_get_height
8775#define fn_g_error_free g_error_free 8790# undef gdk_pixbuf_get_n_channels
8776#endif /* !WINDOWSNT */ 8791# undef gdk_pixbuf_get_pixels
8792# undef gdk_pixbuf_get_rowstride
8793# undef gdk_pixbuf_get_width
8794# undef g_error_free
8795# undef g_object_unref
8796# undef g_type_init
8797# undef rsvg_handle_close
8798# undef rsvg_handle_get_dimensions
8799# undef rsvg_handle_get_pixbuf
8800# undef rsvg_handle_new
8801# undef rsvg_handle_set_base_uri
8802# undef rsvg_handle_write
8803
8804# define gdk_pixbuf_get_bits_per_sample fn_gdk_pixbuf_get_bits_per_sample
8805# define gdk_pixbuf_get_colorspace fn_gdk_pixbuf_get_colorspace
8806# define gdk_pixbuf_get_has_alpha fn_gdk_pixbuf_get_has_alpha
8807# define gdk_pixbuf_get_height fn_gdk_pixbuf_get_height
8808# define gdk_pixbuf_get_n_channels fn_gdk_pixbuf_get_n_channels
8809# define gdk_pixbuf_get_pixels fn_gdk_pixbuf_get_pixels
8810# define gdk_pixbuf_get_rowstride fn_gdk_pixbuf_get_rowstride
8811# define gdk_pixbuf_get_width fn_gdk_pixbuf_get_width
8812# define g_error_free fn_g_error_free
8813# define g_object_unref fn_g_object_unref
8814# define g_type_init fn_g_type_init
8815# define rsvg_handle_close fn_rsvg_handle_close
8816# define rsvg_handle_get_dimensions fn_rsvg_handle_get_dimensions
8817# define rsvg_handle_get_pixbuf fn_rsvg_handle_get_pixbuf
8818# define rsvg_handle_new fn_rsvg_handle_new
8819# define rsvg_handle_set_base_uri fn_rsvg_handle_set_base_uri
8820# define rsvg_handle_write fn_rsvg_handle_write
8821
8822# endif /* !WINDOWSNT */
8777 8823
8778/* Load SVG image IMG for use on frame F. Value is true if 8824/* Load SVG image IMG for use on frame F. Value is true if
8779 successful. */ 8825 successful. */
@@ -8862,28 +8908,28 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
8862#if ! GLIB_CHECK_VERSION (2, 36, 0) 8908#if ! GLIB_CHECK_VERSION (2, 36, 0)
8863 /* g_type_init is a glib function that must be called prior to 8909 /* g_type_init is a glib function that must be called prior to
8864 using gnome type library functions (obsolete since 2.36.0). */ 8910 using gnome type library functions (obsolete since 2.36.0). */
8865 fn_g_type_init (); 8911 g_type_init ();
8866#endif 8912#endif
8867 8913
8868 /* Make a handle to a new rsvg object. */ 8914 /* Make a handle to a new rsvg object. */
8869 rsvg_handle = fn_rsvg_handle_new (); 8915 rsvg_handle = rsvg_handle_new ();
8870 8916
8871 /* Set base_uri for properly handling referenced images (via 'href'). 8917 /* Set base_uri for properly handling referenced images (via 'href').
8872 See rsvg bug 596114 - "image refs are relative to curdir, not .svg file" 8918 See rsvg bug 596114 - "image refs are relative to curdir, not .svg file"
8873 (https://bugzilla.gnome.org/show_bug.cgi?id=596114). */ 8919 (https://bugzilla.gnome.org/show_bug.cgi?id=596114). */
8874 if (filename) 8920 if (filename)
8875 fn_rsvg_handle_set_base_uri(rsvg_handle, filename); 8921 rsvg_handle_set_base_uri(rsvg_handle, filename);
8876 8922
8877 /* Parse the contents argument and fill in the rsvg_handle. */ 8923 /* Parse the contents argument and fill in the rsvg_handle. */
8878 fn_rsvg_handle_write (rsvg_handle, contents, size, &err); 8924 rsvg_handle_write (rsvg_handle, contents, size, &err);
8879 if (err) goto rsvg_error; 8925 if (err) goto rsvg_error;
8880 8926
8881 /* The parsing is complete, rsvg_handle is ready to used, close it 8927 /* The parsing is complete, rsvg_handle is ready to used, close it
8882 for further writes. */ 8928 for further writes. */
8883 fn_rsvg_handle_close (rsvg_handle, &err); 8929 rsvg_handle_close (rsvg_handle, &err);
8884 if (err) goto rsvg_error; 8930 if (err) goto rsvg_error;
8885 8931
8886 fn_rsvg_handle_get_dimensions (rsvg_handle, &dimension_data); 8932 rsvg_handle_get_dimensions (rsvg_handle, &dimension_data);
8887 if (! check_image_size (f, dimension_data.width, dimension_data.height)) 8933 if (! check_image_size (f, dimension_data.width, dimension_data.height))
8888 { 8934 {
8889 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 8935 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
@@ -8892,26 +8938,26 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
8892 8938
8893 /* We can now get a valid pixel buffer from the svg file, if all 8939 /* We can now get a valid pixel buffer from the svg file, if all
8894 went ok. */ 8940 went ok. */
8895 pixbuf = fn_rsvg_handle_get_pixbuf (rsvg_handle); 8941 pixbuf = rsvg_handle_get_pixbuf (rsvg_handle);
8896 if (!pixbuf) goto rsvg_error; 8942 if (!pixbuf) goto rsvg_error;
8897 fn_g_object_unref (rsvg_handle); 8943 g_object_unref (rsvg_handle);
8898 8944
8899 /* Extract some meta data from the svg handle. */ 8945 /* Extract some meta data from the svg handle. */
8900 width = fn_gdk_pixbuf_get_width (pixbuf); 8946 width = gdk_pixbuf_get_width (pixbuf);
8901 height = fn_gdk_pixbuf_get_height (pixbuf); 8947 height = gdk_pixbuf_get_height (pixbuf);
8902 pixels = fn_gdk_pixbuf_get_pixels (pixbuf); 8948 pixels = gdk_pixbuf_get_pixels (pixbuf);
8903 rowstride = fn_gdk_pixbuf_get_rowstride (pixbuf); 8949 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
8904 8950
8905 /* Validate the svg meta data. */ 8951 /* Validate the svg meta data. */
8906 eassert (fn_gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB); 8952 eassert (gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB);
8907 eassert (fn_gdk_pixbuf_get_n_channels (pixbuf) == 4); 8953 eassert (gdk_pixbuf_get_n_channels (pixbuf) == 4);
8908 eassert (fn_gdk_pixbuf_get_has_alpha (pixbuf)); 8954 eassert (gdk_pixbuf_get_has_alpha (pixbuf));
8909 eassert (fn_gdk_pixbuf_get_bits_per_sample (pixbuf) == 8); 8955 eassert (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8);
8910 8956
8911 /* Try to create a x pixmap to hold the svg pixmap. */ 8957 /* Try to create a x pixmap to hold the svg pixmap. */
8912 if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0)) 8958 if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0))
8913 { 8959 {
8914 fn_g_object_unref (pixbuf); 8960 g_object_unref (pixbuf);
8915 return 0; 8961 return 0;
8916 } 8962 }
8917 8963
@@ -8968,7 +9014,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
8968 free_color_table (); 9014 free_color_table ();
8969#endif /* COLOR_TABLE_SUPPORT */ 9015#endif /* COLOR_TABLE_SUPPORT */
8970 9016
8971 fn_g_object_unref (pixbuf); 9017 g_object_unref (pixbuf);
8972 9018
8973 img->width = width; 9019 img->width = width;
8974 img->height = height; 9020 img->height = height;
@@ -8983,11 +9029,11 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
8983 return 1; 9029 return 1;
8984 9030
8985 rsvg_error: 9031 rsvg_error:
8986 fn_g_object_unref (rsvg_handle); 9032 g_object_unref (rsvg_handle);
8987 /* FIXME: Use error->message so the user knows what is the actual 9033 /* FIXME: Use error->message so the user knows what is the actual
8988 problem with the image. */ 9034 problem with the image. */
8989 image_error ("Error parsing SVG image `%s'", img->spec, Qnil); 9035 image_error ("Error parsing SVG image `%s'", img->spec, Qnil);
8990 fn_g_error_free (err); 9036 g_error_free (err);
8991 return 0; 9037 return 0;
8992} 9038}
8993 9039