comparison src/xfns.c @ 29938:be81ae7e0218

(Fimage_size): New function. (syms_of_xfns): Defsubr it.
author Gerd Moellmann <gerd@gnu.org>
date Mon, 26 Jun 2000 13:11:38 +0000
parents c12b0f070cd1
children b7556fa4c05b
comparison
equal deleted inserted replaced
29937:693c2c631d72 29938:be81ae7e0218
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.
6 6
7 GNU Emacs is free software; you can redistribute it and/or modify 7 GNU Emacs is free software; you can redistribute it and/or modify
5211 if (found) 5211 if (found)
5212 *found = 0; 5212 *found = 0;
5213 return Qnil; 5213 return Qnil;
5214 } 5214 }
5215 5215
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 }
5216 5248
5217 5249
5218 5250
5219 /*********************************************************************** 5251 /***********************************************************************
5220 Image type independent image structures 5252 Image type independent image structures
10455 Qpng = intern ("png"); 10487 Qpng = intern ("png");
10456 staticpro (&Qpng); 10488 staticpro (&Qpng);
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;
10463 10496
10464 defsubr (&Sx_show_tip); 10497 defsubr (&Sx_show_tip);