diff --git a/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs b/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs index 42051ca93..79fe68c20 100644 --- a/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs +++ b/src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs @@ -11,6 +11,19 @@ namespace SixLabors.ImageSharp.Processing; /// public static class DrawImageExtensions { + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + float opacity) + => DrawImage(source, foreground, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -26,12 +39,27 @@ public static class DrawImageExtensions this IImageProcessingContext source, Image foreground, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) { GraphicsOptions options = source.GetGraphicsOptions(); return DrawImage(source, foreground, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, foregroundRepeatCount); } + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The rectangle structure that specifies the portion of the image to draw. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Rectangle foregroundRectangle, + float opacity) + => DrawImage(source, foreground, foregroundRectangle, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -49,12 +77,27 @@ public static class DrawImageExtensions Image foreground, Rectangle foregroundRectangle, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) { GraphicsOptions options = source.GetGraphicsOptions(); return DrawImage(source, foreground, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, foregroundRepeatCount); } + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The color blending mode. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + PixelColorBlendingMode colorBlending, + float opacity) + => DrawImage(source, foreground, colorBlending, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -72,9 +115,26 @@ public static class DrawImageExtensions Image foreground, PixelColorBlendingMode colorBlending, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, Point.Empty, colorBlending, opacity, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The rectangle structure that specifies the portion of the image to draw. + /// The color blending mode. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Rectangle foregroundRectangle, + PixelColorBlendingMode colorBlending, + float opacity) + => DrawImage(source, foreground, foregroundRectangle, colorBlending, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -94,9 +154,26 @@ public static class DrawImageExtensions Rectangle foregroundRectangle, PixelColorBlendingMode colorBlending, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, Point.Empty, foregroundRectangle, colorBlending, opacity, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The color blending mode. + /// The alpha composition mode. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + PixelColorBlendingMode colorBlending, + PixelAlphaCompositionMode alphaComposition, + float opacity) + => DrawImage(source, foreground, colorBlending, alphaComposition, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -116,9 +193,28 @@ public static class DrawImageExtensions PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, Point.Empty, colorBlending, alphaComposition, opacity, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The rectangle structure that specifies the portion of the image to draw. + /// The color blending mode. + /// The alpha composition mode. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Rectangle foregroundRectangle, + PixelColorBlendingMode colorBlending, + PixelAlphaCompositionMode alphaComposition, + float opacity) + => DrawImage(source, foreground, foregroundRectangle, colorBlending, alphaComposition, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -140,9 +236,22 @@ public static class DrawImageExtensions PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, Point.Empty, foregroundRectangle, colorBlending, alphaComposition, opacity, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The options, including the blending type and blending amount. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + GraphicsOptions options) + => DrawImage(source, foreground, options, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -158,9 +267,24 @@ public static class DrawImageExtensions this IImageProcessingContext source, Image foreground, GraphicsOptions options, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, Point.Empty, options, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The rectangle structure that specifies the portion of the image to draw. + /// The options, including the blending type and blending amount. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Rectangle foregroundRectangle, + GraphicsOptions options) + => DrawImage(source, foreground, foregroundRectangle, options, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -178,9 +302,24 @@ public static class DrawImageExtensions Image foreground, Rectangle foregroundRectangle, GraphicsOptions options, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, Point.Empty, foregroundRectangle, options, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Point backgroundLocation, + float opacity) + => DrawImage(source, foreground, backgroundLocation, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -198,12 +337,29 @@ public static class DrawImageExtensions Image foreground, Point backgroundLocation, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) { GraphicsOptions options = source.GetGraphicsOptions(); return DrawImage(source, foreground, backgroundLocation, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, foregroundRepeatCount); } + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The rectangle structure that specifies the portion of the image to draw. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Point backgroundLocation, + Rectangle foregroundRectangle, + float opacity) + => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -223,12 +379,29 @@ public static class DrawImageExtensions Point backgroundLocation, Rectangle foregroundRectangle, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) { GraphicsOptions options = source.GetGraphicsOptions(); return DrawImage(source, foreground, backgroundLocation, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, opacity, foregroundRepeatCount); } + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The color blending to apply. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Point backgroundLocation, + PixelColorBlendingMode colorBlending, + float opacity) + => DrawImage(source, foreground, backgroundLocation, colorBlending, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -248,9 +421,28 @@ public static class DrawImageExtensions Point backgroundLocation, PixelColorBlendingMode colorBlending, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, backgroundLocation, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The rectangle structure that specifies the portion of the image to draw. + /// The color blending to apply. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Point backgroundLocation, + Rectangle foregroundRectangle, + PixelColorBlendingMode colorBlending, + float opacity) + => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, colorBlending, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -272,9 +464,24 @@ public static class DrawImageExtensions Rectangle foregroundRectangle, PixelColorBlendingMode colorBlending, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The options containing the blend mode and opacity. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Point backgroundLocation, + GraphicsOptions options) + => DrawImage(source, foreground, backgroundLocation, options, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -292,9 +499,26 @@ public static class DrawImageExtensions Image foreground, Point backgroundLocation, GraphicsOptions options, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, backgroundLocation, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The rectangle structure that specifies the portion of the image to draw. + /// The options containing the blend mode and opacity. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Point backgroundLocation, + Rectangle foregroundRectangle, + GraphicsOptions options) + => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, options, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -314,9 +538,28 @@ public static class DrawImageExtensions Point backgroundLocation, Rectangle foregroundRectangle, GraphicsOptions options, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage, foregroundRepeatCount); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The color blending to apply. + /// The alpha composition mode. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Point backgroundLocation, + PixelColorBlendingMode colorBlending, + PixelAlphaCompositionMode alphaComposition, + float opacity) + => DrawImage(source, foreground, backgroundLocation, colorBlending, alphaComposition, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -338,9 +581,30 @@ public static class DrawImageExtensions PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity, - int foregroundRepeatCount = 0) + int foregroundRepeatCount) => source.ApplyProcessor(new DrawImageProcessor(foreground, backgroundLocation, foreground.Bounds, colorBlending, alphaComposition, opacity, foregroundRepeatCount)); + /// + /// Draws the given image together with the currently processing image by blending their pixels. + /// + /// The current image processing context. + /// The image to draw on the currently processing image. + /// The location on the currently processing image at which to draw. + /// The rectangle structure that specifies the portion of the image to draw. + /// The color blending to apply. + /// The alpha composition mode. + /// The opacity of the image to draw. Must be between 0 and 1. + /// The . + public static IImageProcessingContext DrawImage( + this IImageProcessingContext source, + Image foreground, + Point backgroundLocation, + Rectangle foregroundRectangle, + PixelColorBlendingMode colorBlending, + PixelAlphaCompositionMode alphaComposition, + float opacity) + => DrawImage(source, foreground, backgroundLocation, foregroundRectangle, colorBlending, alphaComposition, opacity, 0); + /// /// Draws the given image together with the currently processing image by blending their pixels. /// @@ -364,7 +628,7 @@ public static class DrawImageExtensions PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity, - int foregroundRepeatCount = 0) => + int foregroundRepeatCount) => source.ApplyProcessor( new DrawImageProcessor(foreground, backgroundLocation, foregroundRectangle, colorBlending, alphaComposition, opacity, foregroundRepeatCount), foregroundRectangle);