summaryrefslogtreecommitdiff
path: root/src/graphics/Graphics.cpp
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2013-03-08 03:14:00 (GMT)
committer jacob1 <jfu614@gmail.com>2013-03-08 03:14:00 (GMT)
commit77d233240f7f1e61f2fb3d9eba45558c56ad8d7e (patch)
treec47707141ae057b86baa7231d52a13eabcf45706 /src/graphics/Graphics.cpp
parenta411fda7de787c091be028f2fe9af865c5274f2e (diff)
downloadpowder-77d233240f7f1e61f2fb3d9eba45558c56ad8d7e.zip
powder-77d233240f7f1e61f2fb3d9eba45558c56ad8d7e.tar.gz
fix mismatched malloc/delete[]'s when not using new image resampler
Diffstat (limited to 'src/graphics/Graphics.cpp')
-rw-r--r--src/graphics/Graphics.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/graphics/Graphics.cpp b/src/graphics/Graphics.cpp
index f851965..068cc5d 100644
--- a/src/graphics/Graphics.cpp
+++ b/src/graphics/Graphics.cpp
@@ -413,13 +413,13 @@ pixel *Graphics::resample_img(pixel *src, int sw, int sh, int rw, int rh)
pixel *q = NULL;
if(rw == sw && rh == sh){
//Don't resample
- q = (pixel *)malloc(rw*rh*PIXELSIZE);
- memcpy(q, src, rw*rh*PIXELSIZE);
+ q = new pixel[rw*rh];
+ std::copy(src, src+(rw*rh), q);
} else if(!stairstep) {
float fx, fy, fyc, fxc;
double intp;
pixel tr, tl, br, bl;
- q = (pixel *)malloc(rw*rh*PIXELSIZE);
+ q = new pixel[rw*rh];
//Bilinear interpolation for upscaling
for (y=0; y<rh; y++)
for (x=0; x<rw; x++)
@@ -449,8 +449,8 @@ pixel *Graphics::resample_img(pixel *src, int sw, int sh, int rw, int rh)
pixel tr, tl, br, bl;
int rrw = rw, rrh = rh;
pixel * oq;
- oq = (pixel *)malloc(sw*sh*PIXELSIZE);
- memcpy(oq, src, sw*sh*PIXELSIZE);
+ oq = new pixel[sw*sh];
+ std::copy(src, src+(sw*sh), oq);
rw = sw;
rh = sh;
while(rrw != rw && rrh != rh){
@@ -462,7 +462,7 @@ pixel *Graphics::resample_img(pixel *src, int sw, int sh, int rw, int rh)
rw = rrw;
if(rh <= rrh)
rh = rrh;
- q = (pixel *)malloc(rw*rh*PIXELSIZE);
+ q = new pixel[rw*rh];
//Bilinear interpolation
for (y=0; y<rh; y++)
for (x=0; x<rw; x++)
@@ -485,7 +485,7 @@ pixel *Graphics::resample_img(pixel *src, int sw, int sh, int rw, int rh)
(int)(((((float)PIXB(tl))*(1.0f-fxc))+(((float)PIXB(tr))*(fxc)))*(1.0f-fyc) + ((((float)PIXB(bl))*(1.0f-fxc))+(((float)PIXB(br))*(fxc)))*(fyc))
);
}
- free(oq);
+ delete[] oq;
oq = q;
sw = rw;
sh = rh;