From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Testing native image scaling Date: Sun, 20 Jan 2019 18:05:18 +0200 Message-ID: <834la3b9hd.fsf@gnu.org> References: <83fttpat8p.fsf@gnu.org> <20190119214543.GA13967@breton.holly.idiocy.org> NNTP-Posting-Host: ciao.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ciao.gmane.org 1548000338 105018 195.159.176.228 (20 Jan 2019 16:05:38 GMT) X-Complaints-To: usenet@ciao.gmane.org NNTP-Posting-Date: Sun, 20 Jan 2019 16:05:38 +0000 (UTC) Cc: emacs-devel@gnu.org To: Alan Third Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 20 17:05:36 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1glFbK-000RJb-VO for ged-emacs-devel@m.gmane.org; Sun, 20 Jan 2019 17:05:35 +0100 Original-Received: from localhost ([127.0.0.1]:41440 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1glFbT-00058h-QB for ged-emacs-devel@m.gmane.org; Sun, 20 Jan 2019 11:05:43 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:44351) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1glFbO-00058V-7h for emacs-devel@gnu.org; Sun, 20 Jan 2019 11:05:39 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:49885) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1glFbN-0003Yx-RX; Sun, 20 Jan 2019 11:05:37 -0500 Original-Received: from [176.228.60.248] (port=3021 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1glFbK-0002bN-R8; Sun, 20 Jan 2019 11:05:35 -0500 In-reply-to: <20190119214543.GA13967@breton.holly.idiocy.org> (message from Alan Third on Sat, 19 Jan 2019 21:45:43 +0000) 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.21 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:232542 Archived-At: > Date: Sat, 19 Jan 2019 21:45:43 +0000 > From: Alan Third > Cc: emacs-devel@gnu.org > > On Sat, Jan 19, 2019 at 11:31:34AM +0200, Eli Zaretskii wrote: > > Alan, could you please tell how you tested native image scaling with > > the XRENDER extension, and perhaps show some Lisp or existing commands > > you used for that? E.g., did the features in thumbs.el work for you > > in a build without Imagemagick? > > I just used a fairly simple series of commands like this: > > (setq i (create-image "~/image.png" nil nil :scale 0.5)) > (insert-image i) > (setq ii (create-image "~/image.png" nil nil :scale 0.5)) > (insert "\n") > (insert-image ii) Thanks, this was very helpful. (Actually, just create-image with one argument is enough: after inserting it, '+' or '-' on the image will interactively resize it.) > It look like thumbs.el uses ImageMagick’s convert program directly, so > it won’t be affected by native scaling. Ah, okay, I missed that. image-dired seems to do the same. I guess we should at some point update those (and others) to use the native resizing. > > I tried to implement this for MS-Windows, but I guess my understanding > > of the internal workings of this is incomplete/incorrect, or my code > > is buggy (or both), because I don't seem to be able to cause Emacs to > > exercise the code when the original image's size and the size > > requested by scaling differ. For example, I thought that when scaling > > is requested, x_set_image_size should be called and compute image > > dimensions different from the original img->height and img->width, but > > I seem to be unable to see this. What am I missing? Could you > > perhaps describe the flow of calls when, e.g., the user types '+' on > > an image in image-mode, and Emacs scales the image at point? > > I think you understand this right. > > x_set_image_size calculates the new sizes, does the conversion, and > writes those new sizes back into struct image, over‐writing the > original sizes. > > For NS it also asks the NSImage back‐end to scale the image using > ns_image_set_size, which in effect does the actual scaling. > > For XRender it sets up an affine transformation matrix, and applies it > to img->picture, which also in effect does the actual scaling. > > The compositing functions in nsterm.m and xterm.c don’t need to know > the original image size, just the new size, and NSImage/XRender > handles the rest. Well, on w32, the implementation actually resizes when it draws. Maybe that's sub-optimal, but I know next to nothing about w32 image display, so what I got looks definitely fine for my ignorance. So we now have native resizing on all major platforms. > We could use XRender to rotate images if we really wanted to, and the > NS port already supports it. Where's the NS support for that? AFAICT, :rotate is only handled in ImageMagick specific portions of the code, what did I miss? Thanks.