Skip to content

Commit

Permalink
Add generic palette quantizer, refactor + werner palette
Browse files Browse the repository at this point in the history
  • Loading branch information
JimBobSquarePants committed Oct 19, 2018
1 parent 7e76506 commit 9370a6e
Show file tree
Hide file tree
Showing 18 changed files with 545 additions and 221 deletions.
5 changes: 2 additions & 3 deletions src/ImageSharp/Formats/Gif/GifEncoderCore.cs
Expand Up @@ -133,7 +133,7 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream)
private void EncodeGlobal<TPixel>(Image<TPixel> image, QuantizedFrame<TPixel> quantized, int transparencyIndex, Stream stream)
where TPixel : struct, IPixel<TPixel>
{
var palleteQuantizer = new PaletteQuantizer(this.quantizer.Diffuser);
var palleteQuantizer = new PaletteQuantizer<TPixel>(quantized.Palette, this.quantizer.Diffuser);

for (int i = 0; i < image.Frames.Count; i++)
{
Expand All @@ -149,8 +149,7 @@ private void EncodeGlobal<TPixel>(Image<TPixel> image, QuantizedFrame<TPixel> qu
}
else
{
using (QuantizedFrame<TPixel> paletteQuantized
= palleteQuantizer.CreateFrameQuantizer(() => quantized.Palette).QuantizeFrame(frame))
using (QuantizedFrame<TPixel> paletteQuantized = palleteQuantizer.CreateFrameQuantizer<TPixel>().QuantizeFrame(frame))
{
this.WriteImageData(paletteQuantized, stream);
}
Expand Down

0 comments on commit 9370a6e

Please sign in to comment.