aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
authorGlenn Morris2014-06-21 12:45:59 -0700
committerGlenn Morris2014-06-21 12:45:59 -0700
commitc400516ab1d827d08225ffb3e1bc1969c73cc45e (patch)
treeb16343b9e11c916c96b12ab56b6024cad91d3aff /src/image.c
parent539ad293eb36b4cf458cbdb5a6b37f5cd1bb68a1 (diff)
parent8047f439ec7d0bbe0085800a13bee8da883ae4dd (diff)
downloademacs-c400516ab1d827d08225ffb3e1bc1969c73cc45e.tar.gz
emacs-c400516ab1d827d08225ffb3e1bc1969c73cc45e.zip
Merge from emacs-24; up to 2014-06-06T02:22:40Z!monnier@iro.umontreal.ca
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c47
1 files changed, 38 insertions, 9 deletions
diff --git a/src/image.c b/src/image.c
index 3220a45a282..f8c2402bfc4 100644
--- a/src/image.c
+++ b/src/image.c
@@ -7250,7 +7250,11 @@ gif_image_p (Lisp_Object object)
7250#ifdef WINDOWSNT 7250#ifdef WINDOWSNT
7251 7251
7252/* GIF library details. */ 7252/* GIF library details. */
7253#if 5 < GIFLIB_MAJOR + (1 <= GIFLIB_MINOR)
7254DEF_IMGLIB_FN (int, DGifCloseFile, (GifFileType *, int *));
7255#else
7253DEF_IMGLIB_FN (int, DGifCloseFile, (GifFileType *)); 7256DEF_IMGLIB_FN (int, DGifCloseFile, (GifFileType *));
7257#endif
7254DEF_IMGLIB_FN (int, DGifSlurp, (GifFileType *)); 7258DEF_IMGLIB_FN (int, DGifSlurp, (GifFileType *));
7255#if GIFLIB_MAJOR < 5 7259#if GIFLIB_MAJOR < 5
7256DEF_IMGLIB_FN (GifFileType *, DGifOpen, (void *, InputFunc)); 7260DEF_IMGLIB_FN (GifFileType *, DGifOpen, (void *, InputFunc));
@@ -7320,6 +7324,22 @@ gif_read_from_memory (GifFileType *file, GifByteType *buf, int len)
7320 return len; 7324 return len;
7321} 7325}
7322 7326
7327static int
7328gif_close (GifFileType *gif, int *err)
7329{
7330 int retval;
7331
7332#if 5 < GIFLIB_MAJOR + (1 <= GIFLIB_MINOR)
7333 retval = fn_DGifCloseFile (gif, err);
7334#else
7335 retval = fn_DGifCloseFile (gif);
7336#if GIFLIB_MAJOR >= 5
7337 if (err)
7338 *err = gif->Error;
7339#endif
7340#endif
7341 return retval;
7342}
7323 7343
7324/* Load GIF image IMG for use on frame F. Value is true if 7344/* Load GIF image IMG for use on frame F. Value is true if
7325 successful. */ 7345 successful. */
@@ -7344,9 +7364,7 @@ gif_load (struct frame *f, struct image *img)
7344 Lisp_Object specified_data = image_spec_value (img->spec, QCdata, NULL); 7364 Lisp_Object specified_data = image_spec_value (img->spec, QCdata, NULL);
7345 unsigned long bgcolor = 0; 7365 unsigned long bgcolor = 0;
7346 EMACS_INT idx; 7366 EMACS_INT idx;
7347#if GIFLIB_MAJOR >= 5
7348 int gif_err; 7367 int gif_err;
7349#endif
7350 7368
7351 if (NILP (specified_data)) 7369 if (NILP (specified_data))
7352 { 7370 {
@@ -7414,7 +7432,7 @@ gif_load (struct frame *f, struct image *img)
7414 if (!check_image_size (f, gif->SWidth, gif->SHeight)) 7432 if (!check_image_size (f, gif->SWidth, gif->SHeight))
7415 { 7433 {
7416 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 7434 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
7417 fn_DGifCloseFile (gif); 7435 gif_close (gif, NULL);
7418 return 0; 7436 return 0;
7419 } 7437 }
7420 7438
@@ -7423,7 +7441,7 @@ gif_load (struct frame *f, struct image *img)
7423 if (rc == GIF_ERROR || gif->ImageCount <= 0) 7441 if (rc == GIF_ERROR || gif->ImageCount <= 0)
7424 { 7442 {
7425 image_error ("Error reading `%s'", img->spec, Qnil); 7443 image_error ("Error reading `%s'", img->spec, Qnil);
7426 fn_DGifCloseFile (gif); 7444 gif_close (gif, NULL);
7427 return 0; 7445 return 0;
7428 } 7446 }
7429 7447
@@ -7435,7 +7453,7 @@ gif_load (struct frame *f, struct image *img)
7435 { 7453 {
7436 image_error ("Invalid image number `%s' in image `%s'", 7454 image_error ("Invalid image number `%s' in image `%s'",
7437 image_number, img->spec); 7455 image_number, img->spec);
7438 fn_DGifCloseFile (gif); 7456 gif_close (gif, NULL);
7439 return 0; 7457 return 0;
7440 } 7458 }
7441 } 7459 }
@@ -7453,7 +7471,7 @@ gif_load (struct frame *f, struct image *img)
7453 if (!check_image_size (f, width, height)) 7471 if (!check_image_size (f, width, height))
7454 { 7472 {
7455 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 7473 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
7456 fn_DGifCloseFile (gif); 7474 gif_close (gif, NULL);
7457 return 0; 7475 return 0;
7458 } 7476 }
7459 7477
@@ -7471,7 +7489,7 @@ gif_load (struct frame *f, struct image *img)
7471 && 0 <= subimg_left && subimg_left <= width - subimg_width)) 7489 && 0 <= subimg_left && subimg_left <= width - subimg_width))
7472 { 7490 {
7473 image_error ("Subimage does not fit in image", Qnil, Qnil); 7491 image_error ("Subimage does not fit in image", Qnil, Qnil);
7474 fn_DGifCloseFile (gif); 7492 gif_close (gif, NULL);
7475 return 0; 7493 return 0;
7476 } 7494 }
7477 } 7495 }
@@ -7479,7 +7497,7 @@ gif_load (struct frame *f, struct image *img)
7479 /* Create the X image and pixmap. */ 7497 /* Create the X image and pixmap. */
7480 if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0)) 7498 if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0))
7481 { 7499 {
7482 fn_DGifCloseFile (gif); 7500 gif_close (gif, NULL);
7483 return 0; 7501 return 0;
7484 } 7502 }
7485 7503
@@ -7650,7 +7668,18 @@ gif_load (struct frame *f, struct image *img)
7650 Fcons (make_number (gif->ImageCount), 7668 Fcons (make_number (gif->ImageCount),
7651 img->lisp_data)); 7669 img->lisp_data));
7652 7670
7653 fn_DGifCloseFile (gif); 7671 if (gif_close (gif, &gif_err) == GIF_ERROR)
7672 {
7673#if 5 <= GIFLIB_MAJOR
7674 char *error_text = fn_GifErrorString (gif_err);
7675
7676 if (error_text)
7677 image_error ("Error closing `%s': %s",
7678 img->spec, build_string (error_text));
7679#else
7680 image_error ("Error closing `%s'", img->spec, Qnil);
7681#endif
7682 }
7654 7683
7655 /* Maybe fill in the background field while we have ximg handy. */ 7684 /* Maybe fill in the background field while we have ximg handy. */
7656 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 7685 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))