Exemple #1
0
        /// <summary>
        /// Creates a deep clone of the current image. The clone is then mutated by the given operation.
        /// </summary>
        /// <param name="source">The image to clone.</param>
        /// <param name="operation">The operation to perform on the clone.</param>
        /// <returns>The new <see cref="SixLabors.ImageSharp.Image"/>.</returns>
        public static Image Clone(this Image source, Action <IImageProcessingContext> operation)
        {
            ProcessingVisitor visitor = new ProcessingVisitor(operation, false);

            source.AcceptVisitor(visitor);
            return(visitor.ResultImage);
        }
Exemple #2
0
        /// <summary>
        /// Mutates the source image by applying the image operation to it.
        /// </summary>
        /// <param name="source">The image to mutate.</param>
        /// <param name="operation">The operation to perform on the source.</param>
        public static void Mutate(this Image source, Action <IImageProcessingContext> operation)
        {
            Guard.NotNull(source, nameof(source));
            Guard.NotNull(operation, nameof(operation));
            source.EnsureNotDisposed();

            source.AcceptVisitor(new ProcessingVisitor(operation, true));
        }
Exemple #3
0
        /// <summary>
        /// Creates a deep clone of the current image. The clone is then mutated by the given operation.
        /// </summary>
        /// <param name="source">The image to clone.</param>
        /// <param name="operation">The operation to perform on the clone.</param>
        /// <returns>The new <see cref="SixLabors.ImageSharp.Image"/>.</returns>
        public static Image Clone(this Image source, Action <IImageProcessingContext> operation)
        {
            Guard.NotNull(source, nameof(source));
            Guard.NotNull(operation, nameof(operation));
            source.EnsureNotDisposed();

            ProcessingVisitor visitor = new ProcessingVisitor(operation, false);

            source.AcceptVisitor(visitor);
            return(visitor.ResultImage);
        }
        public static void Apply(this IImageProcessor processor, Image source, Rectangle sourceRectangle)
        {
            var visitor = new ApplyVisitor(processor, sourceRectangle);

            source.AcceptVisitor(visitor);
        }
 /// <summary>
 /// Executes the processor against the given source image and rectangle bounds.
 /// </summary>
 /// <param name="processor">The processor.</param>
 /// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param>
 /// <param name="source">The source image.</param>
 /// <param name="sourceRectangle">The source bounds.</param>
 public static void Execute(this IImageProcessor processor, Configuration configuration, Image source, Rectangle sourceRectangle)
 => source.AcceptVisitor(new ExecuteVisitor(configuration, processor, sourceRectangle));
Exemple #6
0
        /// <summary>
        /// Mutates the source image by applying the image operation to it.
        /// </summary>
        /// <param name="source">The image to mutate.</param>
        /// <param name="operation">The operation to perform on the source.</param>
        public static void Mutate(this Image source, Action <IImageProcessingContext> operation)
        {
            ProcessingVisitor visitor = new ProcessingVisitor(operation, true);

            source.AcceptVisitor(visitor);
        }