/// <summary> /// Initializes a new instance of the <see cref="BinaryOrderedDitherProcessor{TPixel}"/> class. /// </summary> /// <param name="dither">The ordered ditherer.</param> public BinaryOrderedDitherProcessor(IOrderedDither dither) : this(dither, NamedColors <TPixel> .White, NamedColors <TPixel> .Black) { }
/// <summary> /// Initializes a new instance of the <see cref="OrderedDitherPaletteProcessor{TPixel}"/> class. /// </summary> /// <param name="dither">The ordered ditherer.</param> public OrderedDitherPaletteProcessor(IOrderedDither dither) : this(dither, NamedColors <TPixel> .WebSafePalette) { }
public void BinaryDitherFilter_WorksWithAllDitherers <TPixel>(TestImageProvider <TPixel> provider, string name, IOrderedDither ditherer) where TPixel : struct, IPixel <TPixel> { using (Image <TPixel> image = provider.GetImage()) { image.Mutate(x => x.BinaryDither(ditherer)); image.DebugSave(provider, name); } }
/// <summary> /// Initializes a new instance of the <see cref="BinaryOrderedDitherProcessor{TPixel}"/> class. /// </summary> /// <param name="dither">The ordered ditherer.</param> /// <param name="upperColor">The color to use for pixels that are above the threshold.</param> /// <param name="lowerColor">The color to use for pixels that are below the threshold.</param> public BinaryOrderedDitherProcessor(IOrderedDither dither, TPixel upperColor, TPixel lowerColor) { this.Dither = dither ?? throw new ArgumentNullException(nameof(dither)); this.UpperColor = upperColor; this.LowerColor = lowerColor; }
public BinaryDitherTest() { this.orderedDither = KnownDitherers.BayerDither4x4; this.errorDiffuser = KnownDiffusers.FloydSteinberg; }
public DitherTest() { this.orderedDither = new Mock <IOrderedDither>().Object; this.errorDiffuser = new Mock <IErrorDiffuser>().Object; }
/// <summary> /// Initializes a new instance of the <see cref="OrderedDitherPaletteProcessor"/> class. /// </summary> /// <param name="dither">The ordered ditherer.</param> /// <param name="palette">The palette to select substitute colors from.</param> public OrderedDitherPaletteProcessor(IOrderedDither dither, ReadOnlyMemory <Color> palette) : base(palette) => this.Dither = dither ?? throw new ArgumentNullException(nameof(dither));
/// <summary> /// Dithers the image reducing it to two colors using ordered dithering. /// </summary> /// <typeparam name="TPixel">The pixel format.</typeparam> /// <param name="source">The image this method extends.</param> /// <param name="dither">The ordered ditherer.</param> /// <param name="index">The component index to test the threshold against. Must range from 0 to 3.</param> /// <returns>The <see cref="Image{TPixel}"/>.</returns> public static IImageProcessingContext <TPixel> Dither <TPixel>(this IImageProcessingContext <TPixel> source, IOrderedDither dither, int index) where TPixel : struct, IPixel <TPixel> { source.ApplyProcessor(new OrderedDitherProcessor <TPixel>(dither, index)); return(source); }
/// <summary> /// Dithers the image reducing it to two colors using ordered dithering. /// </summary> /// <typeparam name="TPixel">The pixel format.</typeparam> /// <param name="source">The image this method extends.</param> /// <param name="dither">The ordered ditherer.</param> /// <param name="rectangle"> /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter. /// </param> /// <param name="index">The component index to test the threshold against. Must range from 0 to 3.</param> /// <returns>The <see cref="Image{TPixel}"/>.</returns> public static Image <TPixel> Dither <TPixel>(this Image <TPixel> source, IOrderedDither dither, Rectangle rectangle, int index = 0) where TPixel : struct, IPixel <TPixel> { source.ApplyProcessor(new OrderedDitherProcessor <TPixel>(dither, index), rectangle); return(source); }
/// <summary> /// Initializes a new instance of the <see cref="OrderedDitherPaletteProcessor"/> class. /// </summary> /// <param name="dither">The ordered ditherer.</param> public OrderedDitherPaletteProcessor(IOrderedDither dither) : this(dither, Color.WebSafePalette) { }
/// <summary> /// Dithers the image reducing it to two colors using ordered dithering. /// </summary> /// <typeparam name="TPixel">The pixel format.</typeparam> /// <param name="source">The image this method extends.</param> /// <param name="dither">The ordered ditherer.</param> /// <param name="index">The component index to test the threshold against. Must range from 0 to 3.</param> /// <returns>The <see cref="Image{TPixel}"/>.</returns> public static Image <TPixel> Dither <TPixel>(this Image <TPixel> source, IOrderedDither dither, int index = 0) where TPixel : struct, IPixel <TPixel> { return(Dither(source, dither, source.Bounds, index)); }
/// <summary> /// Dithers the image reducing it to two colors using ordered dithering. /// </summary> /// <typeparam name="TColor">The pixel format.</typeparam> /// <param name="source">The image this method extends.</param> /// <param name="dither">The ordered ditherer.</param> /// <param name="rectangle"> /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter. /// </param> /// <param name="index">The component index to test the threshold against. Must range from 0 to 3.</param> /// <returns>The <see cref="Image"/>.</returns> public static Image <TColor> Dither <TColor>(this Image <TColor> source, IOrderedDither dither, Rectangle rectangle, int index = 0) where TColor : struct, IPackedPixel, IEquatable <TColor> { source.ApplyProcessor(new OrderedDitherProcessor <TColor>(dither, index), rectangle); return(source); }
/// <summary> /// Dithers the image reducing it to two colors using ordered dithering. /// </summary> /// <typeparam name="TColor">The pixel format.</typeparam> /// <param name="source">The image this method extends.</param> /// <param name="dither">The ordered ditherer.</param> /// <param name="index">The component index to test the threshold against. Must range from 0 to 3.</param> /// <returns>The <see cref="Image{TColor}"/>.</returns> public static Image <TColor> Dither <TColor>(this Image <TColor> source, IOrderedDither dither, int index = 0) where TColor : struct, IPackedPixel, IEquatable <TColor> { return(Dither(source, dither, source.Bounds, index)); }
/// <summary> /// Initializes a new instance of the <see cref="OrderedDitherPaletteProcessor{TPixel}"/> class. /// </summary> /// <param name="dither">The ordered ditherer.</param> /// <param name="palette">The palette to select substitute colors from.</param> public OrderedDitherPaletteProcessor(IOrderedDither dither, TPixel[] palette) : base(palette) { Guard.NotNull(dither, nameof(dither)); this.Dither = dither; }
public BinaryDitherTest() { this.orderedDither = DitherMode.BayerDither4x4; this.errorDiffuser = DiffuseMode.FloydSteinberg; }
/// <summary> /// Dithers the image reducing it to a web-safe palette using ordered dithering. /// </summary> /// <typeparam name="TPixel">The pixel format.</typeparam> /// <param name="source">The image this method extends.</param> /// <param name="dither">The ordered ditherer.</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> Dither <TPixel>(this IImageProcessingContext <TPixel> source, IOrderedDither dither, Rectangle rectangle) where TPixel : struct, IPixel <TPixel> => source.ApplyProcessor(new OrderedDitherPaletteProcessor <TPixel>(dither), rectangle);
/// <summary> /// Initializes a new instance of the <see cref="OrderedDitherPaletteProcessor{TPixel}"/> class. /// </summary> /// <param name="dither">The ordered ditherer.</param> /// <param name="palette">The palette to select substitute colors from.</param> public OrderedDitherPaletteProcessor(IOrderedDither dither, TPixel[] palette) : base(palette) => this.Dither = dither ?? throw new ArgumentNullException(nameof(dither));