From fdfef1617a4ec33192a58502f3b913c59bae3dcf Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 19 Apr 2018 23:59:42 +0200 Subject: [PATCH] FIX bug in BrushApplicator when applying BlendPercentage thanks @tocsoft for investigation and finding the bug. He proposed to just replace < by <= in line 78, but that would only shift the problem to values > 1. Those values should not be used from a semantic point, but it's not forbidden in a float value. My fix here keeps the <, but adds an else path that uses the original value from scanline[i]. This adds an else to the code (which technically adds a jump after the then-part), but omits the multiplication. The simple solution @tocsoft proposed might be faster, but should be preferred if and only if BlendPercentage can be guaranteed to be <=1. --- .../Processing/Drawing/Brushes/BrushApplicator.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ImageSharp.Drawing/Processing/Drawing/Brushes/BrushApplicator.cs b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/BrushApplicator.cs index f665e8408..c54666335 100644 --- a/src/ImageSharp.Drawing/Processing/Drawing/Brushes/BrushApplicator.cs +++ b/src/ImageSharp.Drawing/Processing/Drawing/Brushes/BrushApplicator.cs @@ -79,6 +79,10 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Brushes { amountSpan[i] = scanline[i] * this.Options.BlendPercentage; } + else + { + amountSpan[i] = scanline[i]; + } overlaySpan[i] = this[x + i, y]; }