Browse Source

Adding missing BackgroundColor method

Former-commit-id: 1e35d88182015f11e057a9cc48e0d605db91760a
pull/17/head
James South 12 years ago
parent
commit
a783baa804
  1. 28
      src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs
  2. 20
      src/ImageProcessor/ImageFactory.cs

28
src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs

@ -125,7 +125,7 @@ namespace ImageProcessor.UnitTests
}
/// <summary>
/// Tests that a filter is really applied by checking that the image is modified
/// Tests that brightness changes is really applied by checking that the image is modified
/// </summary>
[Test]
public void TestApplyEffectBrightness()
@ -143,7 +143,25 @@ namespace ImageProcessor.UnitTests
}
/// <summary>
/// Tests that a filter is really applied by checking that the image is modified
/// Tests that background color changes are really applied by checking that the image is modified
/// </summary>
[Test]
public void TestApplyEffectBackgroundColor()
{
foreach (FileInfo file in this.ListInputFiles())
{
using (ImageFactory imageFactory = new ImageFactory())
{
imageFactory.Load(file.FullName);
Image original = (Image)imageFactory.Image.Clone();
imageFactory.BackgroundColor(Color.Yellow);
Assert.AreNotEqual(original, imageFactory.Image);
}
}
}
/// <summary>
/// Tests that a contrast change is really applied by checking that the image is modified
/// </summary>
[Test]
public void TestApplyEffectContrast()
@ -161,7 +179,7 @@ namespace ImageProcessor.UnitTests
}
/// <summary>
/// Tests that a filter is really applied by checking that the image is modified
/// Tests that a saturation change is really applied by checking that the image is modified
/// </summary>
[Test]
public void TestApplyEffectSaturation()
@ -179,7 +197,7 @@ namespace ImageProcessor.UnitTests
}
/// <summary>
/// Tests that a filter is really applied by checking that the image is modified
/// Tests that a tint change is really applied by checking that the image is modified
/// </summary>
[Test]
public void TestApplyEffectTint()
@ -197,7 +215,7 @@ namespace ImageProcessor.UnitTests
}
/// <summary>
/// Tests that a filter is really applied by checking that the image is modified
/// Tests that a vignette change is really applied by checking that the image is modified
/// </summary>
[Test]
public void TestApplyEffectVignette()

20
src/ImageProcessor/ImageFactory.cs

@ -332,6 +332,26 @@ namespace ImageProcessor
return this;
}
/// <summary>
/// Changes the background color of the current image.
/// </summary>
/// <param name="color">
/// The <see cref="T:System.Drawing.Color"/> to paint the image with.
/// </param>
/// <returns>
/// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
/// </returns>
public ImageFactory BackgroundColor(Color color)
{
if (this.ShouldProcess)
{
BackgroundColor backgroundColor = new BackgroundColor { DynamicParameter = color };
this.CurrentImageFormat.ApplyProcessor(backgroundColor.ProcessImage, this);
}
return this;
}
/// <summary>
/// Constrains the current image, resizing it to fit within the given dimensions whilst keeping its aspect ratio.
/// </summary>

Loading…
Cancel
Save