Fixed an incorrect cropSize calculation which sometimes triggered an assertion.

This commit is contained in:
Leon Styhre 2023-03-08 19:47:30 +01:00
parent 787164b438
commit eb9cc282a8
2 changed files with 4 additions and 4 deletions

View file

@ -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);

View file

@ -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);