mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Fixed an incorrect cropSize calculation which sometimes triggered an assertion.
This commit is contained in:
parent
787164b438
commit
eb9cc282a8
|
@ -206,13 +206,13 @@ void ImageComponent::coverFitCrop()
|
||||||
mBottomRightCrop = {1.0f, 1.0f};
|
mBottomRightCrop = {1.0f, 1.0f};
|
||||||
|
|
||||||
if (std::round(mSize.y) > std::round(mTargetSize.y)) {
|
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);
|
cropTop(cropSize / 2.0f);
|
||||||
cropBottom(cropSize / 2.0f);
|
cropBottom(cropSize / 2.0f);
|
||||||
mSize.y = mSize.y - (mSize.y * cropSize);
|
mSize.y = mSize.y - (mSize.y * cropSize);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
cropLeft(cropSize / 2.0f);
|
||||||
cropRight(cropSize / 2.0f);
|
cropRight(cropSize / 2.0f);
|
||||||
mSize.x = mSize.x - (mSize.x * cropSize);
|
mSize.x = mSize.x - (mSize.x * cropSize);
|
||||||
|
|
|
@ -124,13 +124,13 @@ void VideoFFmpegComponent::resize()
|
||||||
mSize = textureSize * cropFactor;
|
mSize = textureSize * cropFactor;
|
||||||
|
|
||||||
if (std::round(mSize.y) > std::round(mTargetSize.y)) {
|
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;
|
mTopLeftCrop.y = cropSize / 2.0f;
|
||||||
mBottomRightCrop.y = 1.0f - (cropSize / 2.0f);
|
mBottomRightCrop.y = 1.0f - (cropSize / 2.0f);
|
||||||
mSize.y = mSize.y - (mSize.y * cropSize);
|
mSize.y = mSize.y - (mSize.y * cropSize);
|
||||||
}
|
}
|
||||||
else {
|
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;
|
mTopLeftCrop.x = cropSize / 2.0f;
|
||||||
mBottomRightCrop.x = 1.0f - (cropSize / 2.0f);
|
mBottomRightCrop.x = 1.0f - (cropSize / 2.0f);
|
||||||
mSize.x = mSize.x - (mSize.x * cropSize);
|
mSize.x = mSize.x - (mSize.x * cropSize);
|
||||||
|
|
Loading…
Reference in a new issue