From a07e23927d9937d76c8858968c8e6b2eda33d130 Mon Sep 17 00:00:00 2001 From: People doing a 16 bpc version of gimp Date: Mon, 15 Dec 1997 00:21:15 +0000 Subject: [PATCH] fixed div-by-zero when using custom gradients with offset 100 rayl@netrover.com --- app/blend.c | 6 ++++++ app/core/gimpdrawable-blend.c | 6 ++++++ app/tools/blend.c | 6 ++++++ app/tools/gimpblendtool.c | 6 ++++++ 4 files changed, 24 insertions(+) diff --git a/app/blend.c b/app/blend.c index 3edfcd5346..b593fef545 100644 --- a/app/blend.c +++ b/app/blend.c @@ -891,6 +891,8 @@ gradient_calc_square_factor (double dist, if (rat < offset) rat = 0.0; + else if (offset == 1) + rat = (rat>=1) ? 1 : 0; else rat = (rat - offset) / (1.0 - offset); } /* else */ @@ -923,6 +925,8 @@ gradient_calc_radial_factor (double dist, if (rat < offset) rat = 0.0; + else if (offset == 1) + rat = (rat>=1) ? 1 : 0; else rat = (rat - offset) / (1.0 - offset); } /* else */ @@ -979,6 +983,8 @@ gradient_calc_bilinear_factor (double dist, if (fabs(rat) < offset) rat = 0.0; + else if (offset == 1) + rat = (rat>=1) ? 1 : 0; else rat = (fabs(rat) - offset) / (1.0 - offset); } /* else */ diff --git a/app/core/gimpdrawable-blend.c b/app/core/gimpdrawable-blend.c index 3edfcd5346..b593fef545 100644 --- a/app/core/gimpdrawable-blend.c +++ b/app/core/gimpdrawable-blend.c @@ -891,6 +891,8 @@ gradient_calc_square_factor (double dist, if (rat < offset) rat = 0.0; + else if (offset == 1) + rat = (rat>=1) ? 1 : 0; else rat = (rat - offset) / (1.0 - offset); } /* else */ @@ -923,6 +925,8 @@ gradient_calc_radial_factor (double dist, if (rat < offset) rat = 0.0; + else if (offset == 1) + rat = (rat>=1) ? 1 : 0; else rat = (rat - offset) / (1.0 - offset); } /* else */ @@ -979,6 +983,8 @@ gradient_calc_bilinear_factor (double dist, if (fabs(rat) < offset) rat = 0.0; + else if (offset == 1) + rat = (rat>=1) ? 1 : 0; else rat = (fabs(rat) - offset) / (1.0 - offset); } /* else */ diff --git a/app/tools/blend.c b/app/tools/blend.c index 3edfcd5346..b593fef545 100644 --- a/app/tools/blend.c +++ b/app/tools/blend.c @@ -891,6 +891,8 @@ gradient_calc_square_factor (double dist, if (rat < offset) rat = 0.0; + else if (offset == 1) + rat = (rat>=1) ? 1 : 0; else rat = (rat - offset) / (1.0 - offset); } /* else */ @@ -923,6 +925,8 @@ gradient_calc_radial_factor (double dist, if (rat < offset) rat = 0.0; + else if (offset == 1) + rat = (rat>=1) ? 1 : 0; else rat = (rat - offset) / (1.0 - offset); } /* else */ @@ -979,6 +983,8 @@ gradient_calc_bilinear_factor (double dist, if (fabs(rat) < offset) rat = 0.0; + else if (offset == 1) + rat = (rat>=1) ? 1 : 0; else rat = (fabs(rat) - offset) / (1.0 - offset); } /* else */ diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c index 3edfcd5346..b593fef545 100644 --- a/app/tools/gimpblendtool.c +++ b/app/tools/gimpblendtool.c @@ -891,6 +891,8 @@ gradient_calc_square_factor (double dist, if (rat < offset) rat = 0.0; + else if (offset == 1) + rat = (rat>=1) ? 1 : 0; else rat = (rat - offset) / (1.0 - offset); } /* else */ @@ -923,6 +925,8 @@ gradient_calc_radial_factor (double dist, if (rat < offset) rat = 0.0; + else if (offset == 1) + rat = (rat>=1) ? 1 : 0; else rat = (rat - offset) / (1.0 - offset); } /* else */ @@ -979,6 +983,8 @@ gradient_calc_bilinear_factor (double dist, if (fabs(rat) < offset) rat = 0.0; + else if (offset == 1) + rat = (rat>=1) ? 1 : 0; else rat = (fabs(rat) - offset) / (1.0 - offset); } /* else */