summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormniip <mniip@mniip.com>2013-09-02 14:03:43 (GMT)
committer mniip <mniip@mniip.com>2013-09-02 14:03:43 (GMT)
commitfea920d608c15ba095e5c2e5a55d4ec358e0a8e2 (patch)
treefe52b63d88a5c2f707ffe5b63d4157220f7ce534
parentf1145f31f52f1089fed4c7f390f5384f040b4771 (diff)
downloadpowder-fea920d608c15ba095e5c2e5a55d4ec358e0a8e2.zip
powder-fea920d608c15ba095e5c2e5a55d4ec358e0a8e2.tar.gz
fix fixedRatio when VideoBuffer::Resize'ing, fixes #121
-rw-r--r--src/graphics/Graphics.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/graphics/Graphics.cpp b/src/graphics/Graphics.cpp
index d4e2956..aa00821 100644
--- a/src/graphics/Graphics.cpp
+++ b/src/graphics/Graphics.cpp
@@ -67,13 +67,10 @@ void VideoBuffer::Resize(int width, int height, bool resample, bool fixedRatio)
else if(fixedRatio)
{
//Force proportions
- float scaleFactor = 1.0f;
- if(Height > newHeight)
- scaleFactor = ((float)newHeight)/((float)Height);
- if(Width > newWidth)
- scaleFactor = ((float)newWidth)/((float)Width);
- newWidth = ((float)Width)*scaleFactor;
- newHeight = ((float)Height)*scaleFactor;
+ if(newWidth*Height > newHeight*Width) // same as nW/W > nH/H
+ newWidth = (int)(Width * (newHeight/(float)Height));
+ else
+ newHeight = (int)(Height * (newWidth/(float)Width));
}
if(resample)
newBuffer = Graphics::resample_img(Buffer, Width, Height, newWidth, newHeight);