3.2 DitheringRegistry

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-07 14:34:36 +02:00
parent 0e757e4193
commit 54755c3808
2 changed files with 22 additions and 1 deletions

View File

@@ -100,7 +100,7 @@ Each type lives in `src/FrameProcessor/Domain/`. Tests in `tests/FrameProcessor.
- `static ReadOnlyMemory<Color> BuildDisplay(IReadOnlyList<PaletteEntry>)` and `BuildDevice(...)`. - `static ReadOnlyMemory<Color> BuildDisplay(IReadOnlyList<PaletteEntry>)` and `BuildDevice(...)`.
- **Tests:** `PaletteFactoryTests` — count, ordering preserved. - **Tests:** `PaletteFactoryTests` — count, ordering preserved.
### [ ] 3.2 `DitheringRegistry` ### [x] 3.2 `DitheringRegistry`
- `IReadOnlyDictionary<DitherAlgorithm, IDither>` mapping each enum to the corresponding ImageSharp `KnownDitherings.*`. - `IReadOnlyDictionary<DitherAlgorithm, IDither>` mapping each enum to the corresponding ImageSharp `KnownDitherings.*`.
### [ ] 3.3 `IImagePipeline` + `ImagePipeline` ### [ ] 3.3 `IImagePipeline` + `ImagePipeline`

View File

@@ -0,0 +1,21 @@
using FrameProcessor.Domain;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors.Dithering;
namespace FrameProcessor.ImagePipeline;
/// <summary>
/// Maps each <see cref="DitherAlgorithm"/> to the corresponding ImageSharp <see cref="IDither"/>
/// instance from <see cref="KnownDitherings"/>.
/// </summary>
public static class DitheringRegistry
{
public static IReadOnlyDictionary<DitherAlgorithm, IDither> All { get; } =
new Dictionary<DitherAlgorithm, IDither>
{
[DitherAlgorithm.FloydSteinberg] = KnownDitherings.FloydSteinberg,
[DitherAlgorithm.Atkinson] = KnownDitherings.Atkinson,
[DitherAlgorithm.Stucki] = KnownDitherings.Stucki,
[DitherAlgorithm.Jarvis] = KnownDitherings.JarvisJudiceNinke,
};
}