@@ -321,14 +321,15 @@ calculate_coefficients_triangle( double *c,
321
321
{
322
322
/* Needs to be in sync with vips_reduce_get_points().
323
323
*/
324
- const int n_points = rint ( 2 * shrink ) + 1 ;
324
+ const int n_points = 2 * rint ( shrink ) + 1 ;
325
+ const double half = x + n_points / 2.0 - 1 ;
325
326
326
327
int i;
327
328
double sum;
328
329
329
330
sum = 0 ;
330
331
for ( i = 0 ; i < n_points; i++ ) {
331
- double xp = (i - (shrink - 0.5 ) - x ) / shrink;
332
+ const double xp = (i - half ) / shrink;
332
333
333
334
double l;
334
335
@@ -358,14 +359,15 @@ calculate_coefficients_cubic( double *c,
358
359
{
359
360
/* Needs to be in sync with vips_reduce_get_points().
360
361
*/
361
- const int n_points = rint ( 4 * shrink ) + 1 ;
362
+ const int n_points = 2 * rint ( 2 * shrink ) + 1 ;
363
+ const double half = x + n_points / 2.0 - 1 ;
362
364
363
365
int i;
364
366
double sum;
365
367
366
368
sum = 0 ;
367
369
for ( i = 0 ; i < n_points; i++ ) {
368
- const double xp = (i - ( 2 * shrink - 1 ) - x ) / shrink;
370
+ const double xp = (i - half ) / shrink;
369
371
const double axp = VIPS_FABS ( xp );
370
372
const double axp2 = axp * axp;
371
373
const double axp3 = axp2 * axp;
@@ -406,14 +408,15 @@ calculate_coefficients_lanczos( double *c,
406
408
{
407
409
/* Needs to be in sync with vips_reduce_get_points().
408
410
*/
409
- const int n_points = rint ( 2 * a * shrink ) + 1 ;
411
+ const int n_points = 2 * rint ( a * shrink ) + 1 ;
412
+ const double half = x + n_points / 2.0 - 1 ;
410
413
411
414
int i;
412
415
double sum;
413
416
414
417
sum = 0 ;
415
418
for ( i = 0 ; i < n_points; i++ ) {
416
- double xp = (i - (n_points - 2 ) / 2 - x ) / shrink;
419
+ double xp = (i - half ) / shrink;
417
420
418
421
double l;
419
422
0 commit comments