From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Timo Taipalus Newsgroups: gmane.emacs.bugs Subject: bug#47095: [PATCH] Add support for image mirroring (Bug#47095) Date: Wed, 29 Dec 2021 11:10:03 +0200 Message-ID: <3b23f6a58f935098122e3bbf21e0f59c@taipalus.cc> References: <86a6r8hd8q.fsf@gmail.com> <9d31c48598c3fc1cd6a90a1845f518cb@taipalus.cc> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=_265cb715d031de7c994bf9af20596f49" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30617"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 47095@debbugs.gnu.org To: Timo Taipalus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 29 10:11:14 2021 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 1n2UzJ-0007lr-OM for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 29 Dec 2021 10:11:13 +0100 Original-Received: from localhost ([::1]:39690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2UzH-0004gV-UW for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 29 Dec 2021 04:11:11 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:60086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2Uz9-0004gL-4n for bug-gnu-emacs@gnu.org; Wed, 29 Dec 2021 04:11:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36495) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2Uz8-0002SG-Lh for bug-gnu-emacs@gnu.org; Wed, 29 Dec 2021 04:11:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n2Uz8-0001uK-Dt for bug-gnu-emacs@gnu.org; Wed, 29 Dec 2021 04:11:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Timo Taipalus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 29 Dec 2021 09:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47095 X-GNU-PR-Package: emacs Original-Received: via spool by 47095-submit@debbugs.gnu.org id=B47095.16407690117252 (code B ref 47095); Wed, 29 Dec 2021 09:11:02 +0000 Original-Received: (at 47095) by debbugs.gnu.org; 29 Dec 2021 09:10:11 +0000 Original-Received: from localhost ([127.0.0.1]:48041 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2UyI-0001sr-Ex for submit@debbugs.gnu.org; Wed, 29 Dec 2021 04:10:11 -0500 Original-Received: from mail.kapsi.fi ([91.232.154.25]:49847) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2UyG-0001si-89 for 47095@debbugs.gnu.org; Wed, 29 Dec 2021 04:10:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kapsi.fi; s=20161220; h=Content-Type:Message-ID:References:In-Reply-To:Subject:Cc:To: From:Date:MIME-Version:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=TNLUIQjlUkmkY7Bridj6l2xErgZJh1lqtZ9aM5uhOWg=; b=H9F2lmitRf+aVdtkaymu9lR1cZ cPG+uwT0NpW4EdhbfgTniN4lodYsZH485iBmsrrzcIdFv4cDo50Wixx+EdafSFDQrx/9/vYGv3cLo ACDPjM1vTG57s4fYH0nFfl2xaHBllWKHLccRSrUdnozG3FI+yDlqWZDfXW0TkzgvYA5ZSto0XLDae Mqzg/wJU/dh+/xpJz75RykzpLSAYVBkOY+eBTM7Lyy0w/+9UPHY9dsQjndxSHBVtCZxFcagwa8yiq ldVKlBKKY81gVS6744Qx72iWcY9nh3ctzbteAepzysIG2479Dx+movSM/2fqdX7D2mv6ulA6b9P3e Uk9b0Hwg==; Original-Received: from webng-gw.kapsi.fi ([91.232.154.200] helo=roundcube.kapsi.fi) by mail.kapsi.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1n2UyD-0004FJ-SW; Wed, 29 Dec 2021 11:10:05 +0200 In-Reply-To: X-Sender: timo@taipalus.cc X-SA-Exim-Connect-IP: 91.232.154.200 X-SA-Exim-Mail-From: timo@taipalus.cc X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false 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" Xref: news.gmane.io gmane.emacs.bugs:223313 Archived-At: --=_265cb715d031de7c994bf9af20596f49 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8; format=flowed On 28.12.2021 13:22, Alan Third wrote: > On Mon, Dec 27, 2021 at 10:36:43AM +0200, Timo Taipalus wrote: >> It seems image-mode does not have capability for image mirroring, so >> here's a patch for it. Tested NS (macOS) and XRender/Cairo >> implementations. As it is, it has no effect if ImageMagick is >> enabled. > > I suspect this won't work at all on windows due to the way the > transform is implemented there, but someone should probably check. > >> I chose 'h' as the action key because 'm' and 'f' were reserved, and >> 'h' is easy to memorize ("horizontal"). > > 'r' for reverse, maybe? > > Is it possible to do the mirroring before the rotation instead of as > part of it? I feel like it would make the code a little clearer, > although I suspect you're doing it in the rotation to reduce the > number of calculations? Would it be possible to have both horizontal > and vertical mirroring? As said elsewhere, "r" is reserved for rotation. :) I added an elisp function to do a vertical flip. Also I renamed the procedure flipping because that's what GIMP calls it. Attached is a revised patch to replace the previous one. As for the C code, I agree it adds some complexity to the transform function, but this is probably the fastest way to achieve it. Flipping before rotation would lead to strange results when the image has been rotated 90/270 degrees. Then the flip commands seem reversed – horizontal flip actually flips vertically and vice versa. This is because the transform function always rotates the initial image, which is what would be flipped. Hopefully someone can test this patch on Windows. --=_265cb715d031de7c994bf9af20596f49 Content-Transfer-Encoding: base64 Content-Type: text/x-diff; name=0001-Add-support-for-image-flipping-Bug-47095.patch Content-Disposition: attachment; filename=0001-Add-support-for-image-flipping-Bug-47095.patch; size=4706 RnJvbSBiNTg2MTk0MzFkNmZhMGY2YjlmNTBhOTRhZWZjMDliZTYxMjFmYTNlIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBUaW1vIDx0aW1vQHRhaXBhbHVzLmNjPgpEYXRlOiBXZWQsIDI5 IERlYyAyMDIxIDEwOjU1OjA2ICswMjAwClN1YmplY3Q6IFtQQVRDSF0gQWRkIHN1cHBvcnQgZm9y IGltYWdlIGZsaXBwaW5nIChCdWcjNDcwOTUpCgoqIGxpc3AvaW1hZ2UuZWwgKGltYWdlLW1hcCk6 IEtleWJpbmRpbmdzIGZvciBmbGlwcGluZyBmdW5jdGlvbnMuCihpbWFnZS1mbGlwLWhvcml6b250 YWxseSk6IE5ldyBmdW5jdGlvbiB0aGF0IHRvZ2dsZXMgaW1hZ2UgZmxpcHBpbmcKcHJvcGVydHku CihpbWFnZS1mbGlwLXZlcnRpY2FsbHkpOiBOZX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