mirror of https://github.com/SixLabors/ImageSharp
6 changed files with 4343 additions and 4125 deletions
@ -1,137 +1,137 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
using SixLabors.ImageSharp.PixelFormats; |
using SixLabors.ImageSharp.PixelFormats; |
||||
using SixLabors.ImageSharp.Processing.Processors.Drawing; |
using SixLabors.ImageSharp.Processing.Processors.Drawing; |
||||
using SixLabors.Primitives; |
using SixLabors.Primitives; |
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// Adds extensions that allow the drawing of images to the <see cref="Image{TPixel}"/> type.
|
/// Adds extensions that allow the drawing of images to the <see cref="Image{TPixel}"/> type.
|
||||
/// </summary>
|
/// </summary>
|
||||
public static class DrawImageExtensions |
public static class DrawImageExtensions |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// Draws the given image together with the current one by blending their pixels.
|
/// Draws the given image together with the current one by blending their pixels.
|
||||
/// </summary>
|
/// </summary>
|
||||
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
||||
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
||||
/// <param name="source">The image this method extends.</param>
|
/// <param name="source">The image this method extends.</param>
|
||||
/// <param name="image">The image to blend with the currently processing image.</param>
|
/// <param name="image">The image to blend with the currently processing image.</param>
|
||||
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
||||
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
||||
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, float opacity) |
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, float opacity) |
||||
where TPixelDst : struct, IPixel<TPixelDst> |
where TPixelDst : struct, IPixel<TPixelDst> |
||||
where TPixelSrc : struct, IPixel<TPixelSrc> |
where TPixelSrc : struct, IPixel<TPixelSrc> |
||||
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, Point.Empty, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode, opacity)); |
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, Point.Empty, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode, opacity)); |
||||
|
|
||||
/// <summary>
|
/// <summary>
|
||||
/// Draws the given image together with the current one by blending their pixels.
|
/// Draws the given image together with the current one by blending their pixels.
|
||||
/// </summary>
|
/// </summary>
|
||||
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
||||
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
||||
/// <param name="source">The image this method extends.</param>
|
/// <param name="source">The image this method extends.</param>
|
||||
/// <param name="image">The image to blend with the currently processing image.</param>
|
/// <param name="image">The image to blend with the currently processing image.</param>
|
||||
/// <param name="colorBlending">The blending mode.</param>
|
/// <param name="colorBlending">The blending mode.</param>
|
||||
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
||||
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
||||
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, PixelColorBlendingMode colorBlending, float opacity) |
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, PixelColorBlendingMode colorBlending, float opacity) |
||||
where TPixelDst : struct, IPixel<TPixelDst> |
where TPixelDst : struct, IPixel<TPixelDst> |
||||
where TPixelSrc : struct, IPixel<TPixelSrc> |
where TPixelSrc : struct, IPixel<TPixelSrc> |
||||
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, Point.Empty, colorBlending, GraphicsOptions.Default.AlphaCompositionMode, opacity)); |
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, Point.Empty, colorBlending, GraphicsOptions.Default.AlphaCompositionMode, opacity)); |
||||
|
|
||||
/// <summary>
|
/// <summary>
|
||||
/// Draws the given image together with the current one by blending their pixels.
|
/// Draws the given image together with the current one by blending their pixels.
|
||||
/// </summary>
|
/// </summary>
|
||||
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
||||
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
||||
/// <param name="source">The image this method extends.</param>
|
/// <param name="source">The image this method extends.</param>
|
||||
/// <param name="image">The image to blend with the currently processing image.</param>
|
/// <param name="image">The image to blend with the currently processing image.</param>
|
||||
/// <param name="colorBlending">The color blending mode.</param>
|
/// <param name="colorBlending">The color blending mode.</param>
|
||||
/// <param name="alphaComposition">The alpha composition mode.</param>
|
/// <param name="alphaComposition">The alpha composition mode.</param>
|
||||
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
||||
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
||||
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity) |
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity) |
||||
where TPixelDst : struct, IPixel<TPixelDst> |
where TPixelDst : struct, IPixel<TPixelDst> |
||||
where TPixelSrc : struct, IPixel<TPixelSrc> |
where TPixelSrc : struct, IPixel<TPixelSrc> |
||||
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, Point.Empty, colorBlending, alphaComposition, opacity)); |
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, Point.Empty, colorBlending, alphaComposition, opacity)); |
||||
|
|
||||
/// <summary>
|
/// <summary>
|
||||
/// Draws the given image together with the current one by blending their pixels.
|
/// Draws the given image together with the current one by blending their pixels.
|
||||
/// </summary>
|
/// </summary>
|
||||
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
||||
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
||||
/// <param name="source">The image this method extends.</param>
|
/// <param name="source">The image this method extends.</param>
|
||||
/// <param name="image">The image to blend with the currently processing image.</param>
|
/// <param name="image">The image to blend with the currently processing image.</param>
|
||||
/// <param name="options">The options, including the blending type and blending amount.</param>
|
/// <param name="options">The options, including the blending type and blending amount.</param>
|
||||
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
||||
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, GraphicsOptions options) |
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, GraphicsOptions options) |
||||
where TPixelDst : struct, IPixel<TPixelDst> |
where TPixelDst : struct, IPixel<TPixelDst> |
||||
where TPixelSrc : struct, IPixel<TPixelSrc> |
where TPixelSrc : struct, IPixel<TPixelSrc> |
||||
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, Point.Empty, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage)); |
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, Point.Empty, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage)); |
||||
|
|
||||
/// <summary>
|
/// <summary>
|
||||
/// Draws the given image together with the current one by blending their pixels.
|
/// Draws the given image together with the current one by blending their pixels.
|
||||
/// </summary>
|
/// </summary>
|
||||
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
||||
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
||||
/// <param name="source">The image this method extends.</param>
|
/// <param name="source">The image this method extends.</param>
|
||||
/// <param name="image">The image to blend with the currently processing image.</param>
|
/// <param name="image">The image to blend with the currently processing image.</param>
|
||||
/// <param name="location">The location to draw the blended image.</param>
|
/// <param name="location">The location to draw the blended image.</param>
|
||||
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
||||
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
||||
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, Point location, float opacity) |
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, Point location, float opacity) |
||||
where TPixelDst : struct, IPixel<TPixelDst> |
where TPixelDst : struct, IPixel<TPixelDst> |
||||
where TPixelSrc : struct, IPixel<TPixelSrc> |
where TPixelSrc : struct, IPixel<TPixelSrc> |
||||
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, location, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode, opacity)); |
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, location, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode, opacity)); |
||||
|
|
||||
/// <summary>
|
/// <summary>
|
||||
/// Draws the given image together with the current one by blending their pixels.
|
/// Draws the given image together with the current one by blending their pixels.
|
||||
/// </summary>
|
/// </summary>
|
||||
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
||||
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
||||
/// <param name="source">The image this method extends.</param>
|
/// <param name="source">The image this method extends.</param>
|
||||
/// <param name="image">The image to blend with the currently processing image.</param>
|
/// <param name="image">The image to blend with the currently processing image.</param>
|
||||
/// <param name="location">The location to draw the blended image.</param>
|
/// <param name="location">The location to draw the blended image.</param>
|
||||
/// <param name="colorBlending">The color blending to apply.</param>
|
/// <param name="colorBlending">The color blending to apply.</param>
|
||||
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
||||
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
||||
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, Point location, PixelColorBlendingMode colorBlending, float opacity) |
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, Point location, PixelColorBlendingMode colorBlending, float opacity) |
||||
where TPixelDst : struct, IPixel<TPixelDst> |
where TPixelDst : struct, IPixel<TPixelDst> |
||||
where TPixelSrc : struct, IPixel<TPixelSrc> |
where TPixelSrc : struct, IPixel<TPixelSrc> |
||||
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, location, colorBlending, GraphicsOptions.Default.AlphaCompositionMode, opacity)); |
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, location, colorBlending, GraphicsOptions.Default.AlphaCompositionMode, opacity)); |
||||
|
|
||||
/// <summary>
|
/// <summary>
|
||||
/// Draws the given image together with the current one by blending their pixels.
|
/// Draws the given image together with the current one by blending their pixels.
|
||||
/// </summary>
|
/// </summary>
|
||||
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
||||
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
||||
/// <param name="source">The image this method extends.</param>
|
/// <param name="source">The image this method extends.</param>
|
||||
/// <param name="image">The image to blend with the currently processing image.</param>
|
/// <param name="image">The image to blend with the currently processing image.</param>
|
||||
/// <param name="location">The location to draw the blended image.</param>
|
/// <param name="location">The location to draw the blended image.</param>
|
||||
/// <param name="colorBlending">The color blending to apply.</param>
|
/// <param name="colorBlending">The color blending to apply.</param>
|
||||
/// <param name="alphaComposition">The alpha composition mode.</param>
|
/// <param name="alphaComposition">The alpha composition mode.</param>
|
||||
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
||||
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
||||
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, Point location, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity) |
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, Point location, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity) |
||||
where TPixelDst : struct, IPixel<TPixelDst> |
where TPixelDst : struct, IPixel<TPixelDst> |
||||
where TPixelSrc : struct, IPixel<TPixelSrc> |
where TPixelSrc : struct, IPixel<TPixelSrc> |
||||
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, location, colorBlending, alphaComposition, opacity)); |
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, location, colorBlending, alphaComposition, opacity)); |
||||
|
|
||||
/// <summary>
|
/// <summary>
|
||||
/// Draws the given image together with the current one by blending their pixels.
|
/// Draws the given image together with the current one by blending their pixels.
|
||||
/// </summary>
|
/// </summary>
|
||||
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
||||
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
||||
/// <param name="source">The image this method extends.</param>
|
/// <param name="source">The image this method extends.</param>
|
||||
/// <param name="image">The image to blend with the currently processing image.</param>
|
/// <param name="image">The image to blend with the currently processing image.</param>
|
||||
/// <param name="location">The location to draw the blended image.</param>
|
/// <param name="location">The location to draw the blended image.</param>
|
||||
/// <param name="options">The options containing the blend mode and opacity.</param>
|
/// <param name="options">The options containing the blend mode and opacity.</param>
|
||||
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
||||
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, Point location, GraphicsOptions options) |
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, Point location, GraphicsOptions options) |
||||
where TPixelDst : struct, IPixel<TPixelDst> |
where TPixelDst : struct, IPixel<TPixelDst> |
||||
where TPixelSrc : struct, IPixel<TPixelSrc> |
where TPixelSrc : struct, IPixel<TPixelSrc> |
||||
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, location, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage)); |
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, location, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage)); |
||||
} |
} |
||||
} |
} |
||||
File diff suppressed because it is too large
File diff suppressed because it is too large
Loading…
Reference in new issue