diff --git a/libvips/resample/reduceh.cpp b/libvips/resample/reduceh.cpp index 3a88f4ef..a205da47 100644 --- a/libvips/resample/reduceh.cpp +++ b/libvips/resample/reduceh.cpp @@ -281,8 +281,12 @@ reduceh_notab( VipsReduceh *reduceh, vips_reduce_make_mask( cx, reduceh->kernel, reduceh->hshrink, x ); - for( int z = 0; z < bands; z++ ) - out[z] = reduce_sum( in + z, bands, cx, n ); + for( int z = 0; z < bands; z++ ) { + double sum; + sum = reduce_sum( in + z, bands, cx, n ); + + out[z] = VIPS_ROUND_UINT( sum ); + } } /* Tried a vector path (see reducev) but it was slower. The vectors for diff --git a/libvips/resample/reducev.cpp b/libvips/resample/reducev.cpp index 847f79ec..8b25dfd3 100644 --- a/libvips/resample/reducev.cpp +++ b/libvips/resample/reducev.cpp @@ -511,8 +511,12 @@ reducev_notab( VipsReducev *reducev, vips_reduce_make_mask( cy, reducev->kernel, reducev->vshrink, y ); - for( int z = 0; z < ne; z++ ) - out[z] = reduce_sum( in + z, l1, cy, n ); + for( int z = 0; z < ne; z++ ) { + double sum; + sum = reduce_sum( in + z, l1, cy, n ); + + out[z] = VIPS_ROUND_UINT( sum ); + } } static int