diff options
author | Joseph Turner <joseph@breatheoutbreathe.in> | 2024-03-23 13:29:17 -0700 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2024-03-28 12:11:50 +0200 |
commit | a4da3971f2580c90fb3c6957eea2d0dbfb695879 (patch) | |
tree | 86f16797c50e45beb63a4f8a5c5c9bfca640cd0a | |
parent | f021c3dbcd08eb1b0e3215ba6fd4e56364e6915f (diff) | |
download | emacs-a4da3971f2580c90fb3c6957eea2d0dbfb695879.tar.gz |
copy-tree just image map, not entire image
* lisp/image.el (image--compute-original-map): Copy only
the image map. (Bug#69602)
-rw-r--r-- | lisp/image.el | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/lisp/image.el b/lisp/image.el index 55340ea03dc..d7496485aca 100644 --- a/lisp/image.el +++ b/lisp/image.el @@ -1455,24 +1455,23 @@ When :rotation is not a multiple of 90, return copy of :original-map." If IMAGE lacks :map property, return nil. When :rotation is not a multiple of 90, return copy of :map." (when (image-property image :map) - (let* ((image-copy (copy-tree image t)) - (map (image-property image-copy :map)) - (scale (or (image-property image-copy :scale) 1)) - (rotation (or (image-property image-copy :rotation) 0)) - (flip (image-property image-copy :flip)) - (size (image-size image-copy t))) + (let* ((original-map (copy-tree (image-property image :map) t)) + (scale (or (image-property image :scale) 1)) + (rotation (or (image-property image :rotation) 0)) + (flip (image-property image :flip)) + (size (image-size image t))) (when (and ; Handle only 90-degree rotations (zerop (mod rotation 1)) (zerop (% (truncate rotation) 90))) ;; In rendered images, rotation is always applied before flip. - ;; To undo the transformation, flip before rotating. - ;; SIZE fits MAP before it is transformed back to ORIGINAL-MAP. - ;; Therefore, scale MAP after flip and rotate operations, since - ;; both need MAP to fit SIZE. - (image--flip-map map flip size) - (image--rotate-map map (- rotation) size) - (image--scale-map map (/ 1.0 scale))) - map))) + ;; To undo the transformation, flip before rotating. SIZE fits + ;; ORIGINAL-MAP before transformations are applied. Therefore, + ;; scale ORIGINAL-MAP after flip and rotate operations, since + ;; both need ORIGINAL-MAP to fit SIZE. + (image--flip-map original-map flip size) + (image--rotate-map original-map (- rotation) size) + (image--scale-map original-map (/ 1.0 scale))) + original-map))) (defun image--scale-map (map scale) "Scale MAP according to SCALE. |