mirror of https://github.com/SixLabors/ImageSharp
4 changed files with 75 additions and 5 deletions
@ -0,0 +1,33 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.Processing.Processors.Quantization; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats; |
|||
|
|||
/// <summary>
|
|||
/// Defines the contract for basic encoder options.
|
|||
/// </summary>
|
|||
public interface IEncoderOptions |
|||
{ |
|||
/// <summary>
|
|||
/// Gets or sets a value indicating whether to ignore decoded metadata when encoding.
|
|||
/// </summary>
|
|||
bool SkipMetadata { get; set; } |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Defines the contract for encoder options that allow color palette generation via quantization.
|
|||
/// </summary>
|
|||
public interface IQuantizingEncoderOptions : IEncoderOptions |
|||
{ |
|||
/// <summary>
|
|||
/// Gets or sets the quantizer used to generate the color palette.
|
|||
/// </summary>
|
|||
IQuantizer Quantizer { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the <see cref="IPixelSamplingStrategy"/> used for quantization when building a global color palette.
|
|||
/// </summary>
|
|||
IPixelSamplingStrategy GlobalPixelSamplingStrategy { get; set; } |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
using SixLabors.ImageSharp.Processing; |
|||
using SixLabors.ImageSharp.Processing.Processors.Quantization; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats; |
|||
|
|||
/// <summary>
|
|||
/// The base class for all image encoders.
|
|||
/// </summary>
|
|||
public abstract class ImageEncoder : IImageEncoder, IEncoderOptions |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public bool SkipMetadata { get; set; } |
|||
|
|||
/// <inheritdoc/>
|
|||
public abstract void Encode<TPixel>(Image<TPixel> image, Stream stream) |
|||
where TPixel : unmanaged, IPixel<TPixel>; |
|||
|
|||
/// <inheritdoc/>
|
|||
public abstract Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream, CancellationToken cancellationToken) |
|||
where TPixel : unmanaged, IPixel<TPixel>; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// The base class for all image encoders that allow color palette generation via quantization.
|
|||
/// </summary>
|
|||
public abstract class QuantizingImageEncoder : ImageEncoder, IQuantizingEncoderOptions |
|||
{ |
|||
/// <inheritdoc/>
|
|||
public IQuantizer Quantizer { get; set; } = KnownQuantizers.Octree; |
|||
|
|||
/// <inheritdoc/>
|
|||
public IPixelSamplingStrategy GlobalPixelSamplingStrategy { get; set; } = new DefaultPixelSamplingStrategy(); |
|||
} |
|||
Loading…
Reference in new issue