Mercurial > emacs
comparison src/image.c @ 66208:5414bd89ffde
(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.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Wed, 19 Oct 2005 21:52:13 +0000 |
parents | ad1acaef1abb |
children | 2f521eba6f82 0ca0d9181b5e |
comparison
equal
deleted
inserted
replaced
66207:23849291d887 | 66208:5414bd89ffde |
---|---|
1161 check_image_size (f, width, height) | 1161 check_image_size (f, width, height) |
1162 struct frame *f; | 1162 struct frame *f; |
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 | |
1168 if (width <= 0 || height <= 0) | |
1167 return 0; | 1169 return 0; |
1168 | 1170 |
1169 if (FLOATP (Vmax_image_size) && f | 1171 if (INTEGERP (Vmax_image_size)) |
1170 && ((width > (int)(XFLOAT_DATA (Vmax_image_size) | 1172 w = h = XINT (Vmax_image_size); |
1171 * FRAME_PIXEL_WIDTH (f))) | 1173 else if (FLOATP (Vmax_image_size)) |
1172 || (height > (int)(XFLOAT_DATA (Vmax_image_size) | 1174 { |
1173 * FRAME_PIXEL_HEIGHT (f))))) | 1175 if (f != NULL) |
1174 return 0; | 1176 { |
1175 | 1177 w = FRAME_PIXEL_WIDTH (f); |
1176 return 1; | 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 |
1180 drawing an image. */ | 1192 drawing an image. */ |
1181 | 1193 |
8287 listed; they're always supported. */); | 8299 listed; they're always supported. */); |
8288 Vimage_library_alist = Qnil; | 8300 Vimage_library_alist = Qnil; |
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; |
8301 staticpro (&Vimage_type_cache); | 8316 staticpro (&Vimage_type_cache); |
8302 | 8317 |