Skip to content

Commit

Permalink
Fixed rescaling calculation when image does not fit in viewport.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Sep 17, 2024
1 parent 69d6885 commit c6d649f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/docs/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ v1.2.8
the command-line.
- Fixed ICS pulldown not showing None when switching to a clip with no
Input Color Space stored.
- Fixed viewport/image ratio calculation in Save Move/Save Single Frame.
- Fixed viewport/image rescaling calculation in Save Move/Save Single Frame.
- Fixed Save Resolution setting being set to Half Size when Save Annotations
was on.
- Made Status Bar error/warnings remain longer (8 seconds instead of 5).
Expand Down
28 changes: 8 additions & 20 deletions src/lib/mrvFl/mrvSaveImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,28 +223,16 @@ namespace mrv

view->frameView();

double viewportRatio =
viewportSize.w /
static_cast<double>(viewportSize.h);
double imageRatio =
renderSize.w / static_cast<double>(renderSize.h);

if (viewportRatio < imageRatio)
{
double factor = viewportSize.h /
static_cast<double>(renderSize.h);
outputInfo.size.w =
std::round(renderSize.w * factor);
outputInfo.size.h = viewportSize.h;
}
else
double zoom =
viewportSize.h / static_cast<double>(renderSize.h);

if (zoom * renderSize.w > viewportSize.w)
{
double factor = viewportSize.w /
static_cast<double>(renderSize.w);
outputInfo.size.h =
std::round(renderSize.h * factor);
outputInfo.size.w = viewportSize.w;
zoom = viewportSize.w / static_cast<double>(renderSize.w);
}

outputInfo.size.w = std::round(renderSize.w * zoom);
outputInfo.size.h = std::round(renderSize.h * zoom);
}

X = (viewportSize.w - outputInfo.size.w) / 2;
Expand Down
28 changes: 8 additions & 20 deletions src/lib/mrvFl/mrvSaveMovie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,28 +463,16 @@ namespace mrv

view->frameView();

double viewportRatio =
viewportSize.w /
static_cast<double>(viewportSize.h);
double imageRatio =
renderSize.w / static_cast<double>(renderSize.h);

if (viewportRatio < imageRatio)
{
double factor = viewportSize.h /
static_cast<double>(renderSize.h);
outputInfo.size.w =
std::round(renderSize.w * factor);
outputInfo.size.h = viewportSize.h;
}
else
double zoom =
viewportSize.h / static_cast<double>(renderSize.h);

if (zoom * renderSize.w > viewportSize.w)
{
double factor = viewportSize.w /
static_cast<double>(renderSize.w);
outputInfo.size.h =
std::round(renderSize.h * factor);
outputInfo.size.w = viewportSize.w;
zoom = viewportSize.w / static_cast<double>(renderSize.w);
}

outputInfo.size.w = std::round(renderSize.w * zoom);
outputInfo.size.h = std::round(renderSize.h * zoom);
}

X = (viewportSize.w - outputInfo.size.w) / 2;
Expand Down

0 comments on commit c6d649f

Please sign in to comment.