From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#69992: Minor improvement to image map transformation logic Date: Sun, 24 Mar 2024 18:00:52 -0700 Message-ID: <87o7b3m8ee.fsf@ushin.org> Reply-To: Joseph Turner Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19160"; mail-complaints-to="usenet@ciao.gmane.io" To: 69992@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 25 02:02:49 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1roYjh-0004kQ-80 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 25 Mar 2024 02:02:49 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1roYjI-0007ua-Nw; Sun, 24 Mar 2024 21:02:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1roYjG-0007uK-IS for bug-gnu-emacs@gnu.org; Sun, 24 Mar 2024 21:02:22 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1roYjD-0006jS-Qp for bug-gnu-emacs@gnu.org; Sun, 24 Mar 2024 21:02:22 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1roYjt-0004X9-So for bug-gnu-emacs@gnu.org; Sun, 24 Mar 2024 21:03:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Joseph Turner Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 25 Mar 2024 01:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 69992 X-GNU-PR-Package: emacs X-Debbugs-Original-To: Emacs Bugs Mailing List Original-Received: via spool by submit@debbugs.gnu.org id=B.171132856617402 (code B ref -1); Mon, 25 Mar 2024 01:03:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 25 Mar 2024 01:02:46 +0000 Original-Received: from localhost ([127.0.0.1]:47624 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1roYjd-0004Wc-Hu for submit@debbugs.gnu.org; Sun, 24 Mar 2024 21:02:45 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:39910) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1roYjY-0004WL-C9 for submit@debbugs.gnu.org; Sun, 24 Mar 2024 21:02:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1roYir-0007nO-SR for bug-gnu-emacs@gnu.org; Sun, 24 Mar 2024 21:01:57 -0400 Original-Received: from out-185.mta1.migadu.com ([2001:41d0:203:375::b9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1roYip-0006hv-6d for bug-gnu-emacs@gnu.org; Sun, 24 Mar 2024 21:01:57 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ushin.org; s=key1; t=1711328511; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=edFz9bwM2bvhL/gPoQd7QdEP4DBxipy2FskxlpK20Jc=; b=BFCn4ecUdYlnv1ivZkgdGpzIiXVTPdzHkxEaC3FvF+2KDfMAlyyrXWE7teDoZrQzbw0Dvf xAQH/SC67HidcqYtdtz8QMo/Xmlp8EBFdKz8J5G75XTbj5t9OBWmUtGmdS9K/Y8eqk1ths 1bBhpC5olmSrWbsNlfbDu23IIqtn3OZv0B++iYZBzgrnjeOsPxpvdhthYPGxoNt5kgyTSC Pf9I2JvIw6WrfOZe8DmGKhtGp+wh1SM8NzdsIzKfCNmsrDLXiAppRTKypEIqRAlIg4tAWu IcmFkKpCWEGU+1+fGwO0WTYieeDlUhUyXYUjBzKtcntckZh9jEdhf8RELWa6Kw== X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:203:375::b9; envelope-from=joseph@ushin.org; helo=out-185.mta1.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:282040 Archived-At: --=-=-= Content-Type: text/plain Hello, This patch is slight simplification/optimization. Joseph --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-copy-tree-just-image-map-not-entire-image.patch >From 96a30a0450384eaeda21f234911f947952c4dcde Mon Sep 17 00:00:00 2001 From: Joseph Turner 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 --=-=-=--