diff --git a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs index c5f569a39..6dda570ff 100644 --- a/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs +++ b/src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs @@ -125,7 +125,7 @@ namespace ImageProcessor.UnitTests } /// - /// 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 /// [Test] public void TestApplyEffectBrightness() @@ -143,7 +143,25 @@ namespace ImageProcessor.UnitTests } /// - /// 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 + /// + [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); + } + } + } + + /// + /// Tests that a contrast change is really applied by checking that the image is modified /// [Test] public void TestApplyEffectContrast() @@ -161,7 +179,7 @@ namespace ImageProcessor.UnitTests } /// - /// 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 /// [Test] public void TestApplyEffectSaturation() @@ -179,7 +197,7 @@ namespace ImageProcessor.UnitTests } /// - /// 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 /// [Test] public void TestApplyEffectTint() @@ -197,7 +215,7 @@ namespace ImageProcessor.UnitTests } /// - /// 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 /// [Test] public void TestApplyEffectVignette() diff --git a/src/ImageProcessor/ImageFactory.cs b/src/ImageProcessor/ImageFactory.cs index 29b64cc22..ab4494956 100644 --- a/src/ImageProcessor/ImageFactory.cs +++ b/src/ImageProcessor/ImageFactory.cs @@ -332,6 +332,26 @@ namespace ImageProcessor return this; } + /// + /// Changes the background color of the current image. + /// + /// + /// The to paint the image with. + /// + /// + /// The current instance of the class. + /// + public ImageFactory BackgroundColor(Color color) + { + if (this.ShouldProcess) + { + BackgroundColor backgroundColor = new BackgroundColor { DynamicParameter = color }; + this.CurrentImageFormat.ApplyProcessor(backgroundColor.ProcessImage, this); + } + + return this; + } + /// /// Constrains the current image, resizing it to fit within the given dimensions whilst keeping its aspect ratio. ///