fix centre sampling for non-int nearest upscale

we were not disabling the input offset for NEAREST, whcih is always
centre

thanks edwjusti

see https://github.com/lovell/sharp/issues/1479
This commit is contained in:
John Cupitt 2018-12-03 17:13:57 +00:00
parent ee4d1d7c22
commit f5d76b42fc
1 changed files with 8 additions and 2 deletions

View File

@ -28,6 +28,9 @@
* - make LINEAR and CUBIC adaptive
* 25/11/17
* - deprecate --centre ... it's now always on, thanks tback
* 3/12/18 [edwjusti]
* - disable the centre sampling offset for nearest upscale, since the
* affine nearest interpolator is always centre
*/
/*
@ -241,9 +244,12 @@ vips_resize_build( VipsObject *object )
vips_resize_interpolate( resize->kernel );
/* Input displacement. For centre sampling, shift by 0.5 down
* and right.
* and right. Except if this is nearest, which is always
* centre.
*/
const double id = 0.5;
const double id =
resize->kernel == VIPS_KERNEL_NEAREST ?
0.0 : 0.5;
VipsInterpolate *interpolate;