diff --git a/src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs b/src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs index 5b1409fe2d..5038ea01b5 100644 --- a/src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs @@ -134,7 +134,7 @@ namespace ImageSharp.Drawing.Brushes } BufferSpan destinationRow = this.Target.GetRowSpan(x, y).Slice(0, scanline.Length); - this.Blender.Compose(destinationRow, destinationRow, overlay, amountBuffer); + this.Blender.Blend(destinationRow, destinationRow, overlay, amountBuffer); } } } diff --git a/src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs b/src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs index 133506827c..dc8a4bc902 100644 --- a/src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs @@ -162,7 +162,7 @@ namespace ImageSharp.Drawing.Brushes } BufferSpan destinationRow = this.Target.GetRowSpan(x, y).Slice(0, scanline.Length); - this.Blender.Compose(destinationRow, destinationRow, overlay, amountBuffer); + this.Blender.Blend(destinationRow, destinationRow, overlay, amountBuffer); } } } diff --git a/src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs b/src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs index 59cb0820a4..d7c70220c5 100644 --- a/src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs +++ b/src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs @@ -80,7 +80,7 @@ namespace ImageSharp.Drawing.Processors } BufferSpan destinationRow = this.Target.GetRowSpan(x, y).Slice(0, scanline.Length); - this.Blender.Compose(destinationRow, destinationRow, overlay, amountBuffer); + this.Blender.Blend(destinationRow, destinationRow, overlay, amountBuffer); } } } diff --git a/src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs b/src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs index b8b2499ff7..19ce469141 100644 --- a/src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs @@ -154,7 +154,7 @@ namespace ImageSharp.Drawing.Brushes } BufferSpan destinationRow = this.Target.GetRowSpan(x, y).Slice(0, scanline.Length); - this.Blender.Compose(destinationRow, destinationRow, overlay, amountBuffer); + this.Blender.Blend(destinationRow, destinationRow, overlay, amountBuffer); } } } diff --git a/src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs b/src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs index a18f8de1d7..71b802136d 100644 --- a/src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs +++ b/src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs @@ -98,7 +98,7 @@ namespace ImageSharp.Drawing.Brushes amountBuffer[i] = scanline[i] * this.Options.BlendPercentage; } - this.Blender.Compose(destinationRow, destinationRow, this.Colors, amountBuffer); + this.Blender.Blend(destinationRow, destinationRow, this.Colors, amountBuffer); } } } diff --git a/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs b/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs index 95c5b4a2f0..e58db46895 100644 --- a/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs @@ -67,7 +67,6 @@ namespace ImageSharp.Drawing.Processors { if (targetImage.Bounds.Size != this.Size) { - // should Resize be moved to core? targetImage = disposableImage = new Image(this.Image).Resize(this.Size.Width, this.Size.Height); } @@ -80,7 +79,7 @@ namespace ImageSharp.Drawing.Processors int width = maxX - minX; using (Buffer amount = new Buffer(width)) - using (PixelAccessor toBlendPixels = this.Image.Lock()) + using (PixelAccessor toBlendPixels = targetImage.Lock()) using (PixelAccessor sourcePixels = source.Lock()) { for (int i = 0; i < width; i++) @@ -96,19 +95,8 @@ namespace ImageSharp.Drawing.Processors { BufferSpan background = sourcePixels.GetRowSpan(y).Slice(minX, width); BufferSpan foreground = toBlendPixels.GetRowSpan(y - minY).Slice(0, width); - this.blender.Compose(background, background, foreground, amount); - - // for (int x = minX; x < maxX; x++) - // { - // Vector4 backgroundVector = sourcePixels[x, y].ToVector4(); - // Vector4 sourceVector = toBlendPixels[x - minX, y - minY].ToVector4(); - // // Lerping colors is dependent on the alpha of the blended color - // backgroundVector = Vector4BlendTransforms.PremultipliedLerp(backgroundVector, sourceVector, alpha); - // TPixel packed = default(TPixel); - // packed.PackFromVector4(backgroundVector); - // sourcePixels[x, y] = packed; - // } - }); + this.blender.Blend(background, background, foreground, amount); + }); } } finally diff --git a/src/ImageSharp.Drawing/GraphicsOptions.cs b/src/ImageSharp/GraphicsOptions.cs similarity index 98% rename from src/ImageSharp.Drawing/GraphicsOptions.cs rename to src/ImageSharp/GraphicsOptions.cs index 03176addf8..c32103652b 100644 --- a/src/ImageSharp.Drawing/GraphicsOptions.cs +++ b/src/ImageSharp/GraphicsOptions.cs @@ -3,7 +3,7 @@ // Licensed under the Apache License, Version 2.0. // -namespace ImageSharp.Drawing +namespace ImageSharp { using ImageSharp.PixelFormats; diff --git a/src/ImageSharp/PixelFormats/PixelBlenderMode.cs b/src/ImageSharp/PixelFormats/PixelBlenderMode.cs index ebb08757b5..d8031fe6e5 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenderMode.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenderMode.cs @@ -20,42 +20,42 @@ namespace ImageSharp.PixelFormats Normal = 0, /// - /// Backdrop + Source + /// Blends the 2 values by multiplication. /// Multiply, /// - /// Backdrop + Source + /// Blends the 2 values by addition. /// Add, /// - /// Backdrop - Source + /// Blends the 2 values by subtraction. /// Substract, /// - /// Screen effect + /// Multiplies the complements of the backdrop and source values, then complements the result. /// Screen, /// - /// Darken effect + /// Selects the minimum of the backdrop and source values. /// Darken, /// - /// Lighten effect + /// Selects the max of the backdrop and source values. /// Lighten, /// - /// Overlay effect + /// Multiplies or screens the values, depending on the backdrop vector values. /// Overlay, /// - /// Hard light effect + /// Multiplies or screens the colors, depending on the source value. /// HardLight } diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultAddPixelBlender{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultAddPixelBlender{TPixel}.cs index 441877f5fe..ab3aee0411 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultAddPixelBlender{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultAddPixelBlender{TPixel}.cs @@ -10,7 +10,7 @@ namespace ImageSharp.PixelFormats.PixelBlenders using ImageSharp.PixelFormats; /// - /// Abstract base class for calling pixel composition functions + /// Applies an "Add" blending to pixels. /// /// The type of the pixel internal class DefaultAddPixelBlender : PixelBlender @@ -22,13 +22,13 @@ namespace ImageSharp.PixelFormats.PixelBlenders public static DefaultAddPixelBlender Instance { get; } = new DefaultAddPixelBlender(); /// - public override TPixel Compose(TPixel background, TPixel source, float amount) + public override TPixel Blend(TPixel background, TPixel source, float amount) { return PorterDuffFunctions.AddFunction(background, source, amount); } /// - public override void Compose(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount) + public override void Blend(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultDarkenPixelBlender{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultDarkenPixelBlender{TPixel}.cs index c391aabe56..e0ff80b66e 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultDarkenPixelBlender{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultDarkenPixelBlender{TPixel}.cs @@ -10,7 +10,7 @@ namespace ImageSharp.PixelFormats.PixelBlenders using ImageSharp.PixelFormats; /// - /// Abstract base class for calling pixel composition functions + /// Applies an "Darken" blending to pixels. /// /// The type of the pixel internal class DefaultDarkenPixelBlender : PixelBlender @@ -22,13 +22,13 @@ namespace ImageSharp.PixelFormats.PixelBlenders public static DefaultDarkenPixelBlender Instance { get; } = new DefaultDarkenPixelBlender(); /// - public override TPixel Compose(TPixel background, TPixel source, float amount) + public override TPixel Blend(TPixel background, TPixel source, float amount) { return PorterDuffFunctions.DarkenFunction(background, source, amount); } /// - public override void Compose(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount) + public override void Blend(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultHardLightPixelBlender{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultHardLightPixelBlender{TPixel}.cs index 7d98a05c98..cec0dc0db1 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultHardLightPixelBlender{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultHardLightPixelBlender{TPixel}.cs @@ -10,7 +10,7 @@ namespace ImageSharp.PixelFormats.PixelBlenders using ImageSharp.PixelFormats; /// - /// Abstract base class for calling pixel composition functions + /// Applies an "Hard Light" blending to pixels. /// /// The type of the pixel internal class DefaultHardLightPixelBlender : PixelBlender @@ -22,13 +22,13 @@ namespace ImageSharp.PixelFormats.PixelBlenders public static DefaultHardLightPixelBlender Instance { get; } = new DefaultHardLightPixelBlender(); /// - public override TPixel Compose(TPixel background, TPixel source, float amount) + public override TPixel Blend(TPixel background, TPixel source, float amount) { return PorterDuffFunctions.HardLightFunction(background, source, amount); } /// - public override void Compose(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount) + public override void Blend(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultLightenPixelBlender{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultLightenPixelBlender{TPixel}.cs index e97c52edd3..32cd20650c 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultLightenPixelBlender{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultLightenPixelBlender{TPixel}.cs @@ -10,7 +10,7 @@ namespace ImageSharp.PixelFormats.PixelBlenders using ImageSharp.PixelFormats; /// - /// Abstract base class for calling pixel composition functions + /// Applies an "Lighten" blending to pixels. /// /// The type of the pixel internal class DefaultLightenPixelBlender : PixelBlender @@ -22,13 +22,13 @@ namespace ImageSharp.PixelFormats.PixelBlenders public static DefaultLightenPixelBlender Instance { get; } = new DefaultLightenPixelBlender(); /// - public override TPixel Compose(TPixel background, TPixel source, float amount) + public override TPixel Blend(TPixel background, TPixel source, float amount) { return PorterDuffFunctions.LightenFunction(background, source, amount); } /// - public override void Compose(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount) + public override void Blend(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultMultiplyPixelBlender{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultMultiplyPixelBlender{TPixel}.cs index 53748ad64b..7e01370185 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultMultiplyPixelBlender{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultMultiplyPixelBlender{TPixel}.cs @@ -10,7 +10,7 @@ namespace ImageSharp.PixelFormats.PixelBlenders using ImageSharp.PixelFormats; /// - /// Abstract base class for calling pixel composition functions + /// Applies an "Multiply" blending to pixels. /// /// The type of the pixel internal class DefaultMultiplyPixelBlender : PixelBlender @@ -22,13 +22,13 @@ namespace ImageSharp.PixelFormats.PixelBlenders public static DefaultMultiplyPixelBlender Instance { get; } = new DefaultMultiplyPixelBlender(); /// - public override TPixel Compose(TPixel background, TPixel source, float amount) + public override TPixel Blend(TPixel background, TPixel source, float amount) { return PorterDuffFunctions.MultiplyFunction(background, source, amount); } /// - public override void Compose(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount) + public override void Blend(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultNormalPixelBlender{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultNormalPixelBlender{TPixel}.cs index 823fd1c2f7..47bb084ca0 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultNormalPixelBlender{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultNormalPixelBlender{TPixel}.cs @@ -10,7 +10,7 @@ namespace ImageSharp.PixelFormats.PixelBlenders using ImageSharp.PixelFormats; /// - /// Abstract base class for calling pixel composition functions + /// Applies a "Normal" otherwise nown as "Alpha Blending" blending to pixels. /// /// The type of the pixel internal class DefaultNormalPixelBlender : PixelBlender @@ -22,13 +22,13 @@ namespace ImageSharp.PixelFormats.PixelBlenders public static DefaultNormalPixelBlender Instance { get; } = new DefaultNormalPixelBlender(); /// - public override TPixel Compose(TPixel background, TPixel source, float amount) + public override TPixel Blend(TPixel background, TPixel source, float amount) { return PorterDuffFunctions.NormalBlendFunction(background, source, amount); } /// - public override void Compose(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount) + public override void Blend(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultOverlayPixelBlender{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultOverlayPixelBlender{TPixel}.cs index 64393a66d7..fcb56e3dcc 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultOverlayPixelBlender{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultOverlayPixelBlender{TPixel}.cs @@ -10,7 +10,7 @@ namespace ImageSharp.PixelFormats.PixelBlenders using ImageSharp.PixelFormats; /// - /// Abstract base class for calling pixel composition functions + /// Applies an "Overlay" blending to pixels. /// /// The type of the pixel internal class DefaultOverlayPixelBlender : PixelBlender @@ -22,13 +22,13 @@ namespace ImageSharp.PixelFormats.PixelBlenders public static DefaultOverlayPixelBlender Instance { get; } = new DefaultOverlayPixelBlender(); /// - public override TPixel Compose(TPixel background, TPixel source, float amount) + public override TPixel Blend(TPixel background, TPixel source, float amount) { return PorterDuffFunctions.OverlayFunction(background, source, amount); } /// - public override void Compose(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount) + public override void Blend(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultScreenPixelBlender{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultScreenPixelBlender{TPixel}.cs index 8538fda57f..df0de293c8 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultScreenPixelBlender{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultScreenPixelBlender{TPixel}.cs @@ -10,7 +10,7 @@ namespace ImageSharp.PixelFormats.PixelBlenders using ImageSharp.PixelFormats; /// - /// Abstract base class for calling pixel composition functions + /// Applies an "Screen" blending to pixels. /// /// The type of the pixel internal class DefaultScreenPixelBlender : PixelBlender @@ -22,13 +22,13 @@ namespace ImageSharp.PixelFormats.PixelBlenders public static DefaultScreenPixelBlender Instance { get; } = new DefaultScreenPixelBlender(); /// - public override TPixel Compose(TPixel background, TPixel source, float amount) + public override TPixel Blend(TPixel background, TPixel source, float amount) { return PorterDuffFunctions.ScreenFunction(background, source, amount); } /// - public override void Compose(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount) + public override void Blend(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); diff --git a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultSubstractPixelBlender{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultSubstractPixelBlender{TPixel}.cs index 48b7196faa..415ac04b2c 100644 --- a/src/ImageSharp/PixelFormats/PixelBlenders/DefaultSubstractPixelBlender{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/PixelBlenders/DefaultSubstractPixelBlender{TPixel}.cs @@ -10,7 +10,7 @@ namespace ImageSharp.PixelFormats.PixelBlenders using ImageSharp.PixelFormats; /// - /// Abstract base class for calling pixel composition functions + /// Applies an "Subtract" blending to pixels. /// /// The type of the pixel internal class DefaultSubstractPixelBlender : PixelBlender @@ -22,13 +22,13 @@ namespace ImageSharp.PixelFormats.PixelBlenders public static DefaultSubstractPixelBlender Instance { get; } = new DefaultSubstractPixelBlender(); /// - public override TPixel Compose(TPixel background, TPixel source, float amount) + public override TPixel Blend(TPixel background, TPixel source, float amount) { return PorterDuffFunctions.SubstractFunction(background, source, amount); } /// - public override void Compose(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount) + public override void Blend(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount) { Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length)); Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length)); diff --git a/src/ImageSharp/PixelFormats/PixelBlender{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelBlender{TPixel}.cs index ee0c67396d..23340a60a6 100644 --- a/src/ImageSharp/PixelFormats/PixelBlender{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/PixelBlender{TPixel}.cs @@ -13,7 +13,7 @@ namespace ImageSharp.PixelFormats where TPixel : struct, IPixel { /// - /// Composes 2 pixels together. + /// Blend 2 pixels together. /// /// The background color. /// The source color. @@ -22,10 +22,10 @@ namespace ImageSharp.PixelFormats /// At amount = 0, "from" is returned, at amount = 1, "to" is returned. /// /// The final pixel value after composition - public abstract TPixel Compose(TPixel background, TPixel source, float amount); + public abstract TPixel Blend(TPixel background, TPixel source, float amount); /// - /// Composes 2 pixels together. + /// Blend 2 pixels together. /// /// The destination span. /// The background span. @@ -34,6 +34,6 @@ namespace ImageSharp.PixelFormats /// A value between 0 and 1 indicating the weight of the second source vector. /// At amount = 0, "from" is returned, at amount = 1, "to" is returned. /// - public abstract void Compose(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount); + public abstract void Blend(BufferSpan destination, BufferSpan background, BufferSpan source, BufferSpan amount); } } diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs index e2fb377ba3..cab357c412 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.PixelBenders.cs @@ -5,35 +5,14 @@ namespace ImageSharp.PixelFormats { - using System.Numerics; - using System.Runtime.CompilerServices; using ImageSharp.PixelFormats.PixelBlenders; -#pragma warning disable CS1710 // XML comment has a duplicate typeparam tag - /// - /// A stateless class implementing Strategy Pattern for batched pixel-data conversion operations - /// for pixel buffers of type . - /// - /// The pixel format. + /// + /// Provides access to pixel blenders + /// public partial class PixelOperations -#pragma warning restore CS1710 // XML comment has a duplicate typeparam tag where TPixel : struct, IPixel { - /// - /// Gets the NormalBlender. - /// - private PixelBlender normalBlender = new DefaultNormalPixelBlender(); - - /// - /// Gets the MultiplyBlender. - /// - private PixelBlender multiplyBlender = new DefaultMultiplyPixelBlender(); - - /// - /// Gets the ScreenBlender. - /// - private PixelBlender screenBlender = new DefaultScreenPixelBlender(); - /// /// Find an instance of the pixel blender. /// diff --git a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs index 11ff422221..2070405211 100644 --- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs +++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs @@ -8,14 +8,12 @@ namespace ImageSharp.PixelFormats using System.Numerics; using System.Runtime.CompilerServices; -#pragma warning disable CS1710 // XML comment has a duplicate typeparam tag - /// - /// A stateless class implementing Strategy Pattern for batched pixel-data conversion operations - /// for pixel buffers of type . - /// - /// The pixel format. + /// + /// A stateless class implementing Strategy Pattern for batched pixel-data conversion operations + /// for pixel buffers of type . + /// + /// The pixel format. public partial class PixelOperations -#pragma warning restore CS1710 // XML comment has a duplicate typeparam tag where TPixel : struct, IPixel { /// diff --git a/src/ImageSharp/Processing/Overlays/Glow.cs b/src/ImageSharp/Processing/Overlays/Glow.cs index 1be15ad650..587bbe6104 100644 --- a/src/ImageSharp/Processing/Overlays/Glow.cs +++ b/src/ImageSharp/Processing/Overlays/Glow.cs @@ -25,7 +25,7 @@ namespace ImageSharp public static Image Glow(this Image source) where TPixel : struct, IPixel { - return Glow(source, NamedColors.Black, source.Bounds.Width * .5F, source.Bounds); + return Glow(source, GraphicsOptions.Default); } /// @@ -38,7 +38,7 @@ namespace ImageSharp public static Image Glow(this Image source, TPixel color) where TPixel : struct, IPixel { - return Glow(source, color, source.Bounds.Width * .5F, source.Bounds); + return Glow(source, color, GraphicsOptions.Default); } /// @@ -51,7 +51,7 @@ namespace ImageSharp public static Image Glow(this Image source, float radius) where TPixel : struct, IPixel { - return Glow(source, NamedColors.Black, radius, source.Bounds); + return Glow(source, radius, GraphicsOptions.Default); } /// @@ -66,7 +66,7 @@ namespace ImageSharp public static Image Glow(this Image source, Rectangle rectangle) where TPixel : struct, IPixel { - return Glow(source, NamedColors.Black, 0, rectangle); + return Glow(source, rectangle, GraphicsOptions.Default); } /// @@ -83,7 +83,82 @@ namespace ImageSharp public static Image Glow(this Image source, TPixel color, float radius, Rectangle rectangle) where TPixel : struct, IPixel { - GlowProcessor processor = new GlowProcessor(color) { Radius = radius, }; + return Glow(source, color, radius, rectangle, GraphicsOptions.Default); + } + + /// + /// Applies a radial glow effect to an image. + /// + /// The pixel format. + /// The image this method extends. + /// The options effecting things like blending. + /// The . + public static Image Glow(this Image source, GraphicsOptions options) + where TPixel : struct, IPixel + { + return Glow(source, NamedColors.Black, source.Bounds.Width * .5F, source.Bounds, options); + } + + /// + /// Applies a radial glow effect to an image. + /// + /// The pixel format. + /// The image this method extends. + /// The color to set as the glow. + /// The options effecting things like blending. + /// The . + public static Image Glow(this Image source, TPixel color, GraphicsOptions options) + where TPixel : struct, IPixel + { + return Glow(source, color, source.Bounds.Width * .5F, source.Bounds, options); + } + + /// + /// Applies a radial glow effect to an image. + /// + /// The pixel format. + /// The image this method extends. + /// The the radius. + /// The options effecting things like blending. + /// The . + public static Image Glow(this Image source, float radius, GraphicsOptions options) + where TPixel : struct, IPixel + { + return Glow(source, NamedColors.Black, radius, source.Bounds, options); + } + + /// + /// Applies a radial glow effect to an image. + /// + /// The pixel format. + /// The image this method extends. + /// + /// The structure that specifies the portion of the image object to alter. + /// + /// The options effecting things like blending. + /// The . + public static Image Glow(this Image source, Rectangle rectangle, GraphicsOptions options) + where TPixel : struct, IPixel + { + return Glow(source, NamedColors.Black, 0, rectangle, options); + } + + /// + /// Applies a radial glow effect to an image. + /// + /// The pixel format. + /// The image this method extends. + /// The color to set as the glow. + /// The the radius. + /// + /// The structure that specifies the portion of the image object to alter. + /// + /// The options effecting things like blending. + /// The . + public static Image Glow(this Image source, TPixel color, float radius, Rectangle rectangle, GraphicsOptions options) + where TPixel : struct, IPixel + { + GlowProcessor processor = new GlowProcessor(color, options) { Radius = radius, }; source.ApplyProcessor(processor, rectangle); return source; } diff --git a/src/ImageSharp/Processing/Processors/ColorMatrix/PolaroidProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/PolaroidProcessor.cs index 74185f11f4..c06275314b 100644 --- a/src/ImageSharp/Processing/Processors/ColorMatrix/PolaroidProcessor.cs +++ b/src/ImageSharp/Processing/Processors/ColorMatrix/PolaroidProcessor.cs @@ -42,7 +42,7 @@ namespace ImageSharp.Processing.Processors protected override void AfterApply(ImageBase source, Rectangle sourceRectangle) { new VignetteProcessor(veryDarkOrange).Apply(source, sourceRectangle); - new GlowProcessorParallel(lightOrange) { Radius = source.Width / 4F }.Apply(source, sourceRectangle); + new GlowProcessor(lightOrange, GraphicsOptions.Default) { Radius = source.Width / 4F }.Apply(source, sourceRectangle); } } } \ No newline at end of file diff --git a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs index ad7846d846..5b5d64a9c0 100644 --- a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs @@ -18,13 +18,19 @@ namespace ImageSharp.Processing.Processors internal class GlowProcessor : ImageProcessor where TPixel : struct, IPixel { + private readonly GraphicsOptions options; + private readonly PixelBlender blender; + /// /// Initializes a new instance of the class. /// /// The color or the glow. - public GlowProcessor(TPixel color) + /// The options effecting blending and composition. + public GlowProcessor(TPixel color, GraphicsOptions options) { + this.options = options; this.GlowColor = color; + this.blender = PixelOperations.Instance.GetPixelBlender(this.options.BlenderMode); } /// @@ -67,7 +73,6 @@ namespace ImageSharp.Processing.Processors int width = maxX - minX; using (Buffer rowColors = new Buffer(width)) - using (Buffer amounts = new Buffer(width)) using (PixelAccessor sourcePixels = source.Lock()) { for (int i = 0; i < width; i++) @@ -75,22 +80,27 @@ namespace ImageSharp.Processing.Processors rowColors[i] = glowColor; } - // TODO move GraphicOptions into core so all processes can use it. - PixelBlender blender = PixelOperations.Instance.GetPixelBlender(PixelBlenderMode.Normal); - for (int y = minY; y < maxY; y++) - { - int offsetY = y - startY; - int offsetX = minX - startX; - for (int i = 0; i < width; i++) - { - float distance = Vector2.Distance(centre, new Vector2(i + offsetX, offsetY)); - amounts[i] = (1 - (.95F * (distance / maxDistance))).Clamp(0, 1); - } + Parallel.For( + minY, + maxY, + this.ParallelOptions, + y => + { + using (Buffer amounts = new Buffer(width)) + { + int offsetY = y - startY; + int offsetX = minX - startX; + for (int i = 0; i < width; i++) + { + float distance = Vector2.Distance(centre, new Vector2(i + offsetX, offsetY)); + amounts[i] = (this.options.BlendPercentage * (1 - (.95F * (distance / maxDistance)))).Clamp(0, 1); + } - BufferSpan destination = sourcePixels.GetRowSpan(offsetY).Slice(offsetX, width); + BufferSpan destination = sourcePixels.GetRowSpan(offsetY).Slice(offsetX, width); - blender.Compose(destination, destination, rowColors, amounts); - } + this.blender.Blend(destination, destination, rowColors, amounts); + } + }); } } } diff --git a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessorParallel.cs b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessorParallel.cs deleted file mode 100644 index 8f0247bc25..0000000000 --- a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessorParallel.cs +++ /dev/null @@ -1,98 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp.Processing.Processors -{ - using System; - using System.Numerics; - using System.Threading.Tasks; - - using ImageSharp.PixelFormats; - - /// - /// An that applies a radial glow effect an . - /// - /// The pixel format. - internal class GlowProcessorParallel : ImageProcessor - where TPixel : struct, IPixel - { - /// - /// Initializes a new instance of the class. - /// - /// The color or the glow. - public GlowProcessorParallel(TPixel color) - { - this.GlowColor = color; - } - - /// - /// Gets or sets the glow color to apply. - /// - public TPixel GlowColor { get; set; } - - /// - /// Gets or sets the the radius. - /// - public float Radius { get; set; } - - /// - protected override void OnApply(ImageBase source, Rectangle sourceRectangle) - { - int startY = sourceRectangle.Y; - int endY = sourceRectangle.Bottom; - int startX = sourceRectangle.X; - int endX = sourceRectangle.Right; - TPixel glowColor = this.GlowColor; - Vector2 centre = Rectangle.Center(sourceRectangle).ToVector2(); - float maxDistance = this.Radius > 0 ? MathF.Min(this.Radius, sourceRectangle.Width * .5F) : sourceRectangle.Width * .5F; - - // Align start/end positions. - int minX = Math.Max(0, startX); - int maxX = Math.Min(source.Width, endX); - int minY = Math.Max(0, startY); - int maxY = Math.Min(source.Height, endY); - - // Reset offset if necessary. - if (minX > 0) - { - startX = 0; - } - - if (minY > 0) - { - startY = 0; - } - - int width = maxX - minX; - using (Buffer rowColors = new Buffer(width)) - using (PixelAccessor sourcePixels = source.Lock()) - { - for (int i = 0; i < width; i++) - { - rowColors[i] = glowColor; - } - - Parallel.For( - minY, - maxY, - this.ParallelOptions, - y => - { - int offsetY = y - startY; - - for (int x = minX; x < maxX; x++) - { - int offsetX = x - startX; - float distance = Vector2.Distance(centre, new Vector2(offsetX, offsetY)); - Vector4 sourceColor = sourcePixels[offsetX, offsetY].ToVector4(); - TPixel packed = default(TPixel); - packed.PackFromVector4(Vector4BlendTransforms.PremultipliedLerp(sourceColor, glowColor.ToVector4(), 1 - (.95F * (distance / maxDistance)))); - sourcePixels[offsetX, offsetY] = packed; - } - }); - } - } - } -} \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs index 9b7dbe21a2..748bbf4fad 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs @@ -12,6 +12,10 @@ namespace ImageSharp.Benchmarks using ImageSharp.Processing.Processors; using CoreImage = ImageSharp.Image; using CoreSize = ImageSharp.Size; + using ImageSharp.Processing; + using System.Numerics; + using System; + using System.Threading.Tasks; public class Glow : BenchmarkBase { @@ -21,7 +25,7 @@ namespace ImageSharp.Benchmarks [Setup] public void Setup() { - this.bulk = new GlowProcessor(NamedColors.Beige) { Radius = 800 * .5f, }; + this.bulk = new GlowProcessor(NamedColors.Beige, GraphicsOptions.Default) { Radius = 800 * .5f, }; this.parallel = new GlowProcessorParallel(NamedColors.Beige) { Radius = 800 * .5f, }; } @@ -44,5 +48,86 @@ namespace ImageSharp.Benchmarks return new CoreSize(image.Width, image.Height); } } + + internal class GlowProcessorParallel : ImageProcessor + where TPixel : struct, IPixel + { + /// + /// Initializes a new instance of the class. + /// + /// The color or the glow. + public GlowProcessorParallel(TPixel color) + { + this.GlowColor = color; + } + + /// + /// Gets or sets the glow color to apply. + /// + public TPixel GlowColor { get; set; } + + /// + /// Gets or sets the the radius. + /// + public float Radius { get; set; } + + /// + protected override void OnApply(ImageBase source, Rectangle sourceRectangle) + { + int startY = sourceRectangle.Y; + int endY = sourceRectangle.Bottom; + int startX = sourceRectangle.X; + int endX = sourceRectangle.Right; + TPixel glowColor = this.GlowColor; + Vector2 centre = Rectangle.Center(sourceRectangle).ToVector2(); + float maxDistance = this.Radius > 0 ? MathF.Min(this.Radius, sourceRectangle.Width * .5F) : sourceRectangle.Width * .5F; + + // Align start/end positions. + int minX = Math.Max(0, startX); + int maxX = Math.Min(source.Width, endX); + int minY = Math.Max(0, startY); + int maxY = Math.Min(source.Height, endY); + + // Reset offset if necessary. + if (minX > 0) + { + startX = 0; + } + + if (minY > 0) + { + startY = 0; + } + + int width = maxX - minX; + using (Buffer rowColors = new Buffer(width)) + using (PixelAccessor sourcePixels = source.Lock()) + { + for (int i = 0; i < width; i++) + { + rowColors[i] = glowColor; + } + + Parallel.For( + minY, + maxY, + this.ParallelOptions, + y => + { + int offsetY = y - startY; + + for (int x = minX; x < maxX; x++) + { + int offsetX = x - startX; + float distance = Vector2.Distance(centre, new Vector2(offsetX, offsetY)); + Vector4 sourceColor = sourcePixels[offsetX, offsetY].ToVector4(); + TPixel packed = default(TPixel); + packed.PackFromVector4(Vector4BlendTransforms.PremultipliedLerp(sourceColor, glowColor.ToVector4(), 1 - (.95F * (distance / maxDistance)))); + sourcePixels[offsetX, offsetY] = packed; + } + }); + } + } + } } } diff --git a/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs b/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs new file mode 100644 index 0000000000..6c742c2e0f --- /dev/null +++ b/tests/ImageSharp.Tests/Drawing/BlendedShapes.cs @@ -0,0 +1,56 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp.Tests.Drawing +{ + using System; + using System.Linq; + using System.Collections.Generic; + using System.Text; + using ImageSharp.PixelFormats; + using Xunit; + + public class BlendedShapes + { + public static IEnumerable modes = ((PixelBlenderMode[])Enum.GetValues(typeof(PixelBlenderMode))) + .Select(x=> new object[] { x }); + + [Theory] + [WithBlankImages(nameof(modes), 100, 100, PixelTypes.StandardImageClass)] + public void DrawBlendedValues(TestImageProvider provider, PixelBlenderMode mode) + where TPixel : struct, IPixel + { + using (var img = provider.GetImage()) + { + img.Fill(NamedColors.DarkBlue, new Rectangle(0, 40, 100, 20)); + img.Fill(NamedColors.HotPink, new Rectangle(40, 0, 20, 100), new ImageSharp.GraphicsOptions(true) + { + BlenderMode = mode + }); + img.DebugSave(provider, new { mode }); + } + } + + [Theory] + [WithBlankImages(nameof(modes), 100, 100, PixelTypes.StandardImageClass)] + public void DrawBlendedValues_transparent(TestImageProvider provider, PixelBlenderMode mode) + where TPixel : struct, IPixel + { + using (var img = provider.GetImage()) + { + img.Fill(NamedColors.DarkBlue, new Rectangle(0, 40, 100, 20)); + img.Fill(NamedColors.HotPink, new Rectangle(20, 0, 40, 100), new ImageSharp.GraphicsOptions(true) + { + BlenderMode = mode + }); + img.Fill(NamedColors.Transparent, new Rectangle(40, 0, 20, 100), new ImageSharp.GraphicsOptions(true) + { + BlenderMode = mode + }); + img.DebugSave(provider, new { mode }); + } + } + } +} diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageEffectTest.cs b/tests/ImageSharp.Tests/Drawing/DrawImageEffectTest.cs index f71de1466f..885029fdff 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageEffectTest.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageEffectTest.cs @@ -1,29 +1,29 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp.Tests -{ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp.Tests +{ using System.IO; using ImageSharp.Drawing; - using ImageSharp.PixelFormats; - using Xunit; - - public class DrawImageEffectTest : FileTestBase - { - [Fact] - public void ImageShouldApplyDrawImageFilter() - { + using ImageSharp.PixelFormats; + using Xunit; + + public class DrawImageEffectTest : FileTestBase + { + [Fact] + public void ImageShouldApplyDrawImageFilter() + { string path = this.CreateOutputDirectory("Drawing", "DrawImageEffect"); - PixelBlenderMode[] modes = (PixelBlenderMode[])System.Enum.GetValues(typeof(PixelBlenderMode)); - - using (Image blend = TestFile.Create(TestImages.Png.Blur).CreateImage()) - { - foreach (TestFile file in Files) - { - using (Image image = file.CreateImage()) + PixelBlenderMode[] modes = (PixelBlenderMode[])System.Enum.GetValues(typeof(PixelBlenderMode)); + + using (Image blend = TestFile.Create(TestImages.Png.Blur).CreateImage()) + { + foreach (TestFile file in Files) + { + using (Image image = file.CreateImage()) { foreach (PixelBlenderMode mode in modes) { @@ -37,10 +37,10 @@ namespace ImageSharp.Tests BlendPercentage = .75f }).Save(output); } - } - } - } - } - } - } + } + } + } + } + } + } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs index 1f5971424c..5fa1fccbc0 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffFunctionsTests_TPixel.cs @@ -41,7 +41,7 @@ namespace ImageSharp.Tests.PixelFormats.PixelBlenders public void NormalBlendFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultNormalPixelBlender().Compose(back, source, amount); + TPixel actual = new DefaultNormalPixelBlender().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -51,7 +51,7 @@ namespace ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { BufferSpan dest = new BufferSpan(new TPixel[1]); - new DefaultNormalPixelBlender().Compose(dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultNormalPixelBlender().Blend(dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -80,7 +80,7 @@ namespace ImageSharp.Tests.PixelFormats.PixelBlenders public void MultiplyFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultMultiplyPixelBlender().Compose(back, source, amount); + TPixel actual = new DefaultMultiplyPixelBlender().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -90,7 +90,7 @@ namespace ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { BufferSpan dest = new BufferSpan(new TPixel[1]); - new DefaultMultiplyPixelBlender().Compose(dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultMultiplyPixelBlender().Blend(dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -119,7 +119,7 @@ namespace ImageSharp.Tests.PixelFormats.PixelBlenders public void AddFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultAddPixelBlender().Compose(back, source, amount); + TPixel actual = new DefaultAddPixelBlender().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -129,7 +129,7 @@ namespace ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { BufferSpan dest = new BufferSpan(new TPixel[1]); - new DefaultAddPixelBlender().Compose(dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultAddPixelBlender().Blend(dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -158,7 +158,7 @@ namespace ImageSharp.Tests.PixelFormats.PixelBlenders public void SubstractFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultSubstractPixelBlender().Compose(back, source, amount); + TPixel actual = new DefaultSubstractPixelBlender().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -168,7 +168,7 @@ namespace ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { BufferSpan dest = new BufferSpan(new TPixel[1]); - new DefaultSubstractPixelBlender().Compose(dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultSubstractPixelBlender().Blend(dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -197,7 +197,7 @@ namespace ImageSharp.Tests.PixelFormats.PixelBlenders public void ScreenFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultScreenPixelBlender().Compose(back, source, amount); + TPixel actual = new DefaultScreenPixelBlender().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -207,7 +207,7 @@ namespace ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { BufferSpan dest = new BufferSpan(new TPixel[1]); - new DefaultScreenPixelBlender().Compose(dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultScreenPixelBlender().Blend(dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -236,7 +236,7 @@ namespace ImageSharp.Tests.PixelFormats.PixelBlenders public void DarkenFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultDarkenPixelBlender().Compose(back, source, amount); + TPixel actual = new DefaultDarkenPixelBlender().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -246,7 +246,7 @@ namespace ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { BufferSpan dest = new BufferSpan(new TPixel[1]); - new DefaultDarkenPixelBlender().Compose(dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultDarkenPixelBlender().Blend(dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -275,7 +275,7 @@ namespace ImageSharp.Tests.PixelFormats.PixelBlenders public void LightenFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultLightenPixelBlender().Compose(back, source, amount); + TPixel actual = new DefaultLightenPixelBlender().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -285,7 +285,7 @@ namespace ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { BufferSpan dest = new BufferSpan(new TPixel[1]); - new DefaultLightenPixelBlender().Compose(dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultLightenPixelBlender().Blend(dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -314,7 +314,7 @@ namespace ImageSharp.Tests.PixelFormats.PixelBlenders public void OverlayFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultOverlayPixelBlender().Compose(back, source, amount); + TPixel actual = new DefaultOverlayPixelBlender().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -324,7 +324,7 @@ namespace ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { BufferSpan dest = new BufferSpan(new TPixel[1]); - new DefaultOverlayPixelBlender().Compose(dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultOverlayPixelBlender().Blend(dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } @@ -353,7 +353,7 @@ namespace ImageSharp.Tests.PixelFormats.PixelBlenders public void HardLightFunction_Blender(TestPixel back, TestPixel source, float amount, TestPixel expected) where TPixel : struct, IPixel { - TPixel actual = new DefaultHardLightPixelBlender().Compose(back, source, amount); + TPixel actual = new DefaultHardLightPixelBlender().Blend(back, source, amount); VectorAssert.Equal(expected, actual, 2); } @@ -363,7 +363,7 @@ namespace ImageSharp.Tests.PixelFormats.PixelBlenders where TPixel : struct, IPixel { BufferSpan dest = new BufferSpan(new TPixel[1]); - new DefaultHardLightPixelBlender().Compose(dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); + new DefaultHardLightPixelBlender().Blend(dest, back.AsSpan(), source.AsSpan(), AsSpan(amount)); VectorAssert.Equal(expected, dest[0], 2); } }