コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }