From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: mituharu@math.s.chiba-u.ac.jp Newsgroups: gmane.emacs.devel Subject: Re: Scale transformation of images Date: Sun, 16 Jun 2019 15:45:56 +0900 Message-ID: References: <8475F4F0-00E8-44A9-BD60-6D3894E86EB0@gnu.org> Mime-Version: 1.0 Content-Type: text/plain;charset=iso-2022-jp Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="142496"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: SquirrelMail/1.4.22-5.el6 Cc: emacs-devel@gnu.org To: "Eli Zaretskii" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jun 16 08:46:21 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 1hcOvk-000arX-W7 for ged-emacs-devel@m.gmane.org; Sun, 16 Jun 2019 08:46:21 +0200 Original-Received: from localhost ([::1]:37800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcOvj-00084f-Fo for ged-emacs-devel@m.gmane.org; Sun, 16 Jun 2019 02:46:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42194) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcOvV-00084W-DI for emacs-devel@gnu.org; Sun, 16 Jun 2019 02:46:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcOvT-00077r-FL for emacs-devel@gnu.org; Sun, 16 Jun 2019 02:46:05 -0400 Original-Received: from mathmail.math.s.chiba-u.ac.jp ([133.82.132.2]:60046) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hcOvO-00070E-Vn; Sun, 16 Jun 2019 02:45:59 -0400 Original-Received: from weber.math.s.chiba-u.ac.jp (weber [192.168.32.4]) by mathmail.math.s.chiba-u.ac.jp (Postfix) with ESMTP id 17D25F08DA; Sun, 16 Jun 2019 15:45:56 +0900 (JST) (envelope-from mituharu@math.s.chiba-u.ac.jp) Original-Received: from 223.218.225.84 (SquirrelMail authenticated user mituharu) by weber.math.s.chiba-u.ac.jp with HTTP; Sun, 16 Jun 2019 15:45:56 +0900 In-Reply-To: <8475F4F0-00E8-44A9-BD60-6D3894E86EB0@gnu.org> X-Priority: 3 (Normal) Importance: Normal X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 133.82.132.2 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:237715 Archived-At: > If I insert an image into a buffer with insert-image, and then position > point on the image and press '-' to make it smaller, the scale factors = I > see in the transform matrix are greater than 1. This is because > image_set_size does this: > > double xscale =3D img->width / (double) width; > > and similarly for yscale. Shouldn't we divide width by img->width > instead? No. Documentation of cairo_pattern_set_matrix and its example would help you understand what's happening: https://www.cairographics.org/manual/cairo-cairo-pattern-t.html Important: Please note that the direction of this transformation matrix is from user space to pattern space. This means that if you imagine the flow from a pattern to user space (and on to device space), then coordinates in that flow will be transformed by the inverse of the pattern matrix. For example, if you want to make a pattern appear twice as large as it does by default the correct code to use is: 1 cairo_matrix_init_scale (&matrix, 0.5, 0.5); 2 cairo_pattern_set_matrix (pattern, &matrix); Meanwhile, using values of 2.0 rather than 0.5 in the code above would cause the pattern to appear at half of its default size. YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp