private static IImageProcessor <TPixel> GetProcessor <TPixel>(ColorBlindnessMode colorBlindness)
            where TPixel : struct, IPixel <TPixel>
        {
            switch (colorBlindness)
            {
            case ColorBlindnessMode.Achromatomaly:
                return(new AchromatomalyProcessor <TPixel>());

            case ColorBlindnessMode.Achromatopsia:
                return(new AchromatopsiaProcessor <TPixel>());

            case ColorBlindnessMode.Deuteranomaly:
                return(new DeuteranomalyProcessor <TPixel>());

            case ColorBlindnessMode.Deuteranopia:
                return(new DeuteranopiaProcessor <TPixel>());

            case ColorBlindnessMode.Protanomaly:
                return(new ProtanomalyProcessor <TPixel>());

            case ColorBlindnessMode.Protanopia:
                return(new ProtanopiaProcessor <TPixel>());

            case ColorBlindnessMode.Tritanomaly:
                return(new TritanomalyProcessor <TPixel>());

            default:
                return(new TritanopiaProcessor <TPixel>());
            }
        }
        private static IImageProcessor GetProcessor(ColorBlindnessMode colorBlindness)
        {
            switch (colorBlindness)
            {
            case ColorBlindnessMode.Achromatomaly:
                return(new AchromatomalyProcessor());

            case ColorBlindnessMode.Achromatopsia:
                return(new AchromatopsiaProcessor());

            case ColorBlindnessMode.Deuteranomaly:
                return(new DeuteranomalyProcessor());

            case ColorBlindnessMode.Deuteranopia:
                return(new DeuteranopiaProcessor());

            case ColorBlindnessMode.Protanomaly:
                return(new ProtanomalyProcessor());

            case ColorBlindnessMode.Protanopia:
                return(new ProtanopiaProcessor());

            case ColorBlindnessMode.Tritanomaly:
                return(new TritanomalyProcessor());

            default:
                return(new TritanopiaProcessor());
            }
        }
Ejemplo n.º 3
0
 public void ColorBlindness_rect_CorrectProcessor <T>(TestType <T> testType, ColorBlindnessMode colorBlindness)
     where T : IImageProcessor <Rgba32>
 {
     this.operations.ColorBlindness(colorBlindness, this.rect);
     var p = this.Verify <T>(this.rect);
 }
Ejemplo n.º 4
0
 public void ColorBlindness_CorrectProcessor <T>(TestType <T> testType, ColorBlindnessMode colorBlindness)
     where T : IImageProcessor
 {
     this.operations.ColorBlindness(colorBlindness);
     this.Verify <T>();
 }
Ejemplo n.º 5
0
 public void ApplyColorBlindnessFilter <TPixel>(TestImageProvider <TPixel> provider, ColorBlindnessMode colorBlindness)
     where TPixel : struct, IPixel <TPixel>
 {
     provider.RunValidatingProcessorTest(x => x.ColorBlindness(colorBlindness), colorBlindness.ToString());
 }
Ejemplo n.º 6
0
 public void ApplyColorBlindnessFilter <TPixel>(TestImageProvider <TPixel> provider, ColorBlindnessMode colorBlindness)
     where TPixel : unmanaged, IPixel <TPixel> => provider.RunValidatingProcessorTest(x => x.ColorBlindness(colorBlindness), colorBlindness.ToString(), this.imageComparer);
 /// <summary>
 /// Applies the given colorblindness simulator to the image.
 /// </summary>
 /// <typeparam name="TPixel">The pixel format.</typeparam>
 /// <param name="source">The image this method extends.</param>
 /// <param name="colorBlindnessMode">The type of color blindness simulator to apply.</param>
 /// <param name="rectangle">
 /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
 /// </param>
 /// <returns>The <see cref="Image{TPixel}"/>.</returns>
 public static IImageProcessingContext <TPixel> ColorBlindness <TPixel>(this IImageProcessingContext <TPixel> source, ColorBlindnessMode colorBlindnessMode, Rectangle rectangle)
     where TPixel : struct, IPixel <TPixel>
 => source.ApplyProcessor(GetProcessor <TPixel>(colorBlindnessMode), rectangle);
 /// <summary>
 /// Applies the given colorblindness simulator to the image.
 /// </summary>
 /// <param name="source">The image this method extends.</param>
 /// <param name="colorBlindnessMode">The type of color blindness simulator to apply.</param>
 /// <param name="rectangle">
 /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
 /// </param>
 /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
 public static IImageProcessingContext ColorBlindness(this IImageProcessingContext source, ColorBlindnessMode colorBlindnessMode, Rectangle rectangle)
 => source.ApplyProcessor(GetProcessor(colorBlindnessMode), rectangle);
 /// <summary>
 /// Applies the given colorblindness simulator to the image.
 /// </summary>
 /// <param name="source">The image this method extends.</param>
 /// <param name="colorBlindness">The type of color blindness simulator to apply.</param>
 /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
 public static IImageProcessingContext ColorBlindness(this IImageProcessingContext source, ColorBlindnessMode colorBlindness)
 => source.ApplyProcessor(GetProcessor(colorBlindness));