Esempio n. 1
0
            public void Visit <TPixel>(Image <TPixel> image)
                where TPixel : struct, IPixel <TPixel>
            {
                IInternalImageProcessingContext <TPixel> operationsRunner = image.GetConfiguration()
                                                                            .ImageOperationsProvider.CreateImageProcessingContext(image, this.mutate);

                this.operation(operationsRunner);
                this.ResultImage = operationsRunner.GetResultImage();
            }
Esempio n. 2
0
            public void Visit <TPixel>(Image <TPixel> image)
                where TPixel : unmanaged, IPixel <TPixel>
            {
                IInternalImageProcessingContext <TPixel> operationsRunner =
                    this.configuration.ImageOperationsProvider.CreateImageProcessingContext(this.configuration, image, this.mutate);

                this.operation(operationsRunner);
                this.ResultImage = operationsRunner.GetResultImage();
            }
Esempio n. 3
0
        /// <summary>
        /// Creates a deep clone of the current image. The clone is then mutated by the given operation.
        /// </summary>
        /// <typeparam name="TPixel">The pixel format.</typeparam>
        /// <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{TPixel}"/></returns>
        public static Image <TPixel> Clone <TPixel>(this Image <TPixel> source, Action <IImageProcessingContext> operation)
            where TPixel : struct, IPixel <TPixel>
        {
            Guard.NotNull(operation, nameof(operation));
            Guard.NotNull(source, nameof(source));

            IInternalImageProcessingContext <TPixel> operationsRunner = source.GetConfiguration().ImageOperationsProvider
                                                                        .CreateImageProcessingContext(source, false);

            operation(operationsRunner);
            return(operationsRunner.GetResultImage());
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a deep clone of the current image. The clone is then mutated by the given operations.
        /// </summary>
        /// <typeparam name="TPixel">The pixel format.</typeparam>
        /// <param name="source">The image to clone.</param>
        /// <param name="operations">The operations to perform on the clone.</param>
        /// <returns>The new <see cref="SixLabors.ImageSharp.Image{TPixel}"/></returns>
        public static Image <TPixel> Clone <TPixel>(this Image <TPixel> source, params IImageProcessor[] operations)
            where TPixel : struct, IPixel <TPixel>
        {
            Guard.NotNull(source, nameof(source));
            Guard.NotNull(operations, nameof(operations));
            source.EnsureNotDisposed();

            IInternalImageProcessingContext <TPixel> operationsRunner = source.GetConfiguration().ImageOperationsProvider
                                                                        .CreateImageProcessingContext(source, false);

            operationsRunner.ApplyProcessors(operations);
            return(operationsRunner.GetResultImage());
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a deep clone of the current image. The clone is then mutated by the given operation.
        /// </summary>
        /// <typeparam name="TPixel">The pixel format.</typeparam>
        /// <param name="source">The image to clone.</param>
        /// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param>
        /// <param name="operation">The operation to perform on the clone.</param>
        /// <exception cref="ArgumentNullException">The configuration is null.</exception>
        /// <exception cref="ArgumentNullException">The source is null.</exception>
        /// <exception cref="ArgumentNullException">The operation is null.</exception>
        /// <exception cref="ObjectDisposedException">The source has been disposed.</exception>
        /// <exception cref="ImageProcessingException">The processing operation failed.</exception>
        /// <returns>The new <see cref="Image{TPixel}"/></returns>
        public static Image <TPixel> Clone <TPixel>(this Image <TPixel> source, Configuration configuration, Action <IImageProcessingContext> operation)
            where TPixel : unmanaged, IPixel <TPixel>
        {
            Guard.NotNull(configuration, nameof(configuration));
            Guard.NotNull(source, nameof(source));
            Guard.NotNull(operation, nameof(operation));
            source.EnsureNotDisposed();

            IInternalImageProcessingContext <TPixel> operationsRunner
                = configuration.ImageOperationsProvider.CreateImageProcessingContext(configuration, source, false);

            operation(operationsRunner);
            return(operationsRunner.GetResultImage());
        }