diff --git a/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs b/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs
index df6080162..8ccbe22ac 100644
--- a/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs
+++ b/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs
@@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Processing
/// The .
public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, float opacity)
where TPixel : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, opacity));
+ => source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode, opacity));
///
/// Draws the given image together with the current one by blending their pixels.
@@ -30,63 +30,92 @@ namespace SixLabors.ImageSharp.Processing
/// The pixel format.
/// The image this method extends.
/// The image to blend with the currently processing image.
- /// The blending mode.
+ /// The blending mode.
/// The opacity of the image to blend. Must be between 0 and 1.
/// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelColorBlendingMode blender, float opacity)
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelColorBlendingMode colorBlending, float opacity)
where TPixel : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, opacity, blender));
-
+ => source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, colorBlending, GraphicsOptions.Default.AlphaCompositionMode, opacity));
+
///
/// Draws the given image together with the current one by blending their pixels.
///
/// The pixel format.
/// The image this method extends.
- /// The options, including the blending type and blending amount.
/// The image to blend with the currently processing image.
+ /// The color blending mode.
+ /// The alpha composition mode.
+ /// The opacity of the image to blend. Must be between 0 and 1.
/// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, GraphicsOptions options, Image image)
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity)
where TPixel : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, options));
-
+ => source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, colorBlending, alphaComposition, opacity));
+
///
/// Draws the given image together with the current one by blending their pixels.
///
- /// The image this method extends.
+ /// The pixel format.
+ /// The image this method extends.
/// The image to blend with the currently processing image.
+ /// The options, including the blending type and blending amount.
+ /// The .
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, GraphicsOptions options)
+ where TPixel : struct, IPixel
+ => source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage));
+
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
+ ///
/// The pixel format.
- /// The opacity of the image to blend. Must be between 0 and 1.
+ /// The image this method extends.
+ /// The image to blend with the currently processing image.
/// The location to draw the blended image.
+ /// The opacity of the image to blend. Must be between 0 and 1.
/// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, float opacity, Point location)
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, float opacity)
where TPixel : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, location, opacity));
-
+ => source.ApplyProcessor(new DrawImageProcessor(image, location, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode, opacity));
+
///
/// Draws the given image together with the current one by blending their pixels.
- ///
- /// The image this method extends.
- /// The image to blend with the currently processing image.
+ ///
/// The pixel format.
- /// The type of bending to apply.
- /// The opacity of the image to blend. Must be between 0 and 1.
+ /// The image this method extends.
+ /// The image to blend with the currently processing image.
/// The location to draw the blended image.
+ /// The color blending to apply.
+ /// The opacity of the image to blend. Must be between 0 and 1.
/// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelColorBlendingMode blender, float opacity, Point location)
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, PixelColorBlendingMode colorBlending, float opacity)
where TPixel : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, location, opacity, blender));
-
+ => source.ApplyProcessor(new DrawImageProcessor(image, location, colorBlending, GraphicsOptions.Default.AlphaCompositionMode, opacity));
+
///
/// Draws the given image together with the current one by blending their pixels.
- ///
- /// The image this method extends.
- /// The options containing the blend mode and opacity.
- /// The image to blend with the currently processing image.
+ ///
/// The pixel format.
+ /// The image this method extends.
+ /// The image to blend with the currently processing image.
/// The location to draw the blended image.
+ /// The color blending to apply.
+ /// The alpha composition mode.
+ /// The opacity of the image to blend. Must be between 0 and 1.
+ /// The .
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity)
+ where TPixel : struct, IPixel
+ => source.ApplyProcessor(new DrawImageProcessor(image, location, colorBlending, alphaComposition, opacity));
+
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
+ ///
+ /// The pixel format.
+ /// The image this method extends.
+ /// The image to blend with the currently processing image.
+ /// The location to draw the blended image.
+ /// The options containing the blend mode and opacity.
/// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, GraphicsOptions options, Image image, Point location)
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, GraphicsOptions options)
where TPixel : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, location, options));
+ => source.ApplyProcessor(new DrawImageProcessor(image, location, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage));
}
}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs b/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs
index 760086183..324d25e09 100644
--- a/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs
+++ b/src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawImageProcessor.cs
@@ -18,99 +18,16 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing
/// The pixel format.
internal class DrawImageProcessor : ImageProcessor
where TPixel : struct, IPixel
- {
+ {
///
/// Initializes a new instance of the class.
///
/// The image to blend with the currently processing image.
- /// The opacity of the image to blend. Must be between 0 and 1.
- public DrawImageProcessor(Image image, float opacity)
- : this(image, Point.Empty, opacity)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The image to blend with the currently processing image.
- ///
- /// The options containing the opacity of the image to blend and blending mode.
- /// Opacity must be between 0 and 1.
- ///
- public DrawImageProcessor(Image image, GraphicsOptions options)
- : this(image, Point.Empty, options)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The image to blend with the currently processing image.
- /// The opacity of the image to blend. Must be between 0 and 1.
- /// The blending mode to use when drawing the image.
- public DrawImageProcessor(Image image, float opacity, PixelColorBlendingMode colorBlendingMode)
- : this(image, Point.Empty, opacity, colorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The image to blend with the currently processing image.
- /// The opacity of the image to blend. Must be between 0 and 1.
- /// The Color blending mode to use when drawing the image.
- /// The Alpha blending mode to use when drawing the image.
- public DrawImageProcessor(Image image, float opacity, PixelColorBlendingMode colorBlendingMode, PixelAlphaCompositionMode alphaCompositionMode)
- : this(image, Point.Empty, opacity, colorBlendingMode, alphaCompositionMode)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The image to blend with the currently processing image.
- /// The location to draw the blended image.
- /// The opacity of the image to blend. Must be between 0 and 1.
- public DrawImageProcessor(Image image, Point location, float opacity)
- : this(image, location, opacity, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The image to blend with the currently processing image.
- /// The location to draw the blended image.
- ///
- /// The options containing the opacity of the image to blend and blending mode.
- /// Opacity must be between 0 and 1.
- ///
- public DrawImageProcessor(Image image, Point location, GraphicsOptions options)
- : this(image, location, options.BlendPercentage, options.ColorBlendingMode, options.AlphaCompositionMode)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The image to blend with the currently processing image.
- /// The location to draw the blended image.
- /// The opacity of the image to blend. Must be between 0 and 1.
- /// The blending mode to use when drawing the image.
- public DrawImageProcessor(Image image, Point location, float opacity, PixelColorBlendingMode colorBlendingMode)
- : this(image, location, opacity, colorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The image to blend with the currently processing image.
- /// The location to draw the blended image.
- /// The opacity of the image to blend. Must be between 0 and 1.
+ /// The location to draw the blended image.
/// The blending mode to use when drawing the image.
- /// The Alpha blending mode to use when drawing the image.
- public DrawImageProcessor(Image image, Point location, float opacity, PixelColorBlendingMode colorBlendingMode, PixelAlphaCompositionMode alphaCompositionMode)
+ /// The Alpha blending mode to use when drawing the image.
+ /// The opacity of the image to blend. Must be between 0 and 1.
+ public DrawImageProcessor(Image image, Point location, PixelColorBlendingMode colorBlendingMode, PixelAlphaCompositionMode alphaCompositionMode, float opacity)
{
Guard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity));
diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs
index f50df3b34..740b30a8c 100644
--- a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs
+++ b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs
@@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Tests
using (var blend = Image.Load(TestFile.Create(TestImages.Bmp.Car).Bytes))
{
blend.Mutate(x => x.Resize(image.Width / 2, image.Height / 2));
- image.Mutate(x => x.DrawImage(blend, mode, .75f, new Point(image.Width / 4, image.Height / 4)));
+ image.Mutate(x => x.DrawImage(blend, new Point(image.Width / 4, image.Height / 4), mode, .75f) );
image.DebugSave(provider, new { mode });
}
}
@@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.Tests
new Rectangle(0, 0, destBounds.Width, destBounds.Height)));
var position = new Point((image.Width - blend.Width) / 2, (image.Height - blend.Height) / 2);
- image.Mutate(x => x.DrawImage(blend, mode, .75F, position));
+ image.Mutate(x => x.DrawImage(blend, position, mode, .75F));
image.DebugSave(provider, new[] { "Transformed" });
}
}
@@ -88,7 +88,7 @@ namespace SixLabors.ImageSharp.Tests
Rgba32 backgroundPixel = background[0, 0];
Rgba32 overlayPixel = overlay[Math.Abs(xy) + 1, Math.Abs(xy) + 1];
- background.Mutate(x => x.DrawImage(overlay, PixelColorBlendingMode.Normal, 1F, new Point(xy, xy)));
+ background.Mutate(x => x.DrawImage(overlay, new Point(xy, xy), PixelColorBlendingMode.Normal, 1F));
Assert.Equal(Rgba32.White, backgroundPixel);
Assert.Equal(overlayPixel, background[0, 0]);
@@ -110,7 +110,7 @@ namespace SixLabors.ImageSharp.Tests
Rgba32 backgroundPixel = background[xy - 1, xy - 1];
Rgba32 overlayPixel = overlay[0, 0];
- background.Mutate(x => x.DrawImage(overlay, PixelColorBlendingMode.Normal, 1F, new Point(xy, xy)));
+ background.Mutate(x => x.DrawImage(overlay, new Point(xy, xy), PixelColorBlendingMode.Normal, 1F));
Assert.Equal(Rgba32.White, backgroundPixel);
Assert.Equal(overlayPixel, background[xy, xy]);
diff --git a/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs b/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs
index f6a5b5cdd..6c0efce7a 100644
--- a/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs
+++ b/tests/ImageSharp.Tests/Drawing/SolidFillBlendedShapesTests.cs
@@ -131,7 +131,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
new Shapes.EllipsePolygon(40 * scaleX, 50 * scaleY, 50 * scaleX, 50 * scaleY)));
dstImg.Mutate(
- x => x.DrawImage(new GraphicsOptions(true) { ColorBlendingMode = mode }, srcImg)
+ x => x.DrawImage(srcImg, new GraphicsOptions(true) { ColorBlendingMode = mode })
);
VerifyImage(provider, mode, dstImg);
diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffCompositorTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffCompositorTests.cs
index 316a7b216..9c3ea90d5 100644
--- a/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffCompositorTests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffCompositorTests.cs
@@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
AlphaCompositionMode = mode
};
- using (Image res = dest.Clone(x => x.DrawImage(options, src)))
+ using (Image res = dest.Clone(x => x.DrawImage(src, options)))
{
string combinedMode = mode.ToString();