unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 69992@debbugs.gnu.org
Subject: bug#69992: Minor improvement to image map transformation logic
Date: Sun, 24 Mar 2024 18:00:52 -0700	[thread overview]
Message-ID: <87o7b3m8ee.fsf@ushin.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 67 bytes --]

Hello,

This patch is slight simplification/optimization.

Joseph


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-copy-tree-just-image-map-not-entire-image.patch --]
[-- Type: text/x-diff, Size: 2443 bytes --]

From 96a30a0450384eaeda21f234911f947952c4dcde Mon Sep 17 00:00:00 2001
From: Joseph Turner <joseph@breatheoutbreathe.in>
Date: Sat, 23 Mar 2024 13:29:17 -0700
Subject: [PATCH] copy-tree just image map, not entire image.

* lisp/image.el (image--compute-original-map):
---
 lisp/image.el | 27 +++++++++++++--------------
 1 file 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 @@ image--compute-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.
-- 
2.41.0


             reply	other threads:[~2024-03-25  1:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25  1:00 Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-03-27 11:16 ` bug#69992: Minor improvement to image map transformation logic David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-27 12:50   ` Eli Zaretskii
2024-03-27 14:21     ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-27 22:17       ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-27 23:53         ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-28 22:22         ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-29 10:19           ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-30  8:10             ` Eli Zaretskii
2024-03-30  8:55               ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-30 12:59                 ` David Ponce via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-30 13:37                   ` Eli Zaretskii
2024-03-30 19:07                   ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o7b3m8ee.fsf@ushin.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=69992@debbugs.gnu.org \
    --cc=joseph@ushin.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).