aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoseph Turner2024-03-23 13:29:17 -0700
committerEli Zaretskii2024-03-28 12:11:50 +0200
commita4da3971f2580c90fb3c6957eea2d0dbfb695879 (patch)
tree86f16797c50e45beb63a4f8a5c5c9bfca640cd0a
parentf021c3dbcd08eb1b0e3215ba6fd4e56364e6915f (diff)
downloademacs-a4da3971f2580c90fb3c6957eea2d0dbfb695879.tar.gz
emacs-a4da3971f2580c90fb3c6957eea2d0dbfb695879.zip
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.el27
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."
1455If IMAGE lacks :map property, return nil. 1455If IMAGE lacks :map property, return nil.
1456When :rotation is not a multiple of 90, return copy of :map." 1456When :rotation is not a multiple of 90, return copy of :map."
1457 (when (image-property image :map) 1457 (when (image-property image :map)
1458 (let* ((image-copy (copy-tree image t)) 1458 (let* ((original-map (copy-tree (image-property image :map) t))
1459 (map (image-property image-copy :map)) 1459 (scale (or (image-property image :scale) 1))
1460 (scale (or (image-property image-copy :scale) 1)) 1460 (rotation (or (image-property image :rotation) 0))
1461 (rotation (or (image-property image-copy :rotation) 0)) 1461 (flip (image-property image :flip))
1462 (flip (image-property image-copy :flip)) 1462 (size (image-size image t)))
1463 (size (image-size image-copy t)))
1464 (when (and ; Handle only 90-degree rotations 1463 (when (and ; Handle only 90-degree rotations
1465 (zerop (mod rotation 1)) 1464 (zerop (mod rotation 1))
1466 (zerop (% (truncate rotation) 90))) 1465 (zerop (% (truncate rotation) 90)))
1467 ;; In rendered images, rotation is always applied before flip. 1466 ;; In rendered images, rotation is always applied before flip.
1468 ;; To undo the transformation, flip before rotating. 1467 ;; To undo the transformation, flip before rotating. SIZE fits
1469 ;; SIZE fits MAP before it is transformed back to ORIGINAL-MAP. 1468 ;; ORIGINAL-MAP before transformations are applied. Therefore,
1470 ;; Therefore, scale MAP after flip and rotate operations, since 1469 ;; scale ORIGINAL-MAP after flip and rotate operations, since
1471 ;; both need MAP to fit SIZE. 1470 ;; both need ORIGINAL-MAP to fit SIZE.
1472 (image--flip-map map flip size) 1471 (image--flip-map original-map flip size)
1473 (image--rotate-map map (- rotation) size) 1472 (image--rotate-map original-map (- rotation) size)
1474 (image--scale-map map (/ 1.0 scale))) 1473 (image--scale-map original-map (/ 1.0 scale)))
1475 map))) 1474 original-map)))
1476 1475
1477(defun image--scale-map (map scale) 1476(defun image--scale-map (map scale)
1478 "Scale MAP according to SCALE. 1477 "Scale MAP according to SCALE.