[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scale transformation of images
From: |
Eli Zaretskii |
Subject: |
Re: Scale transformation of images |
Date: |
Sun, 16 Jun 2019 10:54:09 +0300 |
User-agent: |
K-9 Mail for Android |
On June 16, 2019 9:45:56 AM GMT+03:00, address@hidden wrote:
> > 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.
Thanks. So you are saying that in the equations presented by Richard in
https://lists.gnu.org/archive/html/emacs-devel/2019-06/msg00361.html the matrix
Fij is the inverse of the matrix computed in image_set_transform, is that right?