Exemplo 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.Apply();
            }
Exemplo n.º 2
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="Image{TPixel}"/></returns>
        public static Image <TPixel> Clone <TPixel>(this Image <TPixel> source, params IImageProcessor <TPixel>[] operations)
            where TPixel : struct, IPixel <TPixel>
        {
            Guard.NotNull(operations, nameof(operations));
            Guard.NotNull(source, nameof(source));

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

            operationsRunner.ApplyProcessors(operations);
            return(operationsRunner.Apply());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Mutates the source image by applying the image operation to it.
        /// </summary>
        /// <typeparam name="TPixel">The pixel format.</typeparam>
        /// <param name="source">The image to mutate.</param>
        /// <param name="operation">The operation to perform on the source.</param>
        public static void Mutate <TPixel>(this Image <TPixel> source, Action <IImageProcessingContext <TPixel> > operation)
            where TPixel : struct, IPixel <TPixel>
        {
            Guard.NotNull(operation, nameof(operation));
            Guard.NotNull(source, nameof(source));

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

            operation(operationsRunner);
            operationsRunner.Apply();
        }