Browse Source

quatizer base class

pull/299/head
Scott Williams 9 years ago
parent
commit
c0423fa8bf
  1. 3
      src/ImageSharp/Quantizers/OctreeQuantizer{TPixel}.cs
  2. 3
      src/ImageSharp/Quantizers/PaletteQuantizer{TPixel}.cs
  3. 8
      src/ImageSharp/Quantizers/QuantizerBase{TPixel}.cs
  4. 3
      src/ImageSharp/Quantizers/WuQuantizer{TPixel}.cs
  5. 6
      tests/ImageSharp.Benchmarks/Image/EncodePng.cs

3
src/ImageSharp/Quantizers/OctreeQuantizer{TPixel}.cs

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Quantizers.Base;
namespace SixLabors.ImageSharp.Quantizers
{
@ -13,7 +14,7 @@ namespace SixLabors.ImageSharp.Quantizers
/// <see href="http://msdn.microsoft.com/en-us/library/aa479306.aspx"/>
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
public sealed class OctreeQuantizer<TPixel> : Quantizer<TPixel>
public sealed class OctreeQuantizer<TPixel> : QuantizerBase<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>

3
src/ImageSharp/Quantizers/PaletteQuantizer{TPixel}.cs

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Quantizers.Base;
namespace SixLabors.ImageSharp.Quantizers
{
@ -13,7 +14,7 @@ namespace SixLabors.ImageSharp.Quantizers
/// <see href="http://msdn.microsoft.com/en-us/library/aa479306.aspx"/>
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
public sealed class PaletteQuantizer<TPixel> : Quantizer<TPixel>
public sealed class PaletteQuantizer<TPixel> : QuantizerBase<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>

8
src/ImageSharp/Quantizers/Quantizer{TPixel}.cs → src/ImageSharp/Quantizers/QuantizerBase{TPixel}.cs

@ -8,13 +8,13 @@ using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.Dithering;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Quantizers
namespace SixLabors.ImageSharp.Quantizers.Base
{
/// <summary>
/// Encapsulates methods to calculate the color palette of an image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
public abstract class Quantizer<TPixel> : IQuantizer<TPixel>
public abstract class QuantizerBase<TPixel> : IQuantizer<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Quantizers
private readonly bool singlePass;
/// <summary>
/// Initializes a new instance of the <see cref="Quantizer{TPixel}"/> class.
/// Initializes a new instance of the <see cref="QuantizerBase{TPixel}"/> class.
/// </summary>
/// <param name="singlePass">
/// If true, the quantization only needs to loop through the source pixels once
@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Quantizers
/// only call the 'QuantizeImage' function. If two passes are required, the code will call 'InitialQuantizeImage'
/// and then 'QuantizeImage'.
/// </remarks>
protected Quantizer(bool singlePass)
protected QuantizerBase(bool singlePass)
{
this.singlePass = singlePass;
}

3
src/ImageSharp/Quantizers/WuQuantizer{TPixel}.cs

@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Numerics;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Quantizers.Base;
namespace SixLabors.ImageSharp.Quantizers
{
@ -30,7 +31,7 @@ namespace SixLabors.ImageSharp.Quantizers
/// </para>
/// </remarks>
/// <typeparam name="TPixel">The pixel format.</typeparam>
public class WuQuantizer<TPixel> : Quantizer<TPixel>
public class WuQuantizer<TPixel> : QuantizerBase<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>

6
tests/ImageSharp.Benchmarks/Image/EncodePng.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Benchmarks.Image
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Quantizers;
using SixLabors.ImageSharp.Quantizers.Base;
using CoreImage = ImageSharp.Image;
public class EncodePng : BenchmarkBase
@ -66,8 +66,8 @@ namespace SixLabors.ImageSharp.Benchmarks.Image
{
using (MemoryStream memoryStream = new MemoryStream())
{
Quantizer<Rgba32> quantizer = this.UseOctreeQuantizer
? (Quantizer<Rgba32>)
QuantizerBase<Rgba32> quantizer = this.UseOctreeQuantizer
? (QuantizerBase<Rgba32>)
new OctreeQuantizer<Rgba32>()
: new PaletteQuantizer<Rgba32>();

Loading…
Cancel
Save