Skip to content

Commit

Permalink
Fix transformation mode for layers (#998)
Browse files Browse the repository at this point in the history
* Fix transformation mode for layers

Resolve #997

* always use smooth transform resampling for stretched images

* Used fixed frame size

* Run Clang Format over file

---------

Co-authored-by: in1tiate <[email protected]>
Co-authored-by: Salanto <[email protected]>
Co-authored-by: stonedDiscord <[email protected]>
  • Loading branch information
4 people authored Jul 9, 2024
1 parent 81ca470 commit 8a98de8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/animationlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ void AnimationLayer::calculateFrameGeometry()
{
m_mask_rect = QRect();
m_scaled_frame_size = QSize();
m_transformation_mode = m_transformation_mode_hint;

QSize widget_size = size();
if (!widget_size.isValid() || !m_frame_size.isValid())
Expand All @@ -239,6 +240,7 @@ void AnimationLayer::calculateFrameGeometry()
if (m_stretch_to_fit)
{
m_scaled_frame_size = widget_size;
m_transformation_mode = Qt::SmoothTransformation;
}
else
{
Expand All @@ -251,11 +253,11 @@ void AnimationLayer::calculateFrameGeometry()

double scale = double(widget_size.height()) / double(m_scaled_frame_size.height());
m_scaled_frame_size *= scale;
}

if (m_transformation_mode_hint == Qt::FastTransformation)
{
m_transformation_mode = scale < 1.0 ? Qt::SmoothTransformation : Qt::FastTransformation;
}
if (m_transformation_mode_hint == Qt::FastTransformation)
{
m_transformation_mode = widget_size.height() < m_frame_size.height() ? Qt::SmoothTransformation : Qt::FastTransformation;
}

displayCurrentFrame();
Expand Down

0 comments on commit 8a98de8

Please sign in to comment.