From: mituharu@math.s.chiba-u.ac.jp
To: "Eli Zaretskii" <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Scale transformation of images
Date: Sun, 16 Jun 2019 15:45:56 +0900 [thread overview]
Message-ID: <febb95415944134cdb5fecddea42da18.squirrel@weber.math.s.chiba-u.ac.jp> (raw)
In-Reply-To: <8475F4F0-00E8-44A9-BD60-6D3894E86EB0@gnu.org>
> 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 = 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
next prev parent reply other threads:[~2019-06-16 6:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-16 6:16 Scale transformation of images Eli Zaretskii
2019-06-16 6:45 ` mituharu [this message]
2019-06-16 7:54 ` Eli Zaretskii
2019-06-16 8:10 ` mituharu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=febb95415944134cdb5fecddea42da18.squirrel@weber.math.s.chiba-u.ac.jp \
--to=mituharu@math.s.chiba-u.ac.jp \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).