Browse Source

move methods

af/merge-core
Scott Williams 9 years ago
parent
commit
ed92a3b2ce
  1. 11
      src/ImageSharp/ApplyProcessors.cs
  2. 30
      src/ImageSharp/Processing/Delegate.cs
  3. 8
      src/ImageSharp/Processing/Processors/DelegateProcessor.cs
  4. 0
      src/ImageSharp/Processing/Processors/ImageProcessor.cs

11
src/ImageSharp/ApplyProcessors.cs

@ -85,16 +85,5 @@ namespace ImageSharp
operationsRunner.ApplyProcessors(operations);
return generated;
}
/// <summary>
/// Queues up a simple operation that provides access to the mutatable image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to rotate, flip, or both.</param>
/// <param name="operation">The operations to perform on the source.</param>
/// <returns>returns the current optinoatins class to allow chaining of oprations.</returns>
public static IImageOperations<TPixel> Run<TPixel>(this IImageOperations<TPixel> source, Action<Image<TPixel>> operation)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new DelegateImageProcessor<TPixel>(operation));
}
}

30
src/ImageSharp/Processing/Delegate.cs

@ -0,0 +1,30 @@
// <copyright file="RotateFlip.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using ImageSharp.PixelFormats;
using ImageSharp.Processing;
/// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary>
public static partial class ImageExtensions
{
/// <summary>
/// Queues up a simple operation that provides access to the mutatable image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to rotate, flip, or both.</param>
/// <param name="operation">The operations to perform on the source.</param>
/// <returns>returns the current optinoatins class to allow chaining of oprations.</returns>
public static IImageOperations<TPixel> Run<TPixel>(this IImageOperations<TPixel> source, Action<Image<TPixel>> operation)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new DelegateProcessor<TPixel>(operation));
}
}

8
src/ImageSharp/Processing/DelegateImageProcessor.cs → src/ImageSharp/Processing/Processors/DelegateProcessor.cs

@ -1,4 +1,4 @@
// <copyright file="DelegateImageProcessor.cs" company="James Jackson-South">
// <copyright file="DelegateProcessor.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
@ -15,16 +15,16 @@ namespace ImageSharp.Processing
/// Allows the application of processors to images.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
internal class DelegateImageProcessor<TPixel> : ImageProcessor<TPixel>
internal class DelegateProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel>
{
private readonly Action<Image<TPixel>> action;
/// <summary>
/// Initializes a new instance of the <see cref="DelegateImageProcessor{TPixel}"/> class.
/// Initializes a new instance of the <see cref="DelegateProcessor{TPixel}"/> class.
/// </summary>
/// <param name="action">The action.</param>
public DelegateImageProcessor(Action<Image<TPixel>> action)
public DelegateProcessor(Action<Image<TPixel>> action)
{
this.action = action;
}

0
src/ImageSharp/Processing/ImageProcessor.cs → src/ImageSharp/Processing/Processors/ImageProcessor.cs

Loading…
Cancel
Save