Use bilinear interpolation for everything
This commit is contained in:
parent
45e91c15b2
commit
41d8e316cd
@ -147,7 +147,8 @@ pixel *resample_img(pixel *src, int sw, int sh, int rw, int rh)
|
|||||||
pixel *q;
|
pixel *q;
|
||||||
q = malloc(rw*rh*PIXELSIZE);
|
q = malloc(rw*rh*PIXELSIZE);
|
||||||
//TODO: Actual resampling, this is just cheap nearest pixel crap
|
//TODO: Actual resampling, this is just cheap nearest pixel crap
|
||||||
if(rw > sw && rh > sh){
|
//if(rw > sw && rh > sh){
|
||||||
|
//if(1){
|
||||||
float fx, fy, fyc, fxc, intp;
|
float fx, fy, fyc, fxc, intp;
|
||||||
pixel tr, tl, br, bl;
|
pixel tr, tl, br, bl;
|
||||||
//Bilinear interpolation for upscaling
|
//Bilinear interpolation for upscaling
|
||||||
@ -168,13 +169,13 @@ pixel *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))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
//} else {
|
||||||
for (y=0; y<rh; y++)
|
// for (y=0; y<rh; y++)
|
||||||
for (x=0; x<rw; x++)
|
// for (x=0; x<rw; x++)
|
||||||
{
|
// {
|
||||||
q[rw*y+x] = src[sw*(y*sh/rh)+(x*sw/rw)];
|
// q[rw*y+x] = src[sw*(y*sh/rh)+(x*sw/rw)];
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
//*qw = w;
|
//*qw = w;
|
||||||
//*qh = h;
|
//*qh = h;
|
||||||
return q;
|
return q;
|
||||||
|
Reference in New Issue
Block a user