Browse Source

Use overloads not nullable params

pull/2995/head
James Jackson-South 2 weeks ago
parent
commit
99aadf6b03
  1. 296
      src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs

296
src/ImageSharp/Processing/Extensions/Drawing/DrawImageExtensions.cs

@ -11,6 +11,19 @@ namespace SixLabors.ImageSharp.Processing;
/// </summary>
public static class DrawImageExtensions
{
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
/// <param name="source">The current image processing context.</param>
/// <param name="foreground">The image to draw on the currently processing image.</param>
/// <param name="opacity">The opacity of the image to draw. Must be between 0 and 1.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DrawImage(
this IImageProcessingContext source,
Image foreground,
float opacity)
=> DrawImage(source, foreground, opacity, 0);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
@ -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);
}
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
/// <param name="source">The current image processing context.</param>
/// <param name="foreground">The image to draw on the currently processing image.</param>
/// <param name="foregroundRectangle">The rectangle structure that specifies the portion of the image to draw.</param>
/// <param name="opacity">The opacity of the image to draw. Must be between 0 and 1.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DrawImage(
this IImageProcessingContext source,
Image foreground,
Rectangle foregroundRectangle,
float opacity)
=> DrawImage(source, foreground, foregroundRectangle, opacity, 0);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
@ -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);
}
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
/// <param name="source">The current image processing context.</param>
/// <param name="foreground">The image to draw on the currently processing image.</param>
/// <param name="colorBlending">The color blending mode.</param>
/// <param name="opacity">The opacity of the image to draw. Must be between 0 and 1.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DrawImage(
this IImageProcessingContext source,
Image foreground,
PixelColorBlendingMode colorBlending,
float opacity)
=> DrawImage(source, foreground, colorBlending, opacity, 0);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
@ -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);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
/// <param name="source">The current image processing context.</param>
/// <param name="foreground">The image to draw on the currently processing image.</param>
/// <param name="foregroundRectangle">The rectangle structure that specifies the portion of the image to draw.</param>
/// <param name="colorBlending">The color blending mode.</param>
/// <param name="opacity">The opacity of the image to draw. Must be between 0 and 1.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DrawImage(
this IImageProcessingContext source,
Image foreground,
Rectangle foregroundRectangle,
PixelColorBlendingMode colorBlending,
float opacity)
=> DrawImage(source, foreground, foregroundRectangle, colorBlending, opacity, 0);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
@ -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);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
/// <param name="source">The current image processing context.</param>
/// <param name="foreground">The image to draw on the currently processing image.</param>
/// <param name="colorBlending">The color blending mode.</param>
/// <param name="alphaComposition">The alpha composition mode.</param>
/// <param name="opacity">The opacity of the image to draw. Must be between 0 and 1.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DrawImage(
this IImageProcessingContext source,
Image foreground,
PixelColorBlendingMode colorBlending,
PixelAlphaCompositionMode alphaComposition,
float opacity)
=> DrawImage(source, foreground, colorBlending, alphaComposition, opacity, 0);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
@ -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);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
/// <param name="source">The current image processing context.</param>
/// <param name="foreground">The image to draw on the currently processing image.</param>
/// <param name="foregroundRectangle">The rectangle structure that specifies the portion of the image to draw.</param>
/// <param name="colorBlending">The color blending mode.</param>
/// <param name="alphaComposition">The alpha composition mode.</param>
/// <param name="opacity">The opacity of the image to draw. Must be between 0 and 1.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns>
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);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
@ -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);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
/// <param name="source">The current image processing context.</param>
/// <param name="foreground">The image to draw on the currently processing image.</param>
/// <param name="options">The options, including the blending type and blending amount.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DrawImage(
this IImageProcessingContext source,
Image foreground,
GraphicsOptions options)
=> DrawImage(source, foreground, options, 0);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
@ -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);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
/// <param name="source">The current image processing context.</param>
/// <param name="foreground">The image to draw on the currently processing image.</param>
/// <param name="foregroundRectangle">The rectangle structure that specifies the portion of the image to draw.</param>
/// <param name="options">The options, including the blending type and blending amount.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DrawImage(
this IImageProcessingContext source,
Image foreground,
Rectangle foregroundRectangle,
GraphicsOptions options)
=> DrawImage(source, foreground, foregroundRectangle, options, 0);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
@ -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);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
/// <param name="source">The current image processing context.</param>
/// <param name="foreground">The image to draw on the currently processing image.</param>
/// <param name="backgroundLocation">The location on the currently processing image at which to draw.</param>
/// <param name="opacity">The opacity of the image to draw. Must be between 0 and 1.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DrawImage(
this IImageProcessingContext source,
Image foreground,
Point backgroundLocation,
float opacity)
=> DrawImage(source, foreground, backgroundLocation, opacity, 0);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
@ -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);
}
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
/// <param name="source">The current image processing context.</param>
/// <param name="foreground">The image to draw on the currently processing image.</param>
/// <param name="backgroundLocation">The location on the currently processing image at which to draw.</param>
/// <param name="foregroundRectangle">The rectangle structure that specifies the portion of the image to draw.</param>
/// <param name="opacity">The opacity of the image to draw. Must be between 0 and 1.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DrawImage(
this IImageProcessingContext source,
Image foreground,
Point backgroundLocation,
Rectangle foregroundRectangle,
float opacity)
=> DrawImage(source, foreground, backgroundLocation, foregroundRectangle, opacity, 0);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
@ -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);
}
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
/// <param name="source">The current image processing context.</param>
/// <param name="foreground">The image to draw on the currently processing image.</param>
/// <param name="backgroundLocation">The location on the currently processing image at which to draw.</param>
/// <param name="colorBlending">The color blending to apply.</param>
/// <param name="opacity">The opacity of the image to draw. Must be between 0 and 1.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DrawImage(
this IImageProcessingContext source,
Image foreground,
Point backgroundLocation,
PixelColorBlendingMode colorBlending,
float opacity)
=> DrawImage(source, foreground, backgroundLocation, colorBlending, opacity, 0);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
@ -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);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
/// <param name="source">The current image processing context.</param>
/// <param name="foreground">The image to draw on the currently processing image.</param>
/// <param name="backgroundLocation">The location on the currently processing image at which to draw.</param>
/// <param name="foregroundRectangle">The rectangle structure that specifies the portion of the image to draw.</param>
/// <param name="colorBlending">The color blending to apply.</param>
/// <param name="opacity">The opacity of the image to draw. Must be between 0 and 1.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns>
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);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
@ -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);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
/// <param name="source">The current image processing context.</param>
/// <param name="foreground">The image to draw on the currently processing image.</param>
/// <param name="backgroundLocation">The location on the currently processing image at which to draw.</param>
/// <param name="options">The options containing the blend mode and opacity.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DrawImage(
this IImageProcessingContext source,
Image foreground,
Point backgroundLocation,
GraphicsOptions options)
=> DrawImage(source, foreground, backgroundLocation, options, 0);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
@ -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);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
/// <param name="source">The current image processing context.</param>
/// <param name="foreground">The image to draw on the currently processing image.</param>
/// <param name="backgroundLocation">The location on the currently processing image at which to draw.</param>
/// <param name="foregroundRectangle">The rectangle structure that specifies the portion of the image to draw.</param>
/// <param name="options">The options containing the blend mode and opacity.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DrawImage(
this IImageProcessingContext source,
Image foreground,
Point backgroundLocation,
Rectangle foregroundRectangle,
GraphicsOptions options)
=> DrawImage(source, foreground, backgroundLocation, foregroundRectangle, options, 0);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
@ -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);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
/// <param name="source">The current image processing context.</param>
/// <param name="foreground">The image to draw on the currently processing image.</param>
/// <param name="backgroundLocation">The location on the currently processing image at which to draw.</param>
/// <param name="colorBlending">The color blending to apply.</param>
/// <param name="alphaComposition">The alpha composition mode.</param>
/// <param name="opacity">The opacity of the image to draw. Must be between 0 and 1.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns>
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);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
@ -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));
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
/// <param name="source">The current image processing context.</param>
/// <param name="foreground">The image to draw on the currently processing image.</param>
/// <param name="backgroundLocation">The location on the currently processing image at which to draw.</param>
/// <param name="foregroundRectangle">The rectangle structure that specifies the portion of the image to draw.</param>
/// <param name="colorBlending">The color blending to apply.</param>
/// <param name="alphaComposition">The alpha composition mode.</param>
/// <param name="opacity">The opacity of the image to draw. Must be between 0 and 1.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns>
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);
/// <summary>
/// Draws the given image together with the currently processing image by blending their pixels.
/// </summary>
@ -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);

Loading…
Cancel
Save