Browse Source

Fix issue in EncodeImage() not using correct histogram image size, fixes #2763

pull/2767/head
Brian Popow 2 years ago
parent
commit
00b253d1dd
  1. 6
      src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs

6
src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs

@ -698,6 +698,8 @@ internal class Vp8LEncoder : IDisposable
}
}
histogramImageSize = maxIndex;
this.bitWriter.PutBits((uint)(this.HistoBits - 2), 3);
this.EncodeImageNoHuffman(
histogramBgra,
@ -713,7 +715,7 @@ internal class Vp8LEncoder : IDisposable
// Store Huffman codes.
// Find maximum number of symbols for the huffman tree-set.
int maxTokens = 0;
for (int i = 0; i < 5 * histogramImage.Count; i++)
for (int i = 0; i < 5 * histogramImageSize; i++)
{
HuffmanTreeCode codes = huffmanCodes[i];
if (maxTokens < codes.NumSymbols)
@ -728,7 +730,7 @@ internal class Vp8LEncoder : IDisposable
tokens[i] = new HuffmanTreeToken();
}
for (int i = 0; i < 5 * histogramImage.Count; i++)
for (int i = 0; i < 5 * histogramImageSize; i++)
{
HuffmanTreeCode codes = huffmanCodes[i];
this.StoreHuffmanCode(huffTree, tokens, codes);

Loading…
Cancel
Save