emacs-devel
[Top][All Lists]
Advanced

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

Retain image properties after image-mode commands


From: Joseph Turner
Subject: Retain image properties after image-mode commands
Date: Sun, 03 Mar 2024 22:07:49 -0800

Hello!

I would like to use `image-mode' commands such as
`image-transform-set-scale' on non-file-backed images which have image
properties.  That command internally calls `image-toggle-display-image',
which recontructs the image with `create-image', throwing away any
existing image properties.

A concrete example:

Evalute the following form to render an SVG image in an Emacs buffer:

(with-current-buffer (get-buffer-create "*image-properties-test*")
  (let ((svg-string "<?xml version=\"1.0\" encoding=\"UTF-8\" 
standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n 
\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\";>\n<!-- Generated by 
graphviz version 2.43.0 (0)\n -->\n<!-- Title: orggraphview Pages: 1 -->\n<svg 
width=\"128pt\" height=\"128pt\"\n viewBox=\"0.00 0.00 127.59 127.59\" 
xmlns=\"http://www.w3.org/2000/svg\"; 
xmlns:xlink=\"http://www.w3.org/1999/xlink\";>\n<g id=\"graph0\" class=\"graph\" 
transform=\"scale(1 1) rotate(0) translate(4 
123.59)\">\n<title>orggraphview</title>\n<polygon fill=\"white\" 
stroke=\"transparent\" points=\"-4,4 -4,-123.59 123.59,-123.59 123.59,4 
-4,4\"/>\n<!-- a -->\n<g id=\"node1\" class=\"node\">\n<title>a</title>\n<g 
id=\"a_node1\"><a xlink:href=\"1\" xlink:title=\"Hover me!\">\n<ellipse 
fill=\"none\" stroke=\"black\" cx=\"59.79\" cy=\"-59.79\" rx=\"59.59\" 
ry=\"59.59\"/>\n<text text-anchor=\"middle\" x=\"59.79\" y=\"-56.09\" 
font-family=\"Times,serif\" font-size=\"14.00\" fill=\"#000000\">Hover 
me!</text>\n</a>\n</g>\n</g>\n</g>\n</svg>\n")
        (map '(((circle (85 . 85) . 80) "1" (help-echo "Surprise!"))))
        (inhibit-read-only t))
    (fundamental-mode)
    (erase-buffer)
    (insert-image (create-image svg-string 'svg t :map map) svg-string)
    (image-mode)
    (pop-to-buffer (current-buffer))))

Mouse over the circle in the center of the SVG to see the tooltip.

Then zoom in on the image: Interactively run `image-transform-set-scale'
by pressing "s s" then type the number 2 and press RET.

The image gets bigger, but now mousing over the circle has no effect.

How can I keep the mouse-over effect (the image :map property) after
running `image-mode' commands which reconstruct the image?

Thank you!!

Joseph



reply via email to

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