Browse Source

Can now add pixel accessors.

Former-commit-id: 2540005d263d7cd223413b314faafe322eee30a5
Former-commit-id: b772bbb168bc62a9cac94fedba81c658780a42b1
Former-commit-id: 4e610b0abbbc4742c813b240694ffeb6d689e167
af/merge-core
James Jackson-South 10 years ago
parent
commit
21e7318afd
  1. 28
      src/ImageProcessorCore/Bootstrapper.cs
  2. 1
      src/ImageProcessorCore/project.json

28
src/ImageProcessorCore/Bootstrapper.cs

@ -8,7 +8,7 @@ namespace ImageProcessorCore
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Reflection;
using System.Threading.Tasks;
using Formats;
@ -56,9 +56,16 @@ namespace ImageProcessorCore
public static Bootstrapper Instance = Lazy.Value;
/// <summary>
/// Gets the list of supported <see cref="IImageFormat"/>
/// Gets the collection of supported <see cref="IImageFormat"/>
/// </summary>
public IReadOnlyCollection<IImageFormat> ImageFormats =>
new ReadOnlyCollection<IImageFormat>(this.imageFormats);
/// <summary>
/// Gets the collection of supported pixel accessors
/// </summary>
public IReadOnlyCollection<IImageFormat> ImageFormats => new ReadOnlyCollection<IImageFormat>(this.imageFormats);
public IReadOnlyDictionary<Type, Func<IImageBase, IPixelAccessor>> PixelAccessors =>
new ReadOnlyDictionary<Type, Func<IImageBase, IPixelAccessor>>(this.pixelAccessors);
/// <summary>
/// Gets or sets the global parallel options for processing tasks in parallel.
@ -74,6 +81,21 @@ namespace ImageProcessorCore
this.imageFormats.Add(format);
}
/// <summary>
/// Adds a pixel accessor for the given pixel format.
/// </summary>
/// <param name="packedType">The packed format type, must implement <see cref="IPackedVector"/></param>
/// <param name="initializer">The function to return a new instance of the pixel accessor.</param>
public void AddPixelAccessor(Type packedType, Func<IImageBase, IPixelAccessor> initializer)
{
if (!typeof(IPackedVector).GetTypeInfo().IsAssignableFrom(packedType.GetTypeInfo()))
{
throw new ArgumentException($"Type {packedType} must implement {nameof(IPackedVector)}");
}
this.pixelAccessors.Add(packedType, initializer);
}
/// <summary>
/// Gets an instance of the correct <see cref="IPixelAccessor"/> for the packed vector.
/// </summary>

1
src/ImageProcessorCore/project.json

@ -24,6 +24,7 @@
"System.IO.Compression": "4.1.0",
"System.Linq": "4.1.0",
"System.Numerics.Vectors": "4.1.1",
"System.ObjectModel": "4.0.12",
"System.Resources.ResourceManager": "4.0.1",
"System.Runtime.Extensions": "4.1.0",
"System.Runtime.InteropServices": "4.1.0",

Loading…
Cancel
Save