// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using System; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; namespace SixLabors.ImageSharp.Processing.Processors { /// /// Allows the application of processing algorithms to images via an action delegate /// /// The pixel format. internal class DelegateProcessor : ImageProcessor where TPixel : struct, IPixel { /// /// Initializes a new instance of the class. /// /// The action. public DelegateProcessor(Action> action) { this.Action = action; } /// /// Gets the action that will be applied to the image. /// internal Action> Action { get; } /// protected override void BeforeImageApply(Image source, Rectangle sourceRectangle) { this.Action?.Invoke(source); } /// protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration) { // NOP, we did all we wanted to do inside BeforeImageApply } } }