Esempio n. 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);
        }
Esempio n. 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();

            ProcessingVisitor visitor = new ProcessingVisitor(operation, true);

            source.AcceptVisitor(visitor);
        }
Esempio n. 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);
        }
Esempio n. 4
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);
        }