olive-groves / butterfly_viewer

Side-by-side image viewer with synchronized zoom and sliding overlays. Drag and drop to instantly compare multiple images on your desktop. Very open source.
https://olive-groves.github.io/butterfly_viewer/
Other
27 stars 4 forks source link

[Bug] The relative pan and zoom is not preserved (locked) when turning synchronisation back on #61

Open NEKolev opened 3 months ago

NEKolev commented 3 months ago

Is there an existing issue for this?

Current behavior

When I turn off the synchronisation between the images to adjust one of the images and then turn the synchronisation back on, the images return to their original state. In my opinion, the expected behaviour is for the images to “lock” as I have aligned them.

https://github.com/olive-groves/butterfly_viewer/assets/70388317/58bb93d6-941d-43e4-a951-617ee71d9965

Expected behavior

No response

Steps to reproduce

No response

Anything else?

When zoomed in, red pixels from the mouse cursor can be seen, which do not clear after the mouse cursor is no longer in that place. It can be seen at the end of the clip, I don’t know if this is normal behaviour.

larsmaxfield commented 3 months ago

This is not a bug but rather the current expected behavior. You can think of turning off synchronization as pausing the synchronization, with turning it back on as resuming the synchronization.

Nevertheless it would make a good new feature ;-)

*And the red outline at the mouse's position which you see when overzooming the image is a feature. I originally added that to show users where each pixel was because upsampling was then an always-on feature, making it difficult to see individual pixels. It also helps to see the extent of zoom with upsampling on.

**The video you added doesn't play for me: image

larsmaxfield commented 3 months ago

Implementation notes:

I had previously thought of adding this preserve/lock/freeze/trim feature while developing automatic scaling but didn't due to time. I think FastStone implements this, and it would indeed make it more easy to compare non-registered images like this:

  1. Add images to the Viewer
  2. Turn sync off
  3. Pan and/or zoom each image to align their shared features
  4. Turn sync back on with the enabled option to preserve pan and zoom adjustments

This requires tracking each image window's adjusted pan and zoom and applying it during synced movement. It would be straightforward if the values are relative to unity, for example "1" being no adjustment, "2" being double zoom, "0.5" being half, and then when an image window of "2" is moved it causes a window of "1" to move "1/2", a window of "0.5" to move "0.5/2", etc.

Zoom might be just a multiplication factor to the zoom transform. Pan might just be an addition factor of the scrollbar position.

NEKolev commented 3 months ago

https://ibb.co/fkwr42f