diff --git a/src/ImageProcessor/Filters/Blend.cs b/src/ImageProcessor/Filters/Blend.cs index 2bc6ace25..858ed5602 100644 --- a/src/ImageProcessor/Filters/Blend.cs +++ b/src/ImageProcessor/Filters/Blend.cs @@ -59,13 +59,9 @@ namespace ImageProcessor.Filters { Color blendedColor = this.toBlend[x, y]; - // Combining colors is dependent on the alpha of the blended color + // Lerping colors is dependent on the alpha of the blended color float alphaFactor = alpha > 0 ? alpha : blendedColor.A; - float invertedAlphaFactor = 1 - alphaFactor; - - color.R = (color.R * invertedAlphaFactor) + (blendedColor.R * alphaFactor); - color.G = (color.G * invertedAlphaFactor) + (blendedColor.G * alphaFactor); - color.B = (color.B * invertedAlphaFactor) + (blendedColor.B * alphaFactor); + color = Color.Lerp(color, blendedColor, alphaFactor); } target[x, y] = color; diff --git a/tests/ImageProcessor.Tests/Processors/Filters/FilterTests.cs b/tests/ImageProcessor.Tests/Processors/Filters/FilterTests.cs index 96824e264..aba96dddd 100644 --- a/tests/ImageProcessor.Tests/Processors/Filters/FilterTests.cs +++ b/tests/ImageProcessor.Tests/Processors/Filters/FilterTests.cs @@ -16,7 +16,7 @@ namespace ImageProcessor.Tests //{ "Brightness--50", new Brightness(-50) }, //{ "Contrast-50", new Contrast(50) }, //{ "Contrast--50", new Contrast(-50) }, - { "Blend", new Blend(new Image(File.OpenRead("../../TestImages/Formats/Bmp/Car.bmp")),50)}, + { "Blend", new Blend(new Image(File.OpenRead("../../TestImages/Formats/Bmp/Car.bmp")),75)}, //{ "Saturation-50", new Saturation(50) }, //{ "Saturation--50", new Saturation(-50) }, //{ "Alpha--50", new Alpha(50) },