summaryrefslogtreecommitdiff
path: root/src/graphics/Graphics.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-07-28 17:38:34 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-07-28 17:38:34 (GMT)
commitc14a008d463dab4e6e2168fa28afb26384432b36 (patch)
treefece974b4df3a93b48393ceda3e6ec1d8e070164 /src/graphics/Graphics.cpp
parentca1f81a26423fd9c86bb76b20e9992db7204fa4f (diff)
downloadpowder-c14a008d463dab4e6e2168fa28afb26384432b36.zip
powder-c14a008d463dab4e6e2168fa28afb26384432b36.tar.gz
Corrections to GameSave to prevent conflicts in the Expanded state, improve Save preview comments display
Diffstat (limited to 'src/graphics/Graphics.cpp')
-rw-r--r--src/graphics/Graphics.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/graphics/Graphics.cpp b/src/graphics/Graphics.cpp
index ac6878c..20f5851 100644
--- a/src/graphics/Graphics.cpp
+++ b/src/graphics/Graphics.cpp
@@ -1,4 +1,5 @@
#include <cmath>
+#include <iostream>
#include <bzlib.h>
#include <string>
#include "Config.h"
@@ -330,6 +331,9 @@ pixel *Graphics::resample_img_nn(pixel * src, int sw, int sh, int rw, int rh)
pixel *Graphics::resample_img(pixel *src, int sw, int sh, int rw, int rh)
{
+#ifdef DEBUG
+ std::cout << "Resampling " << sw << "x" << sh << " to " << rw << "x" << rh << std::endl;
+#endif
int y, x, fxceil, fyceil;
//int i,j,x,y,w,h,r,g,b,c;
pixel *q = NULL;
@@ -337,7 +341,7 @@ pixel *Graphics::resample_img(pixel *src, int sw, int sh, int rw, int rh)
//Don't resample
q = (pixel *)malloc(rw*rh*PIXELSIZE);
memcpy(q, src, rw*rh*PIXELSIZE);
- } else if(rw > sw && rh > sh){
+ } else if(rw >= sw && rh >= sh){
float fx, fy, fyc, fxc;
double intp;
pixel tr, tl, br, bl;
@@ -376,14 +380,16 @@ pixel *Graphics::resample_img(pixel *src, int sw, int sh, int rw, int rh)
rw = sw;
rh = sh;
while(rrw != rw && rrh != rh){
- rw *= 0.7;
- rh *= 0.7;
- if(rw <= rrw || rh <= rrh){
+ if(rw > rrw)
+ rw *= 0.7;
+ if(rh > rrh)
+ rh *= 0.7;
+ if(rw <= rrw)
rw = rrw;
+ if(rh <= rrh)
rh = rrh;
- }
q = (pixel *)malloc(rw*rh*PIXELSIZE);
- //Bilinear interpolation for upscaling
+ //Bilinear interpolation
for (y=0; y<rh; y++)
for (x=0; x<rw; x++)
{