vips_scale() needs round to nearest

or we can get rounding errors in some cases
This commit is contained in:
John Cupitt 2014-07-14 14:36:35 +01:00
parent 91eeeafa05
commit 388f25fc0c
2 changed files with 7 additions and 1 deletions

View File

@ -1,6 +1,7 @@
4/7/14 started 7.40.4
- fix vips_rawsave_fd(), thanks aferrero2707
- fix im_point()
- vips_scale() now does round to nearest to avoid rounding errors
30/6/14 started 7.40.3
- fix interlaced thumbnails in vipsthumbnail, thanks lovell

View File

@ -20,6 +20,8 @@
* - add log scale and exponent as an option
* 14/1/14
* - use linear uchar mode
* 14/7/14
* - round to nearest on uchar output
*/
/*
@ -117,7 +119,10 @@ vips_scale_build( VipsObject *object )
}
else {
double f = 255.0 / (mx - mn);
double a = -(mn * f);
/* Add .5 to get round-to-nearest.
*/
double a = -(mn * f) + 0.5;
if( vips_linear1( scale->in, &t[2], f, a,
"uchar", TRUE,