Skip to content

Commit

Permalink
Fix display of images with different aspect ratios
Browse files Browse the repository at this point in the history
  • Loading branch information
tizian committed Jan 3, 2025
1 parent fe100b9 commit dd9f7c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 3.13...3.18)

set(YEAR "2023")
set(VERSION "2.0.1")
set(YEAR "2025")
set(VERSION "2.0.2")
add_definitions(-D YEAR=\\""${YEAR}"\\")
add_definitions(-D VERSION=\\""${VERSION}"\\")

Expand Down
11 changes: 10 additions & 1 deletion src/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,16 @@ void TonemapperGui::setImage(const std::string &filename) {
}

m_imageDisplayHeight = SCREEN_HEIGHT_DEFAULT;
m_imageDisplayWidth = SCREEN_HEIGHT_DEFAULT * int(m_image->getWidth() / m_image->getHeight());
m_imageDisplayWidth = SCREEN_HEIGHT_DEFAULT;
float ratio = (float) m_image->getWidth() / (float) m_image->getHeight();
if (ratio > 1.f) {
m_imageDisplayHeight = SCREEN_WIDTH_DEFAULT / ratio;
m_imageDisplayWidth = SCREEN_WIDTH_DEFAULT;
} else if (ratio < 1.f) {
m_imageDisplayHeight = SCREEN_HEIGHT_DEFAULT;
m_imageDisplayWidth = SCREEN_HEIGHT_DEFAULT * ratio;
}

m_screenSize = Vector2i(std::max(int(SCREEN_WIDTH_DEFAULT), m_imageDisplayWidth), m_imageDisplayHeight);
set_size(Vector2i(m_screenSize));

Expand Down

0 comments on commit dd9f7c8

Please sign in to comment.