aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
authorKim F. Storm <[email protected]>2005-10-19 21:52:13 +0000
committerKim F. Storm <[email protected]>2005-10-19 21:52:13 +0000
commit7df4765a4cef4cad91f471b606834867125e11ff (patch)
tree4d9063f06352cd586beba3231f43fc69276145c5 /src/image.c
parentcf39c182861d1239a2ddbc818a8ced86970c4377 (diff)
(check_image_size): Handle integer Vmax_image_size value
directly as max pixel value. Use default frame size for null frame. (syms_of_image) <max-image-size>: Describe integer value.
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/src/image.c b/src/image.c
index c0702c5ea8..1996d8477e 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;