aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Rumney2008-08-23 03:48:06 +0000
committerJason Rumney2008-08-23 03:48:06 +0000
commit5827950329afbc17937c065ba29ba6d6333d08f0 (patch)
treecf0f18b1b3a62ee9a4c94d2cee4ba2fafb360fb1 /src
parentc221eff3fc03b468d915f1777e108246309f2ff0 (diff)
downloademacs-5827950329afbc17937c065ba29ba6d6333d08f0.tar.gz
emacs-5827950329afbc17937c065ba29ba6d6333d08f0.zip
(enum tiff_keyword_index, tiff_format): Add :index keyword.
(fn_TIFFSetDirectory): New library function used. (init_tiff_functions) [HAVE_NTGUI]: Initialize it. (tiff_load): Use :index to select among multiple images. Set count property when multiple images exist. (gif_format): Use :index, not :image.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/image.c40
2 files changed, 44 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 2eca7a92915..fc5afde616d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
12008-08-23 Jason Rumney <jasonr@gnu.org>
2
3 * image.c (enum tiff_keyword_index, tiff_format): Add :index keyword.
4 (fn_TIFFSetDirectory): New library function used.
5 (init_tiff_functions) [HAVE_NTGUI]: Initialize it.
6 (tiff_load): Use :index to select among multiple images. Set count
7 property when multiple images exist.
8 (gif_format): Use :index, not :image.
9
12008-08-23 Chong Yidong <cyd@stupidchicken.com> 102008-08-23 Chong Yidong <cyd@stupidchicken.com>
2 11
3 * xdisp.c (try_scrolling): Check INT_MAX instead of 12 * xdisp.c (try_scrolling): Check INT_MAX instead of
diff --git a/src/image.c b/src/image.c
index 1312d132f5c..7ce5b9b2e08 100644
--- a/src/image.c
+++ b/src/image.c
@@ -6926,6 +6926,7 @@ enum tiff_keyword_index
6926 TIFF_HEURISTIC_MASK, 6926 TIFF_HEURISTIC_MASK,
6927 TIFF_MASK, 6927 TIFF_MASK,
6928 TIFF_BACKGROUND, 6928 TIFF_BACKGROUND,
6929 TIFF_INDEX,
6929 TIFF_LAST 6930 TIFF_LAST
6930}; 6931};
6931 6932
@@ -6943,7 +6944,8 @@ static struct image_keyword tiff_format[TIFF_LAST] =
6943 {":conversions", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, 6944 {":conversions", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
6944 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, 6945 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
6945 {":mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, 6946 {":mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
6946 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} 6947 {":background", IMAGE_STRING_OR_NIL_VALUE, 0},
6948 {":index", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0}
6947}; 6949};
6948 6950
6949/* Structure describing the image type `tiff'. */ 6951/* Structure describing the image type `tiff'. */
@@ -6989,6 +6991,7 @@ DEF_IMGLIB_FN (TIFFClientOpen);
6989DEF_IMGLIB_FN (TIFFGetField); 6991DEF_IMGLIB_FN (TIFFGetField);
6990DEF_IMGLIB_FN (TIFFReadRGBAImage); 6992DEF_IMGLIB_FN (TIFFReadRGBAImage);
6991DEF_IMGLIB_FN (TIFFClose); 6993DEF_IMGLIB_FN (TIFFClose);
6994DEF_IMGLIB_FN (TIFFSetDirectory);
6992 6995
6993static int 6996static int
6994init_tiff_functions (Lisp_Object libraries) 6997init_tiff_functions (Lisp_Object libraries)
@@ -7005,6 +7008,7 @@ init_tiff_functions (Lisp_Object libraries)
7005 LOAD_IMGLIB_FN (library, TIFFGetField); 7008 LOAD_IMGLIB_FN (library, TIFFGetField);
7006 LOAD_IMGLIB_FN (library, TIFFReadRGBAImage); 7009 LOAD_IMGLIB_FN (library, TIFFReadRGBAImage);
7007 LOAD_IMGLIB_FN (library, TIFFClose); 7010 LOAD_IMGLIB_FN (library, TIFFClose);
7011 LOAD_IMGLIB_FN (library, TIFFSetDirectory);
7008 return 1; 7012 return 1;
7009} 7013}
7010 7014
@@ -7017,7 +7021,7 @@ init_tiff_functions (Lisp_Object libraries)
7017#define fn_TIFFGetField TIFFGetField 7021#define fn_TIFFGetField TIFFGetField
7018#define fn_TIFFReadRGBAImage TIFFReadRGBAImage 7022#define fn_TIFFReadRGBAImage TIFFReadRGBAImage
7019#define fn_TIFFClose TIFFClose 7023#define fn_TIFFClose TIFFClose
7020 7024#define fn_TIFFSetDirectory TIFFSetDirectory
7021#endif /* HAVE_NTGUI */ 7025#endif /* HAVE_NTGUI */
7022 7026
7023 7027
@@ -7170,12 +7174,13 @@ tiff_load (f, img)
7170 Lisp_Object file, specified_file; 7174 Lisp_Object file, specified_file;
7171 Lisp_Object specified_data; 7175 Lisp_Object specified_data;
7172 TIFF *tiff; 7176 TIFF *tiff;
7173 int width, height, x, y; 7177 int width, height, x, y, count;
7174 uint32 *buf; 7178 uint32 *buf;
7175 int rc; 7179 int rc, rc2;
7176 XImagePtr ximg; 7180 XImagePtr ximg;
7177 struct gcpro gcpro1; 7181 struct gcpro gcpro1;
7178 tiff_memory_source memsrc; 7182 tiff_memory_source memsrc;
7183 Lisp_Object image;
7179 7184
7180 specified_file = image_spec_value (img->spec, QCfile, NULL); 7185 specified_file = image_spec_value (img->spec, QCfile, NULL);
7181 specified_data = image_spec_value (img->spec, QCdata, NULL); 7186 specified_data = image_spec_value (img->spec, QCdata, NULL);
@@ -7231,6 +7236,20 @@ tiff_load (f, img)
7231 } 7236 }
7232 } 7237 }
7233 7238
7239 image = image_spec_value (img->spec, QCindex, NULL);
7240 if (INTEGERP (image))
7241 {
7242 int ino = XFASTINT (image);
7243 if (!fn_TIFFSetDirectory (tiff, ino))
7244 {
7245 image_error ("Invalid image number `%s' in image `%s'",
7246 image, img->spec);
7247 fn_TIFFClose (tiff);
7248 UNGCPRO;
7249 return 0;
7250 }
7251 }
7252
7234 /* Get width and height of the image, and allocate a raster buffer 7253 /* Get width and height of the image, and allocate a raster buffer
7235 of width x height 32-bit values. */ 7254 of width x height 32-bit values. */
7236 fn_TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width); 7255 fn_TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width);
@@ -7239,6 +7258,7 @@ tiff_load (f, img)
7239 if (!check_image_size (f, width, height)) 7258 if (!check_image_size (f, width, height))
7240 { 7259 {
7241 image_error ("Invalid image size", Qnil, Qnil); 7260 image_error ("Invalid image size", Qnil, Qnil);
7261 fn_TIFFClose (tiff);
7242 UNGCPRO; 7262 UNGCPRO;
7243 return 0; 7263 return 0;
7244 } 7264 }
@@ -7246,6 +7266,16 @@ tiff_load (f, img)
7246 buf = (uint32 *) xmalloc (width * height * sizeof *buf); 7266 buf = (uint32 *) xmalloc (width * height * sizeof *buf);
7247 7267
7248 rc = fn_TIFFReadRGBAImage (tiff, width, height, buf, 0); 7268 rc = fn_TIFFReadRGBAImage (tiff, width, height, buf, 0);
7269
7270 /* Count the number of images in the file. */
7271 for (count = 1, rc2 = 1; rc2; count++)
7272 rc2 = fn_TIFFSetDirectory (tiff, count);
7273
7274 if (count > 1)
7275 img->data.lisp_val = Fcons (Qcount,
7276 Fcons (make_number (count),
7277 img->data.lisp_val));
7278
7249 fn_TIFFClose (tiff); 7279 fn_TIFFClose (tiff);
7250 if (!rc) 7280 if (!rc)
7251 { 7281 {
@@ -7366,7 +7396,7 @@ static struct image_keyword gif_format[GIF_LAST] =
7366 {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, 7396 {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
7367 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, 7397 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
7368 {":mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, 7398 {":mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0},
7369 {":image", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0}, 7399 {":index", IMAGE_NON_NEGATIVE_INTEGER_VALUE, 0},
7370 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} 7400 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}
7371}; 7401};
7372 7402