From eb9cc282a86f36202804389660ddf688235f2b9a Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Wed, 8 Mar 2023 19:47:30 +0100 Subject: [PATCH] Fixed an incorrect cropSize calculation which sometimes triggered an assertion. --- es-core/src/components/ImageComponent.cpp | 4 ++-- es-core/src/components/VideoFFmpegComponent.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/es-core/src/components/ImageComponent.cpp b/es-core/src/components/ImageComponent.cpp index 5e04f93f3..2e2c2554d 100644 --- a/es-core/src/components/ImageComponent.cpp +++ b/es-core/src/components/ImageComponent.cpp @@ -206,13 +206,13 @@ void ImageComponent::coverFitCrop() mBottomRightCrop = {1.0f, 1.0f}; if (std::round(mSize.y) > std::round(mTargetSize.y)) { - const float cropSize {1.0f - (mTargetSize.y / mSize.y)}; + const float cropSize {1.0f - (mTargetSize.y / std::round(mSize.y))}; cropTop(cropSize / 2.0f); cropBottom(cropSize / 2.0f); mSize.y = mSize.y - (mSize.y * cropSize); } else { - const float cropSize {1.0f - (mTargetSize.x / mSize.x)}; + const float cropSize {1.0f - (mTargetSize.x / std::round(mSize.x))}; cropLeft(cropSize / 2.0f); cropRight(cropSize / 2.0f); mSize.x = mSize.x - (mSize.x * cropSize); diff --git a/es-core/src/components/VideoFFmpegComponent.cpp b/es-core/src/components/VideoFFmpegComponent.cpp index 45e5b4e33..8e955670b 100644 --- a/es-core/src/components/VideoFFmpegComponent.cpp +++ b/es-core/src/components/VideoFFmpegComponent.cpp @@ -124,13 +124,13 @@ void VideoFFmpegComponent::resize() mSize = textureSize * cropFactor; if (std::round(mSize.y) > std::round(mTargetSize.y)) { - const float cropSize {1.0f - (mTargetSize.y / mSize.y)}; + const float cropSize {1.0f - (mTargetSize.y / std::round(mSize.y))}; mTopLeftCrop.y = cropSize / 2.0f; mBottomRightCrop.y = 1.0f - (cropSize / 2.0f); mSize.y = mSize.y - (mSize.y * cropSize); } else { - const float cropSize {1.0f - (mTargetSize.x / mSize.x)}; + const float cropSize {1.0f - (mTargetSize.x / std::round(mSize.x))}; mTopLeftCrop.x = cropSize / 2.0f; mBottomRightCrop.x = 1.0f - (cropSize / 2.0f); mSize.x = mSize.x - (mSize.x * cropSize);