// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors.Drawing; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing { /// /// Adds extensions that allow the drawing of images to the type. /// public static class DrawImageExtensions { /// /// 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 opacity of the image to blend. Must be between 0 and 1. /// The . public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, float opacity) where TPixel : struct, IPixel => source.ApplyProcessor(new DrawImageProcessor(image, 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 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, PixelBlenderMode blender, float opacity) where TPixel : struct, IPixel => source.ApplyProcessor(new DrawImageProcessor(image, opacity, blender)); /// /// 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 . public static IImageProcessingContext DrawImage(this IImageProcessingContext source, GraphicsOptions options, Image image) where TPixel : struct, IPixel => source.ApplyProcessor(new DrawImageProcessor(image, options)); /// /// 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 opacity of the image to blend. Must be between 0 and 1. /// The location to draw the blended image. /// The . public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, float opacity, Point location) where TPixel : struct, IPixel => source.ApplyProcessor(new DrawImageProcessor(image, location, 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 location to draw the blended image. /// The . public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelBlenderMode blender, float opacity, Point location) where TPixel : struct, IPixel => source.ApplyProcessor(new DrawImageProcessor(image, location, opacity, blender)); /// /// 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 location to draw the blended image. /// The . public static IImageProcessingContext DrawImage(this IImageProcessingContext source, GraphicsOptions options, Image image, Point location) where TPixel : struct, IPixel => source.ApplyProcessor(new DrawImageProcessor(image, location, options)); } }