// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; namespace SixLabors.ImageSharp.Drawing.Processing { /// /// Executes the callback for a specific pixel type by creating a /// over each frame. /// /// The pixel format. internal sealed class PaintProcessor : ImageProcessor where TPixel : unmanaged, IPixel { private readonly PaintProcessor definition; private readonly CanvasAction action; /// /// Initializes a new instance of the class. /// /// The processing configuration. /// The non-generic processor definition that owns the drawing options and callback. /// The source image. /// The source bounds passed through the processing pipeline. public PaintProcessor( Configuration configuration, PaintProcessor definition, Image source, Rectangle sourceRectangle) : base(configuration, source, sourceRectangle) { this.definition = definition; this.action = definition.Action; } /// protected override void OnFrameApply(ImageFrame source) { using DrawingCanvas canvas = source.CreateCanvas(this.Configuration, this.definition.Options); this.action(canvas); } } }