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(); }
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(); }
/// <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()); }
/// <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(); }
/// <summary> /// Mutates the source image by applying the operations to it. /// </summary> /// <typeparam name="TPixel">The pixel format.</typeparam> /// <param name="source">The image to mutate.</param> /// <param name="operations">The operations to perform on the source.</param> public static void Mutate <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, true); operationsRunner.ApplyProcessors(operations); }
/// <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()); }
/// <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="configuration">The configuration which allows altering default behaviour or extending the library.</param> /// <param name="operation">The operation to perform on the source.</param> public static void Mutate <TPixel>(this Image <TPixel> source, Configuration configuration, Action <IImageProcessingContext> operation) where TPixel : struct, 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, true); operation(operationsRunner); }
/// <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="configuration">The configuration which allows altering default behaviour or extending the library.</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, Configuration configuration, params IImageProcessor[] operations) where TPixel : struct, IPixel <TPixel> { Guard.NotNull(configuration, nameof(configuration)); Guard.NotNull(source, nameof(source)); Guard.NotNull(operations, nameof(operations)); source.EnsureNotDisposed(); IInternalImageProcessingContext <TPixel> operationsRunner = configuration.ImageOperationsProvider.CreateImageProcessingContext(configuration, source, false); operationsRunner.ApplyProcessors(operations); return(operationsRunner.GetResultImage()); }
/// <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()); }