From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Image transformations Date: Tue, 25 Jun 2019 21:57:56 +0300 Message-ID: <838stplcgb.fsf@gnu.org> References: <20190613192724.GA11945@breton.holly.idiocy.org> <83zhmlxo6d.fsf@gnu.org> <20190613222626.GA12971@breton.holly.idiocy.org> <83o930y7cl.fsf@gnu.org> <20190615104242.GA13368@breton.holly.idiocy.org> <838su3w0de.fsf@gnu.org> <20190616152259.GA22789@breton.holly.idiocy.org> <83d0jdv68i.fsf@gnu.org> <20190617211332.GA55597@breton.holly.idiocy.org> <83a7e6na26.fsf@gnu.org> <20190625183352.GA18019@breton.holly.idiocy.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="111579"; mail-complaints-to="usenet@blaine.gmane.org" Cc: emacs-devel@gnu.org To: Alan Third Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jun 25 20:58:29 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hfqeB-000SjE-Tb for ged-emacs-devel@m.gmane.org; Tue, 25 Jun 2019 20:58:28 +0200 Original-Received: from localhost ([::1]:34722 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfqeA-00052N-2Q for ged-emacs-devel@m.gmane.org; Tue, 25 Jun 2019 14:58:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56173) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfqdo-00052F-My for emacs-devel@gnu.org; Tue, 25 Jun 2019 14:58:06 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:36114) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hfqdo-0003As-Ii; Tue, 25 Jun 2019 14:58:04 -0400 Original-Received: from [176.228.60.248] (port=4377 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hfqdl-0007zl-Ch; Tue, 25 Jun 2019 14:58:03 -0400 In-reply-to: <20190625183352.GA18019@breton.holly.idiocy.org> (message from Alan Third on Tue, 25 Jun 2019 19:33:52 +0100) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:238144 Archived-At: > Date: Tue, 25 Jun 2019 19:33:52 +0100 > From: Alan Third > Cc: emacs-devel@gnu.org > > Yes. I’m happy to drop :crop entirely. Although we might be as well > leaving it for ImageMagick, as it provides a RAM saving by actually > cropping the image, if people care enough about that. Sure, I didn't mean to remove :crop from ImageMagick images. > > In my research I found out that the equivalent Windows graphics APIs > > need a matrix that is the inverse of what we calculate in image.c. I > > think that calculating a matrix and then inverting it at draw time is > > inefficient at best and silly at worst; I'd rather calculate the > > inverse matrix to begin with. Calculating the inverse matrix involves > > reversing all the primitive transformations (translations change sign, > > rotations change the sign of the angle), and also changing the > > multiplication order from left-multiplication of matrices to > > right-multiplication. > > Am I right in thinking we need to invert the scaling too? 1/scale? Yes, of course. > > Given these findings, what would you prefer to do in image.c? We > > could either (a) make the individual functions (image_set_rotation > > etc.) return the transformation parameters, and leave the matrix > > calculation to image_set_transform, or we could have the individual > > functions accept a flag to tell them whether to generate XRender/Cairo > > style matrices or NS/Windows style. Or maybe you ave yet another > > idea? > > The image size calculation is already a separate function, shared with > ImageMagick, so I feel we’re halfway towards (a) as it is. I’m happy > to put all the matrix code into image_set_transform: once we remove > cropping the resulting function shouldn’t be obscenely large. OK, I will work on these changes. > '((:rotation imagemagick) > (:width png gif svg imagemagick) > (:height png gif svg imagemagick) > ...) > > where png, svg, imagemagick, etc. are types (image backends) that you > can pass to create-image. > > Or it might be better to spin it round a bit: > > '((png :width :height ...) > (imagemagick :rotation :width ...)) > > Whenever I think about this I get a bit carried away and wonder if we > could do it by image type rather than backend so that we could provide > a function, that you pass an image type and spec to, which finds the > first image backend that can handle it: > > (image-get-type "tiff" > '(:rotation 90 :max-width 20)) > => 'imagemagick > > (image-get-type "jpeg" > '(:rotation 90 :max-width 20)) > => 'jpeg > > I can’t decide if that’s getting a bit silly, though. Let me think about this and propose something. Thanks.