diff options
| author | Gerd Moellmann | 2000-06-26 13:11:38 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-06-26 13:11:38 +0000 |
| commit | 42677916be338854ccbc08b16184e808786d2eb2 (patch) | |
| tree | 5bfdb105061495660ceffd8cf536be25d81b578d /src | |
| parent | 9ef3882f5d2816e5bc872031878ff0901b78e432 (diff) | |
| download | emacs-42677916be338854ccbc08b16184e808786d2eb2.tar.gz emacs-42677916be338854ccbc08b16184e808786d2eb2.zip | |
(Fimage_size): New function.
(syms_of_xfns): Defsubr it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfns.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/xfns.c b/src/xfns.c index 435de7e658f..8e66abbfa7f 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Functions for the X window system. | 1 | /* Functions for the X window system. |
| 2 | Copyright (C) 1989, 92, 93, 94, 95, 96, 1997, 1998, 1999 | 2 | Copyright (C) 1989, 92, 93, 94, 95, 96, 1997, 1998, 1999, 2000 |
| 3 | Free Software Foundation. | 3 | Free Software Foundation. |
| 4 | 4 | ||
| 5 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| @@ -5214,6 +5214,38 @@ image_spec_value (spec, key, found) | |||
| 5214 | } | 5214 | } |
| 5215 | 5215 | ||
| 5216 | 5216 | ||
| 5217 | DEFUN ("image-size", Fimage_size, Simage_size, 1, 3, 0, | ||
| 5218 | "Return the size of image SPEC as pair (WIDTH . HEIGHT).\n\ | ||
| 5219 | PIXELS non-nil means return the size in pixels, otherwise return the\n\ | ||
| 5220 | size in canonical character units.\n\ | ||
| 5221 | FRAME is the frame on which the image will be displayed. FRAME nil\n\ | ||
| 5222 | or omitted means use the selected frame.") | ||
| 5223 | (spec, pixels, frame) | ||
| 5224 | Lisp_Object spec, pixels, frame; | ||
| 5225 | { | ||
| 5226 | Lisp_Object size; | ||
| 5227 | |||
| 5228 | size = Qnil; | ||
| 5229 | if (valid_image_p (spec)) | ||
| 5230 | { | ||
| 5231 | struct frame *f = check_x_frame (frame); | ||
| 5232 | int id = lookup_image (f, spec); | ||
| 5233 | struct image *img = IMAGE_FROM_ID (f, id); | ||
| 5234 | int width = img->width + 2 * img->margin; | ||
| 5235 | int height = img->height + 2 * img->margin; | ||
| 5236 | |||
| 5237 | if (NILP (pixels)) | ||
| 5238 | size = Fcons (make_float ((double) width / CANON_X_UNIT (f)), | ||
| 5239 | make_float ((double) height / CANON_Y_UNIT (f))); | ||
| 5240 | else | ||
| 5241 | size = Fcons (make_number (width), make_number (height)); | ||
| 5242 | } | ||
| 5243 | else | ||
| 5244 | error ("Invalid image specification"); | ||
| 5245 | |||
| 5246 | return size; | ||
| 5247 | } | ||
| 5248 | |||
| 5217 | 5249 | ||
| 5218 | 5250 | ||
| 5219 | /*********************************************************************** | 5251 | /*********************************************************************** |
| @@ -10457,6 +10489,7 @@ meaning don't clear the cache."); | |||
| 10457 | #endif | 10489 | #endif |
| 10458 | 10490 | ||
| 10459 | defsubr (&Sclear_image_cache); | 10491 | defsubr (&Sclear_image_cache); |
| 10492 | defsubr (&Simage_size); | ||
| 10460 | 10493 | ||
| 10461 | busy_cursor_atimer = NULL; | 10494 | busy_cursor_atimer = NULL; |
| 10462 | busy_cursor_shown_p = 0; | 10495 | busy_cursor_shown_p = 0; |