|
|
|
@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Processing |
|
|
|
public static class DitherExtensions |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Dithers the image reducing it to a web-safe palette using Bayer4x4 ordered dithering.
|
|
|
|
/// Dithers the image reducing it to a web-safe palette using <see cref="KnownDitherings.BayerDither4x4"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
|
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|
|
|
@ -26,9 +26,24 @@ namespace SixLabors.ImageSharp.Processing |
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
|
/// <param name="dither">The ordered ditherer.</param>
|
|
|
|
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|
|
|
public static IImageProcessingContext Dither(this IImageProcessingContext source, IDither dither) => |
|
|
|
public static IImageProcessingContext Dither( |
|
|
|
this IImageProcessingContext source, |
|
|
|
IDither dither) => |
|
|
|
source.ApplyProcessor(new PaletteDitherProcessor(dither)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Dithers the image reducing it to a web-safe palette using ordered dithering.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
|
/// <param name="dither">The ordered ditherer.</param>
|
|
|
|
/// <param name="ditherScale">The dithering scale used to adjust the amount of dither.</param>
|
|
|
|
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|
|
|
public static IImageProcessingContext Dither( |
|
|
|
this IImageProcessingContext source, |
|
|
|
IDither dither, |
|
|
|
float ditherScale) => |
|
|
|
source.ApplyProcessor(new PaletteDitherProcessor(dither, ditherScale)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Dithers the image reducing it to the given palette using ordered dithering.
|
|
|
|
/// </summary>
|
|
|
|
@ -42,6 +57,32 @@ namespace SixLabors.ImageSharp.Processing |
|
|
|
ReadOnlyMemory<Color> palette) => |
|
|
|
source.ApplyProcessor(new PaletteDitherProcessor(dither, palette)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Dithers the image reducing it to the given palette using ordered dithering.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
|
/// <param name="dither">The ordered ditherer.</param>
|
|
|
|
/// <param name="ditherScale">The dithering scale used to adjust the amount of dither.</param>
|
|
|
|
/// <param name="palette">The palette to select substitute colors from.</param>
|
|
|
|
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
|
|
|
|
public static IImageProcessingContext Dither( |
|
|
|
this IImageProcessingContext source, |
|
|
|
IDither dither, |
|
|
|
float ditherScale, |
|
|
|
ReadOnlyMemory<Color> palette) => |
|
|
|
source.ApplyProcessor(new PaletteDitherProcessor(dither, ditherScale, palette)); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Dithers the image reducing it to a web-safe palette using <see cref="KnownDitherings.BayerDither4x4"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">The image this method extends.</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 Dither(this IImageProcessingContext source, Rectangle rectangle) => |
|
|
|
Dither(source, KnownDitherings.BayerDither4x4, rectangle); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Dithers the image reducing it to a web-safe palette using ordered dithering.
|
|
|
|
/// </summary>
|
|
|
|
@ -57,6 +98,23 @@ namespace SixLabors.ImageSharp.Processing |
|
|
|
Rectangle rectangle) => |
|
|
|
source.ApplyProcessor(new PaletteDitherProcessor(dither), rectangle); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Dithers the image reducing it to a web-safe palette using ordered dithering.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
|
/// <param name="dither">The ordered ditherer.</param>
|
|
|
|
/// <param name="ditherScale">The dithering scale used to adjust the amount of dither.</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 Dither( |
|
|
|
this IImageProcessingContext source, |
|
|
|
IDither dither, |
|
|
|
float ditherScale, |
|
|
|
Rectangle rectangle) => |
|
|
|
source.ApplyProcessor(new PaletteDitherProcessor(dither, ditherScale), rectangle); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Dithers the image reducing it to the given palette using ordered dithering.
|
|
|
|
/// </summary>
|
|
|
|
@ -73,5 +131,24 @@ namespace SixLabors.ImageSharp.Processing |
|
|
|
ReadOnlyMemory<Color> palette, |
|
|
|
Rectangle rectangle) => |
|
|
|
source.ApplyProcessor(new PaletteDitherProcessor(dither, palette), rectangle); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Dithers the image reducing it to the given palette using ordered dithering.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="source">The image this method extends.</param>
|
|
|
|
/// <param name="dither">The ordered ditherer.</param>
|
|
|
|
/// <param name="ditherScale">The dithering scale used to adjust the amount of dither.</param>
|
|
|
|
/// <param name="palette">The palette to select substitute colors from.</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 Dither( |
|
|
|
this IImageProcessingContext source, |
|
|
|
IDither dither, |
|
|
|
float ditherScale, |
|
|
|
ReadOnlyMemory<Color> palette, |
|
|
|
Rectangle rectangle) => |
|
|
|
source.ApplyProcessor(new PaletteDitherProcessor(dither, ditherScale, palette), rectangle); |
|
|
|
} |
|
|
|
} |
|
|
|
|