mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-01 20:12:50 +02:00
fix mismatched malloc/delete[]'s when not using new image resampler
This commit is contained in:
@@ -413,13 +413,13 @@ pixel *Graphics::resample_img(pixel *src, int sw, int sh, int rw, int rh)
|
|||||||
pixel *q = NULL;
|
pixel *q = NULL;
|
||||||
if(rw == sw && rh == sh){
|
if(rw == sw && rh == sh){
|
||||||
//Don't resample
|
//Don't resample
|
||||||
q = (pixel *)malloc(rw*rh*PIXELSIZE);
|
q = new pixel[rw*rh];
|
||||||
memcpy(q, src, rw*rh*PIXELSIZE);
|
std::copy(src, src+(rw*rh), q);
|
||||||
} else if(!stairstep) {
|
} else if(!stairstep) {
|
||||||
float fx, fy, fyc, fxc;
|
float fx, fy, fyc, fxc;
|
||||||
double intp;
|
double intp;
|
||||||
pixel tr, tl, br, bl;
|
pixel tr, tl, br, bl;
|
||||||
q = (pixel *)malloc(rw*rh*PIXELSIZE);
|
q = new pixel[rw*rh];
|
||||||
//Bilinear interpolation for upscaling
|
//Bilinear interpolation for upscaling
|
||||||
for (y=0; y<rh; y++)
|
for (y=0; y<rh; y++)
|
||||||
for (x=0; x<rw; x++)
|
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;
|
pixel tr, tl, br, bl;
|
||||||
int rrw = rw, rrh = rh;
|
int rrw = rw, rrh = rh;
|
||||||
pixel * oq;
|
pixel * oq;
|
||||||
oq = (pixel *)malloc(sw*sh*PIXELSIZE);
|
oq = new pixel[sw*sh];
|
||||||
memcpy(oq, src, sw*sh*PIXELSIZE);
|
std::copy(src, src+(sw*sh), oq);
|
||||||
rw = sw;
|
rw = sw;
|
||||||
rh = sh;
|
rh = sh;
|
||||||
while(rrw != rw && rrh != rh){
|
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;
|
rw = rrw;
|
||||||
if(rh <= rrh)
|
if(rh <= rrh)
|
||||||
rh = rrh;
|
rh = rrh;
|
||||||
q = (pixel *)malloc(rw*rh*PIXELSIZE);
|
q = new pixel[rw*rh];
|
||||||
//Bilinear interpolation
|
//Bilinear interpolation
|
||||||
for (y=0; y<rh; y++)
|
for (y=0; y<rh; y++)
|
||||||
for (x=0; x<rw; x++)
|
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))
|
(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;
|
oq = q;
|
||||||
sw = rw;
|
sw = rw;
|
||||||
sh = rh;
|
sh = rh;
|
||||||
|
Reference in New Issue
Block a user