:type '(repeat (choice directory variable))
:initialize #'custom-initialize-delay)
-(defcustom image-scaling-factor 'auto
- "When displaying images, apply this scaling factor before displaying.
-This is not supported for all image types, and is mostly useful
-when you have a high-resolution monitor.
-The value is either a floating point number (where numbers higher
-than 1 means to increase the size and lower means to shrink the
-size), or the symbol `auto', which will compute a scaling factor
-based on the font pixel size."
- :type '(choice number
- (const :tag "Automatically compute" auto))
- :version "26.1")
-
(defcustom image-transform-smoothing #'image--default-smoothing
"Whether to do smoothing when applying transforms to images.
Common transforms are rescaling and rotation.
file-or-data)
(and (not (plist-get props :scale))
;; Add default scaling.
- (list :scale
- (image-compute-scaling-factor
- image-scaling-factor)))
+ (list :scale 'default))
props)))
;; Add default smoothing.
(unless (plist-member props :transform-smoothing)
(rotation (plist-get props :rotation)))
(cond
;; We always smooth when scaling down and small upwards scaling.
- ((and scaling (< scaling 2))
+ ((and scaling (numberp scaling) (< scaling 2))
t)
;; Smooth when doing non-90-degree rotation
((and rotation
(defun image-compute-scaling-factor (&optional scaling)
"Compute the scaling factor based on SCALING.
If a number, use that. If it's `auto', compute the factor.
-If nil, use the `image-scaling-factor' variable."
+If nil, use the `image-scaling-factor' variable.
+
+This function is provided for the benefit of Lisp code that
+must compute this factor; it does not affect Emacs's scaling
+of images."
(unless scaling
(setq scaling image-scaling-factor))
(cond
If image-cache-eviction-delay is non-nil, this frees images in the cache
which weren't displayed for at least that many seconds. */
-static void
+void
clear_image_cache (struct frame *f, Lisp_Object filter)
{
struct image_cache *c = FRAME_IMAGE_CACHE (f);
return -1;
}
-/* Compute the desired size of an image with native size WIDTH x HEIGHT.
- Use IMG to deduce the size. Store the desired size into
- *D_WIDTH x *D_HEIGHT. Store -1 x -1 if the native size is OK. */
+/* Compute the desired size of an image with native size WIDTH x HEIGHT,
+ which is to be displayed on F. Use IMG to deduce the size. Store
+ the desired size into *D_WIDTH x *D_HEIGHT. Store -1 x -1 if the
+ native size is OK. */
+
static void
-compute_image_size (double width, double height,
+compute_image_size (struct frame *f, double width, double height,
struct image *img,
int *d_width, int *d_height)
{
double scale = 1;
Lisp_Object value = image_spec_value (img->spec, QCscale, NULL);
- if (NUMBERP (value))
+
+ if (EQ (value, Qdefault))
+ {
+ Lisp_Object sval = Vimage_scaling_factor;
+
+ /* Compute the scale from factors specified by the value of
+ Vimage_scaling_factor. */
+
+ invalid_value:
+ if (EQ (sval, Qauto))
+ {
+ /* This is a tag with which callers of `clear_image_cache' can
+ refer to this image and its likenesses. */
+ img->dependencies = Fcons (Qauto, img->dependencies);
+ scale = (FRAME_COLUMN_WIDTH (f) > 10
+ ? (FRAME_COLUMN_WIDTH (f) / 10.0f) : 1);
+ }
+ else if (NUMBERP (sval))
+ scale = XFLOATINT (sval);
+ else
+ {
+ image_error ("Invalid `image-scaling-factor': %s",
+ Vimage_scaling_factor);
+
+ /* If Vimage_scaling_factor is set to an invalid value, treat
+ it as though it were the default. */
+ sval = Qauto;
+ goto invalid_value;
+ }
+ }
+ else if (NUMBERP (value))
{
double dval = XFLOATINT (value);
if (0 <= dval)
}
else
#endif
- compute_image_size (img->width, img->height, img, &width, &height);
+ compute_image_size (f, img->width, img->height, img, &width,
+ &height);
/* Determine rotation. */
double rotation = 0.0;
}
#ifndef DONT_CREATE_TRANSFORMED_IMAGEMAGICK_IMAGE
- compute_image_size (MagickGetImageWidth (image_wand),
+ compute_image_size (f, MagickGetImageWidth (image_wand),
MagickGetImageHeight (image_wand),
img, &desired_width, &desired_height);
#else
#endif
#ifdef HAVE_NATIVE_TRANSFORMS
- compute_image_size (viewbox_width, viewbox_height, img,
+ compute_image_size (f, viewbox_width, viewbox_height, img,
&width, &height);
width = scale_image_size (width, 1, FRAME_SCALE_FACTOR (f));
DEFSYM (Qcount, "count");
DEFSYM (Qextension_data, "extension-data");
DEFSYM (Qdelay, "delay");
+ DEFSYM (Qauto, "auto");
/* Keywords. */
DEFSYM (QCascent, ":ascent");
The function `clear-image-cache' disregards this variable. */);
Vimage_cache_eviction_delay = make_fixnum (300);
+
+ DEFVAR_LISP ("image-scaling-factor", Vimage_scaling_factor,
+ doc: /* When displaying images, apply this scaling factor before displaying.
+This is not supported for all image types, and is mostly useful
+when you have a high-resolution monitor.
+The value is either a floating point number (where numbers higher
+than 1 means to increase the size and lower means to shrink the
+size), or the symbol `auto', which will compute a scaling factor
+based on the font pixel size. */);
+ Vimage_scaling_factor = Qauto;
+
#ifdef HAVE_IMAGEMAGICK
DEFVAR_INT ("imagemagick-render-type", imagemagick_render_type,
doc: /* Integer indicating which ImageMagick rendering method to use.