Bilinear interpolation: Difference between revisions

m (→‎{{header|Phix}}: IupCloseOnEscape no longer needed)
Line 19:
return image->pixels[(y*image->w)+x];
}
 
float max(float a, float b) { return (a < b) ? a : b; };
float lerp(float s, float e, float t){return s+(e-s)*t;}
float blerp(float c00, float c10, float c01, float c11, float tx, float ty){
Line 34 ⟶ 36:
x = 0; y++;
}
//float gx = x / (float)(newWidth) * (src->w - 1);
//float gy = y / (float)(newHeight) * (src->h - 1);
// Image should be clamped at the edges and not scaled.
float gx = max(x / (float)(newWidth) * (src->w) - 0.5f, src->w - 1);
float gy = max(y / (float)(newHeight) * (src->h) - 0.5, src->h - 1);
int gxi = (int)gx;
int gyi = (int)gy;