From 7df4765a4cef4cad91f471b606834867125e11ff Mon Sep 17 00:00:00 2001 From: "Kim F. Storm" Date: Wed, 19 Oct 2005 21:52:13 +0000 Subject: [PATCH] (check_image_size): Handle integer Vmax_image_size value directly as max pixel value. Use default frame size for null frame. (syms_of_image) : Describe integer value. --- src/image.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/src/image.c b/src/image.c index c0702c5ea8c..1996d8477e9 100644 --- a/src/image.c +++ b/src/image.c @@ -1163,17 +1163,29 @@ check_image_size (f, width, height) int width; int height; { - if (width <= 0 || height <=0) - return 0; + int w, h; - if (FLOATP (Vmax_image_size) && f - && ((width > (int)(XFLOAT_DATA (Vmax_image_size) - * FRAME_PIXEL_WIDTH (f))) - || (height > (int)(XFLOAT_DATA (Vmax_image_size) - * FRAME_PIXEL_HEIGHT (f))))) + if (width <= 0 || height <= 0) return 0; - return 1; + if (INTEGERP (Vmax_image_size)) + w = h = XINT (Vmax_image_size); + else if (FLOATP (Vmax_image_size)) + { + if (f != NULL) + { + w = FRAME_PIXEL_WIDTH (f); + h = FRAME_PIXEL_HEIGHT (f); + } + else + w = h = 1024; /* Arbitrary size for unknown frame. */ + w = (int) (XFLOAT_DATA (Vmax_image_size) * w); + h = (int) (XFLOAT_DATA (Vmax_image_size) * h); + } + else + return 1; + + return (width <= w && height <= h); } /* Prepare image IMG for display on frame F. Must be called before @@ -8289,12 +8301,15 @@ listed; they're always supported. */); Fput (intern ("image-library-alist"), Qrisky_local_variable, Qt); DEFVAR_LISP ("max-image-size", &Vmax_image_size, - doc: /* Maximum size of an image, relative to the selected frame. - -This is a floating point number that is multiplied by the width and -height of the selected frame, to give the maximum width and height for -images. Emacs will not load an image into memory if its width or -height exceeds this limit. */); + doc: /* Maximum size of images. +Emacs will not load an image into memory if its pixel width or +pixel height exceeds this limit. + +If the value is an integer, it directly specifies the maximum +image height and width, measured in pixels. If it is a floating +point number, it specifies the maximum image height and width +as a ratio to the frame height and width. If the value is +non-numeric, there is no explicit limit on the size of images. */); Vmax_image_size = make_float (MAX_IMAGE_SIZE); Vimage_type_cache = Qnil; -- 2.39.5