namespace ImageSharp.Tests
{
using System;
using System.IO;
using ImageSharp;
using Processing;
using System.Collections.Generic;
using ImageSharp.Formats;
using ImageSharp.IO;
///
/// Watches but does not actually run the processors against the image.
///
///
public class SaveWatchingImage : Image, IImageCallbacks
{
public List Saves { get; } = new List();
public SaveWatchingImage(int width, int height, IFileSystem fs = null)
: base(width, height, Configuration.CreateDefaultInstance())
{
//switch out the file system for tests
this.Configuration.FileSystem = fs ?? this.Configuration.FileSystem;
this.Callbacks = this;
}
public bool OnSaving(ImageBase image, Stream stream, IImageEncoder encoder, IEncoderOptions options) where TColor : struct, IPixel
{
this.Saves.Add(new OperationDetails
{
encoder = encoder,
options = options,
stream = stream
});
return false;
}
public bool OnProcessing(ImageBase image, IImageProcessor processor, Rectangle rectangle) where TColor : struct, IPixel
{
return false;
}
public struct OperationDetails
{
public Stream stream;
public IImageEncoder encoder;
public IEncoderOptions options;
}
}
}