Example #1
0
 /// <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)
 {
 }
Example #2
0
 /// <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)
 {
 }
Example #3
0
 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);
     }
 }
Example #4
0
 /// <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;
 }
Example #5
0
 public BinaryDitherTest()
 {
     this.orderedDither = KnownDitherers.BayerDither4x4;
     this.errorDiffuser = KnownDiffusers.FloydSteinberg;
 }
Example #6
0
 public DitherTest()
 {
     this.orderedDither = new Mock <IOrderedDither>().Object;
     this.errorDiffuser = new Mock <IErrorDiffuser>().Object;
 }
Example #7
0
 /// <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));
Example #8
0
 /// <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);
 }
Example #9
0
 /// <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);
 }
Example #10
0
 /// <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)
 {
 }
Example #11
0
 /// <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));
 }
Example #12
0
 /// <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);
 }
Example #13
0
 /// <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));
 }
Example #14
0
 /// <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;
 }
Example #15
0
 public BinaryDitherTest()
 {
     this.orderedDither = DitherMode.BayerDither4x4;
     this.errorDiffuser = DiffuseMode.FloydSteinberg;
 }
Example #16
0
 /// <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));