Browse Source

define IImageVisitor

af/merge-core
Anton Firszov 7 years ago
parent
commit
2fa57ff510
  1. 2
      src/ImageSharp/IImage.cs
  2. 40
      src/ImageSharp/Image.cs
  3. 5
      src/ImageSharp/Image{TPixel}.cs
  4. 5
      src/ImageSharp/Processing/IImageProcessingContext{TPixel}.cs
  5. 5
      src/ImageSharp/Processing/ProcessingExtensions.cs
  6. 6
      src/ImageSharp/Processing/Processors/IImageProcessor.cs

2
src/ImageSharp/IImage.cs

@ -4,7 +4,7 @@
using System;
namespace SixLabors.ImageSharp
{
{
/// <summary>
/// Encapsulates the properties and methods that describe an image.
/// </summary>

40
src/ImageSharp/Image.cs

@ -0,0 +1,40 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Metadata;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp
{
internal interface IImageVisitor
{
void Visit<TPixel>(Image<TPixel> image)
where TPixel : struct, IPixel<TPixel>;
}
public abstract partial class Image : IImage
{
/// <inheritdoc/>
public PixelTypeInfo PixelType { get; }
/// <inheritdoc />
public abstract int Width { get; }
/// <inheritdoc />
public abstract int Height { get; }
/// <inheritdoc/>
public ImageMetadata Metadata { get; }
protected Image(PixelTypeInfo pixelType, ImageMetadata metadata)
{
this.PixelType = pixelType;
this.Metadata = metadata ?? new ImageMetadata();
}
public abstract void Dispose();
internal abstract void ApplyVisitor(IImageVisitor visitor);
}
}

5
src/ImageSharp/Image{TPixel}.cs

@ -220,6 +220,11 @@ namespace SixLabors.ImageSharp
/// <inheritdoc/>
public void Dispose() => this.Frames.Dispose();
internal override void ApplyVisitor(IImageVisitor visitor)
{
visitor.Visit(this);
}
/// <inheritdoc/>
public override string ToString() => $"Image<{typeof(TPixel).Name}>: {this.Width}x{this.Height}";

5
src/ImageSharp/Processing/IImageProcessingContext{TPixel}.cs

@ -8,6 +8,11 @@ using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing
{
public interface IImageProcessingContext
{
}
/// <summary>
/// An interface to queue up image operations to apply to an image.
/// </summary>

5
src/ImageSharp/Processing/ProcessingExtensions.cs

@ -13,6 +13,11 @@ namespace SixLabors.ImageSharp.Processing
/// </summary>
public static class ProcessingExtensions
{
public static void Mutate(this Image source, Action<IImageProcessingContext> operation)
{
}
/// <summary>
/// Applies the given operation to the mutable image.
/// Useful when we need to extract information like Width/Height to parametrize the next operation working on the <see cref="IImageProcessingContext{TPixel}"/> chain.

6
src/ImageSharp/Processing/Processors/IImageProcessor.cs

@ -6,6 +6,12 @@ using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors
{
public interface IImageProcessor
{
IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>()
where TPixel : struct, IPixel<TPixel>;
}
/// <summary>
/// Encapsulates methods to alter the pixels of an image.
/// </summary>

Loading…
Cancel
Save