diff options
| author | Kim F. Storm | 2005-10-19 21:52:13 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2005-10-19 21:52:13 +0000 |
| commit | 7df4765a4cef4cad91f471b606834867125e11ff (patch) | |
| tree | 4d9063f06352cd586beba3231f43fc69276145c5 /src | |
| parent | cf39c182861d1239a2ddbc818a8ced86970c4377 (diff) | |
| download | emacs-7df4765a4cef4cad91f471b606834867125e11ff.tar.gz emacs-7df4765a4cef4cad91f471b606834867125e11ff.zip | |
(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')
| -rw-r--r-- | src/image.c | 43 |
1 files 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) | |||
| 1163 | int width; | 1163 | int width; |
| 1164 | int height; | 1164 | int height; |
| 1165 | { | 1165 | { |
| 1166 | if (width <= 0 || height <=0) | 1166 | int w, h; |
| 1167 | return 0; | ||
| 1168 | 1167 | ||
| 1169 | if (FLOATP (Vmax_image_size) && f | 1168 | if (width <= 0 || height <= 0) |
| 1170 | && ((width > (int)(XFLOAT_DATA (Vmax_image_size) | ||
| 1171 | * FRAME_PIXEL_WIDTH (f))) | ||
| 1172 | || (height > (int)(XFLOAT_DATA (Vmax_image_size) | ||
| 1173 | * FRAME_PIXEL_HEIGHT (f))))) | ||
| 1174 | return 0; | 1169 | return 0; |
| 1175 | 1170 | ||
| 1176 | return 1; | 1171 | if (INTEGERP (Vmax_image_size)) |
| 1172 | w = h = XINT (Vmax_image_size); | ||
| 1173 | else if (FLOATP (Vmax_image_size)) | ||
| 1174 | { | ||
| 1175 | if (f != NULL) | ||
| 1176 | { | ||
| 1177 | w = FRAME_PIXEL_WIDTH (f); | ||
| 1178 | h = FRAME_PIXEL_HEIGHT (f); | ||
| 1179 | } | ||
| 1180 | else | ||
| 1181 | w = h = 1024; /* Arbitrary size for unknown frame. */ | ||
| 1182 | w = (int) (XFLOAT_DATA (Vmax_image_size) * w); | ||
| 1183 | h = (int) (XFLOAT_DATA (Vmax_image_size) * h); | ||
| 1184 | } | ||
| 1185 | else | ||
| 1186 | return 1; | ||
| 1187 | |||
| 1188 | return (width <= w && height <= h); | ||
| 1177 | } | 1189 | } |
| 1178 | 1190 | ||
| 1179 | /* Prepare image IMG for display on frame F. Must be called before | 1191 | /* Prepare image IMG for display on frame F. Must be called before |
| @@ -8289,12 +8301,15 @@ listed; they're always supported. */); | |||
| 8289 | Fput (intern ("image-library-alist"), Qrisky_local_variable, Qt); | 8301 | Fput (intern ("image-library-alist"), Qrisky_local_variable, Qt); |
| 8290 | 8302 | ||
| 8291 | DEFVAR_LISP ("max-image-size", &Vmax_image_size, | 8303 | DEFVAR_LISP ("max-image-size", &Vmax_image_size, |
| 8292 | doc: /* Maximum size of an image, relative to the selected frame. | 8304 | doc: /* Maximum size of images. |
| 8293 | 8305 | Emacs will not load an image into memory if its pixel width or | |
| 8294 | This is a floating point number that is multiplied by the width and | 8306 | pixel height exceeds this limit. |
| 8295 | height of the selected frame, to give the maximum width and height for | 8307 | |
| 8296 | images. Emacs will not load an image into memory if its width or | 8308 | If the value is an integer, it directly specifies the maximum |
| 8297 | height exceeds this limit. */); | 8309 | image height and width, measured in pixels. If it is a floating |
| 8310 | point number, it specifies the maximum image height and width | ||
| 8311 | as a ratio to the frame height and width. If the value is | ||
| 8312 | non-numeric, there is no explicit limit on the size of images. */); | ||
| 8298 | Vmax_image_size = make_float (MAX_IMAGE_SIZE); | 8313 | Vmax_image_size = make_float (MAX_IMAGE_SIZE); |
| 8299 | 8314 | ||
| 8300 | Vimage_type_cache = Qnil; | 8315 | Vimage_type_cache = Qnil; |