1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-24 07:20:37 +00:00

Small followup change

* lisp/image.el (create-image): Remove supererogatory instances
of pcase.  Recognize new `lambda' values and refrain from
specifying a default transform-smoothing when it is returned.
(image--default-smoothing): Return lambda if scaling is default.

* lisp/tool-bar.el (tool-bar--image-expression): Revert this
portion of last change.
This commit is contained in:
Po Lu 2024-06-03 20:37:41 +08:00
parent 3a54dfab24
commit 68cc4cb6b1
2 changed files with 16 additions and 11 deletions

View File

@ -520,7 +520,7 @@ Images should not be larger than specified by `max-image-size'."
(let ((data-format (let ((data-format
;; Pass the image format, if any, if this is data. ;; Pass the image format, if any, if this is data.
(and data-p (or (plist-get props :format) t)))) (and data-p (or (plist-get props :format) t))))
;; It is x_find_image_file in image.c that sets the search path. ;; It is `x_find_image_fd' in image.c that sets the search path.
(setq type (ignore-error unknown-image-type (setq type (ignore-error unknown-image-type
(image-type file-or-data type data-format))) (image-type file-or-data type data-format)))
;; If we have external image conversion switched on (for exotic, ;; If we have external image conversion switched on (for exotic,
@ -540,12 +540,13 @@ Images should not be larger than specified by `max-image-size'."
props))) props)))
;; Add default smoothing. ;; Add default smoothing.
(unless (plist-member props :transform-smoothing) (unless (plist-member props :transform-smoothing)
(setq image (nconc image (let* ((func image-transform-smoothing)
(list :transform-smoothing (value (or (eq func t)
(pcase image-transform-smoothing (and func (funcall func image)))))
('t t) (unless (eq value 'lambda)
('nil nil) (setq image (nconc image
(func (funcall func image))))))) (list :transform-smoothing
value))))))
;; Add original map from map. ;; Add original map from map.
(when (and (plist-get props :map) (when (and (plist-get props :map)
(not (plist-get props :original-map))) (not (plist-get props :original-map)))
@ -559,13 +560,18 @@ Images should not be larger than specified by `max-image-size'."
image))) image)))
(defun image--default-smoothing (image) (defun image--default-smoothing (image)
"Say whether IMAGE should be smoothed when transformed." "Say whether IMAGE should be smoothed when transformed.
Return `lambda' if the decision should be deferred to the time IMAGE is
loaded."
(let* ((props (nthcdr 5 image)) (let* ((props (nthcdr 5 image))
(scaling (plist-get props :scale)) (scaling (plist-get props :scale))
(rotation (plist-get props :rotation))) (rotation (plist-get props :rotation)))
(cond (cond
;; The scale of the image won't be available until
;; `image_set_transform', and as such, defer to its judgement.
((eq scaling 'default) 'lambda)
;; We always smooth when scaling down and small upwards scaling. ;; We always smooth when scaling down and small upwards scaling.
((and scaling (numberp scaling) (< scaling 2)) ((and scaling (< scaling 2))
t) t)
;; Smooth when doing non-90-degree rotation ;; Smooth when doing non-90-degree rotation
((and rotation ((and rotation

View File

@ -220,8 +220,7 @@ To define items in any other map, use `tool-bar-local-item'."
(let* ((fg (face-attribute 'tool-bar :foreground)) (let* ((fg (face-attribute 'tool-bar :foreground))
(bg (face-attribute 'tool-bar :background)) (bg (face-attribute 'tool-bar :background))
(colors (nconc (if (eq fg 'unspecified) nil (list :foreground fg)) (colors (nconc (if (eq fg 'unspecified) nil (list :foreground fg))
(if (eq bg 'unspecified) nil (list :background bg)) (if (eq bg 'unspecified) nil (list :background bg))))
'(:transform-smoothing nil)))
(xpm-spec (list :type 'xpm :file (concat icon ".xpm"))) (xpm-spec (list :type 'xpm :file (concat icon ".xpm")))
(xpm-lo-spec (list :type 'xpm :file (xpm-lo-spec (list :type 'xpm :file
(concat "low-color/" icon ".xpm"))) (concat "low-color/" icon ".xpm")))