]> git.eshelyaron.com Git - emacs.git/commit
Recompute :map when image :scale, :rotation, or :flip changes
authorJoseph Turner <joseph@breatheoutbreathe.in>
Fri, 8 Mar 2024 05:55:00 +0000 (21:55 -0800)
committerEshel Yaron <me@eshelyaron.com>
Sun, 24 Mar 2024 14:21:31 +0000 (15:21 +0100)
commitd650719205cc526e085ffb4d5266626de41ac0c1
tree25f8d26397f10b354317a42f3ca6c2f27e225c54
parentd1138abe7a177ff0f90e4a0ea03676ba7e185cfe
Recompute :map when image :scale, :rotation, or :flip changes

Now, when transforming an image, its :map is recomputed to fit.
Image map coordinates are integers, so when computing :map,
coordinates are rounded.  To prevent an image from drifting from
its map after repeated transformations, 'create-image' now adds
a new image property :original-map, which is combined with the
image's transformation parameters to recompute :map.

* lisp/image.el (image-recompute-map-p): Add user option to
control whether :map is recomputed when an image is transformed.
(create-image): Create :map from :original-map and vice versa.
(image--delayed-change-size): Fix comment.
(image--change-size, image-rotate, image-flip-horizontally,
image-flip-vertically): Recompute image map after transformation
and mention 'image-recompute-map-p' in docstring.
(image--compute-map): Add function to compute a map from original
map.
(image--compute-original-map): Add function to compute an
original map from map.
(image--scale-map): Add function to scale a map based on :scale.
(image--rotate-map): Add function to rotate a map based on
:rotation.
(image--rotate-coord): Add function to rotate a map coordinate
pair.
(image--flip-map): Add function to flip a map based on :flip.
(image-increase-size, image-decrease-size, image-mouse-increase-size)
(image-mouse-decrease-size): Mention 'image-recompute-map-p' in
docstrings.
* etc/NEWS: Add NEWS entry.
* doc/lispref/display.texi (Image Descriptors): Document :original-map
and new user option 'image-recompute-map-p'.
* test/lisp/image-tests.el (image--compute-map-and-original-map):
Test 'image--compute-map' and 'image--compute-original-map'.
(image-tests--map-equal): Add equality predicate to compare image maps.
(image-create-image-with-map): Test that 'create-image' adds :map
and/or :original-map as appropriate.
(image-transform-map): Test functions related to transforming maps.
(Bug#69602)

(cherry picked from commit 79c758187cef7fc1f93fd525b9d81be81ee2b2cc)
doc/lispref/display.texi
etc/NEWS
lisp/image.el
test/lisp/image-tests.el