emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scale transformation of images


From: mituharu
Subject: Re: Scale transformation of images
Date: Sun, 16 Jun 2019 15:45:56 +0900
User-agent: SquirrelMail/1.4.22-5.el6

> 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
                                address@hidden





reply via email to

[Prev in Thread] Current Thread [Next in Thread]