mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-26 08:05:38 +00:00
Fix for image resize flicker when using MaxSize
This commit is contained in:
parent
0928498ef2
commit
68dff607c8
|
@ -58,17 +58,16 @@ void ImageComponent::resize()
|
||||||
|
|
||||||
if(resizeScale.x() < resizeScale.y())
|
if(resizeScale.x() < resizeScale.y())
|
||||||
{
|
{
|
||||||
mSize[0] *= resizeScale.x();
|
mSize[0] *= resizeScale.x(); // this will be mTargetSize.x(). We can't exceed it, nor be lower than it.
|
||||||
mSize[1] *= resizeScale.x();
|
// we need to make sure we're not creating an image larger than max size
|
||||||
|
mSize[1] = Math::min(Math::round(mSize[1] *= resizeScale.x()), mTargetSize.y());
|
||||||
}else{
|
}else{
|
||||||
mSize[0] *= resizeScale.y();
|
mSize[1] = Math::round(mSize[1] *= resizeScale.y()); // this will be mTargetSize.y(). We can't exceed it.
|
||||||
mSize[1] *= resizeScale.y();
|
|
||||||
}
|
|
||||||
|
|
||||||
// for SVG rasterization, always calculate width from rounded height (see comment above)
|
// for SVG rasterization, always calculate width from rounded height (see comment above)
|
||||||
mSize[1] = Math::round(mSize[1]);
|
// we need to make sure we're not creating an image larger than max size
|
||||||
mSize[0] = (mSize[1] / textureSize.y()) * textureSize.x();
|
mSize[0] = Math::min((mSize[1] / textureSize.y()) * textureSize.x(), mTargetSize.x());
|
||||||
|
}
|
||||||
}else if(mTargetIsMin)
|
}else if(mTargetIsMin)
|
||||||
{
|
{
|
||||||
mSize = textureSize;
|
mSize = textureSize;
|
||||||
|
@ -91,8 +90,9 @@ void ImageComponent::resize()
|
||||||
}
|
}
|
||||||
|
|
||||||
// for SVG rasterization, always calculate width from rounded height (see comment above)
|
// for SVG rasterization, always calculate width from rounded height (see comment above)
|
||||||
mSize[1] = Math::round(mSize[1]);
|
// we need to make sure we're not creating an image smaller than min size
|
||||||
mSize[0] = (mSize[1] / textureSize.y()) * textureSize.x();
|
mSize[1] = Math::max(Math::round(mSize[1]), mTargetSize.y());
|
||||||
|
mSize[0] = Math::max((mSize[1] / textureSize.y()) * textureSize.x(), mTargetSize.x());
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
// if both components are set, we just stretch
|
// if both components are set, we just stretch
|
||||||
|
|
Loading…
Reference in a new issue