fix fixedRatio when VideoBuffer::Resize'ing, fixes #121
This commit is contained in:
parent
f1145f31f5
commit
fea920d608
@ -67,13 +67,10 @@ void VideoBuffer::Resize(int width, int height, bool resample, bool fixedRatio)
|
|||||||
else if(fixedRatio)
|
else if(fixedRatio)
|
||||||
{
|
{
|
||||||
//Force proportions
|
//Force proportions
|
||||||
float scaleFactor = 1.0f;
|
if(newWidth*Height > newHeight*Width) // same as nW/W > nH/H
|
||||||
if(Height > newHeight)
|
newWidth = (int)(Width * (newHeight/(float)Height));
|
||||||
scaleFactor = ((float)newHeight)/((float)Height);
|
else
|
||||||
if(Width > newWidth)
|
newHeight = (int)(Height * (newWidth/(float)Width));
|
||||||
scaleFactor = ((float)newWidth)/((float)Width);
|
|
||||||
newWidth = ((float)Width)*scaleFactor;
|
|
||||||
newHeight = ((float)Height)*scaleFactor;
|
|
||||||
}
|
}
|
||||||
if(resample)
|
if(resample)
|
||||||
newBuffer = Graphics::resample_img(Buffer, Width, Height, newWidth, newHeight);
|
newBuffer = Graphics::resample_img(Buffer, Width, Height, newWidth, newHeight);
|
||||||
|
Loading…
Reference in New Issue
Block a user