unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Scale transformation of images
@ 2019-06-16  6:16 Eli Zaretskii
  2019-06-16  6:45 ` mituharu
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2019-06-16  6:16 UTC (permalink / raw)
  To: emacs-devel

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?



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Scale transformation of images
  2019-06-16  6:16 Scale transformation of images Eli Zaretskii
@ 2019-06-16  6:45 ` mituharu
  2019-06-16  7:54   ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: mituharu @ 2019-06-16  6:45 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

> 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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Scale transformation of images
  2019-06-16  6:45 ` mituharu
@ 2019-06-16  7:54   ` Eli Zaretskii
  2019-06-16  8:10     ` mituharu
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2019-06-16  7:54 UTC (permalink / raw)
  To: emacs-devel, mituharu

On June 16, 2019 9:45:56 AM GMT+03:00, mituharu@math.s.chiba-u.ac.jp 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?



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Scale transformation of images
  2019-06-16  7:54   ` Eli Zaretskii
@ 2019-06-16  8:10     ` mituharu
  0 siblings, 0 replies; 4+ messages in thread
From: mituharu @ 2019-06-16  8:10 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: mituharu, emacs-devel

> 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?

The equations themselves are correct, but the source and destination
spaces are implicit.
I would say the directions of the conversions you and Richard are thinking
about are inverse each other.
See also item 2 in my previous post:
https://lists.gnu.org/archive/html/emacs-devel/2019-06/msg00405.html

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-16  8:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-16  6:16 Scale transformation of images Eli Zaretskii
2019-06-16  6:45 ` mituharu
2019-06-16  7:54   ` Eli Zaretskii
2019-06-16  8:10     ` mituharu

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).