Skip to content

fix(iv): 'save window' saves only the visible region - #5479

Merged
lgritz merged 1 commit into
AcademySoftwareFoundation:mainfrom
orelsin:fix/iv-save-window-roi
Sep 21, 2026
Merged

lgritz merged 1 commit into
AcademySoftwareFoundation:mainfrom
orelsin:fix/iv-save-window-roi

Conversation

@orelsin

@orelsin orelsin commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Issue: "Save Window As..." called ImageBuf::write() on the whole image, which made it do exactly the same thing as "Save As...".

Add IvGL::get_visible_image_roi(), which maps the two opposite corners, sorts out which is the min and which is the max, and intersects the result with the data window so only real pixels come back.
saveWindowAs() then writes ImageBufAlgo::cut() of that region instead of the whole buffer, returns an error if nothing is visible.

Closes #4716

Assisted-by: Claude Code / Claude Opus 5

@linux-foundation-easycla

linux-foundation-easycla Bot commented Sep 17, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: orelsin / name: Aurele Boquet (6a7a1d3)

@orelsin
orelsin force-pushed the fix/iv-save-window-roi branch 2 times, most recently from 8fee93f to 34ab58f Compare September 17, 2026 15:04
@lgritz

lgritz commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Need CLA and formatting fix.

I built it on my side, and it did not behave quite like I expected.

Maybe we should establish a common understanding of what this does. What do you think is the difference between

  • save as
  • save window as
  • save selection as

Trying them on my end, I could discern no difference at all. Now I'm a little confused about what we originally wanted and/or really should do.

I have some ideas, but before I pollute the space with my notions, I'd like to hear what you and others think.

What was your recipe for testing this? Do you have a sequence of actions that results in different saved results for the three menu choices?

@lgritz

lgritz commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Wait! I take it back!

I was testing the wrong branch.

This does seem to work -- "save window as" does save the part of the image that's visible in the window as a separate image. So you can zoom, adjust window boundaries, etc., and it acts as a cropping tool.

Comment thread src/iv/imageviewer.cpp Outdated
@orelsin
orelsin force-pushed the fix/iv-save-window-roi branch from cba984e to 6a7a1d3 Compare September 18, 2026 14:13
@lgritz

lgritz commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Seems to be failing CI.

Signed-off-by: Aurele Boquet <aurele.boquet@gmail.com>
@orelsin
orelsin force-pushed the fix/iv-save-window-roi branch from 6a7a1d3 to 81a7656 Compare September 21, 2026 12:44
@orelsin

orelsin commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

I had to rebase, there was a refactoring of IvGL which removed the variable m_current_image and replaced it with an image-slot array. I changed the cerr << statements to OIIO::print(stderr, ‘...’) and added the TODOs.

@lgritz lgritz added bug Crash or wrong behavior of an existing feature. iv Image viewer devdays26 Dev Days 2026 labels Sep 21, 2026

@lgritz lgritz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@lgritz
lgritz merged commit 87530a8 into AcademySoftwareFoundation:main Sep 21, 2026
60 of 61 checks passed
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request Sep 21, 2026
…Foundation#5479)

Issue: "Save Window As..." called ImageBuf::write() on the whole image,
which made it do exactly the same thing as "Save As...".

Add IvGL::get_visible_image_roi(), which maps the two opposite corners,
sorts out which is the min and which is the max, and intersects the
result with the data window so only real pixels come back.
saveWindowAs() then writes ImageBufAlgo::cut() of that region instead of
the whole buffer, returns an error if nothing is visible.

Closes AcademySoftwareFoundation#4716  

Assisted-by: Claude Code / Claude Opus 5

Signed-off-by: Aurele Boquet <aurele.boquet@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Crash or wrong behavior of an existing feature. devdays26 Dev Days 2026 iv Image viewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iv: "Save window" doesn't work -- it saves the whole image

2 participants