Browse Source

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.
af/merge-core
Unknown 8 years ago
parent
commit
fdfef1617a
  1. 4
      src/ImageSharp.Drawing/Processing/Drawing/Brushes/BrushApplicator.cs

4
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];
}

Loading…
Cancel
Save