mirror of https://github.com/SixLabors/ImageSharp
Browse Source
Not going well 😦
Former-commit-id: 0fc05546fcc3a29e61620da83b7421ee4601f18e
Former-commit-id: 13403576c1acfa541456e97568852d845e9a8a42
Former-commit-id: f81fa27c751ee3171e9e9f330133d2bfa671d081
pull/17/head
13 changed files with 169 additions and 16 deletions
@ -0,0 +1,27 @@ |
|||
// --------------------------------------------------------------------------------------------------------------------
|
|||
// <copyright file="IQuantizer.cs" company="James South">
|
|||
// Copyright © James South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
// <summary>
|
|||
// Provides methods for allowing quantization of images pixels.
|
|||
// </summary>
|
|||
// --------------------------------------------------------------------------------------------------------------------
|
|||
|
|||
namespace ImageProcessor.Formats |
|||
{ |
|||
/// <summary>
|
|||
/// Provides methods for allowing quantization of images pixels.
|
|||
/// </summary>
|
|||
public interface IQuantizer |
|||
{ |
|||
/// <summary>
|
|||
/// Quantize an image and return the resulting output pixels.
|
|||
/// </summary>
|
|||
/// <param name="image">The image to quantize.</param>
|
|||
/// <returns>
|
|||
/// A <see cref="T:byte[]"/> representing a quantized version of the image pixels.
|
|||
/// </returns>
|
|||
byte[] Quantize(ImageBase image); |
|||
} |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
// --------------------------------------------------------------------------------------------------------------------
|
|||
// <copyright file="OctreeQuantizer.cs" company="James South">
|
|||
// Copyright © James South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
// <summary>
|
|||
// Encapsulates methods to calculate the color palette of an image using an Octree pattern.
|
|||
// <see href="http://msdn.microsoft.com/en-us/library/aa479306.aspx" />
|
|||
// </summary>
|
|||
// --------------------------------------------------------------------------------------------------------------------
|
|||
|
|||
namespace ImageProcessor.Formats |
|||
{ |
|||
/// <summary>
|
|||
/// Encapsulates methods to calculate the color palette of an image using an Octree pattern.
|
|||
/// <see href="http://msdn.microsoft.com/en-us/library/aa479306.aspx"/>
|
|||
/// </summary>
|
|||
public class OctreeQuantizer : Quantizer |
|||
{ |
|||
/// <summary>
|
|||
/// Maximum allowed color depth
|
|||
/// </summary>
|
|||
private readonly int maxColors; |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="OctreeQuantizer"/> class.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// The Octree quantizer is a two pass algorithm. The initial pass sets up the Octree,
|
|||
/// the second pass quantizes a color based on the nodes in the tree.
|
|||
/// <para>
|
|||
/// Defaults to return a maximum of 255 colors plus transparency with 8 significant bits.
|
|||
/// </para>
|
|||
/// </remarks>
|
|||
public OctreeQuantizer() |
|||
: this(255, 8) |
|||
{ |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="OctreeQuantizer"/> class.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// The Octree quantizer is a two pass algorithm. The initial pass sets up the Octree,
|
|||
/// the second pass quantizes a color based on the nodes in the tree
|
|||
/// </remarks>
|
|||
/// <param name="maxColors">The maximum number of colors to return</param>
|
|||
/// <param name="maxColorBits">The number of significant bits</param>
|
|||
public OctreeQuantizer(int maxColors, int maxColorBits) |
|||
: base(false) |
|||
{ |
|||
Guard.LessEquals(maxColors, 255, "maxColors"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
// --------------------------------------------------------------------------------------------------------------------
|
|||
// <copyright file="Quantizer.cs" company="James South">
|
|||
// Copyright © James South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
// <summary>
|
|||
// Encapsulates methods to calculate the color palette of an image.
|
|||
// </summary>
|
|||
// --------------------------------------------------------------------------------------------------------------------
|
|||
|
|||
namespace ImageProcessor.Formats |
|||
{ |
|||
/// <summary>
|
|||
/// Encapsulates methods to calculate the color palette of an image.
|
|||
/// </summary>
|
|||
public abstract class Quantizer : IQuantizer |
|||
{ |
|||
/// <summary>
|
|||
/// Flag used to indicate whether a single pass or two passes are needed for quantization.
|
|||
/// </summary>
|
|||
private readonly bool singlePass; |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="Quantizer"/> class.
|
|||
/// </summary>
|
|||
/// <param name="singlePass">
|
|||
/// If true, the quantization only needs to loop through the source pixels once
|
|||
/// </param>
|
|||
/// <remarks>
|
|||
/// If you construct this class with a true value for singlePass, then the code will, when quantizing your image,
|
|||
/// only call the 'QuantizeImage' function. If two passes are required, the code will call 'InitialQuantizeImage'
|
|||
/// and then 'QuantizeImage'.
|
|||
/// </remarks>
|
|||
protected Quantizer(bool singlePass) |
|||
{ |
|||
this.singlePass = singlePass; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Quantize an image and return the resulting output pixels.
|
|||
/// </summary>
|
|||
/// <param name="image">The image to quantize.</param>
|
|||
/// <returns>
|
|||
/// A <see cref="T:byte[]"/> representing a quantized version of the image pixels.
|
|||
/// </returns>
|
|||
public byte[] Quantize(ImageBase image) |
|||
{ |
|||
throw new System.NotImplementedException(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue