Browse Source

Use Lerp silly!

Former-commit-id: eaf0f42e5396ade62ae183cebf6e5184497d4080
Former-commit-id: 549126e52b96fa9964cd784d4b9d77d49a144406
Former-commit-id: ab690f14924de2ae267ffc189dd741c6281b10bc
af/merge-core
James Jackson-South 11 years ago
parent
commit
c755ac602e
  1. 8
      src/ImageProcessor/Filters/Blend.cs
  2. 2
      tests/ImageProcessor.Tests/Processors/Filters/FilterTests.cs

8
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;

2
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) },

Loading…
Cancel
Save