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