prevent /0 in eye for width/height 1

see https://github.com/libvips/libvips/issues/1236
This commit is contained in:
John Cupitt 2019-02-20 15:00:00 +00:00
parent 4af242b599
commit 2fb81b8ed6

View File

@ -77,8 +77,13 @@ vips_eye_point( VipsPoint *point, int x, int y )
{
VipsEye *eye = (VipsEye *) point;
double c = eye->factor * VIPS_PI / (2 * (point->width - 1));
double h = ((point->height - 1) * (point->height - 1));
/* VIPS_MAX to prevent /0.
*/
int max_x = VIPS_MAX( point->width - 1, 1 );
int max_y = VIPS_MAX( point->height - 1, 1 );
double c = eye->factor * VIPS_PI / (2 * max_x);
double h = max_y * max_y;
return( y * y * cos( c * x * x ) / h );
}