Browse Source

Don't adaptively encode indexed pngs

Former-commit-id: fbb4508b15ccb81f78bae6cb0e969e6ee7a34350
pull/1/head
James Jackson-South 10 years ago
parent
commit
e3765100d8
  1. 2100
      src/ImageProcessorCore/Formats/Jpg/JpegDecoderCore.cs
  2. 1
      src/ImageProcessorCore/Formats/Jpg/JpegDecoderCore.cs.REMOVED.git-id
  3. 28
      src/ImageProcessorCore/Formats/Png/PngEncoderCore.cs
  4. BIN
      tests/ImageProcessorCore.Tests/TestImages/Formats/Bmp/Car.bmp
  5. 1
      tests/ImageProcessorCore.Tests/TestImages/Formats/Bmp/Car.bmp.REMOVED.git-id
  6. BIN
      tests/ImageProcessorCore.Tests/TestImages/Formats/Bmp/neg_height.bmp
  7. 1
      tests/ImageProcessorCore.Tests/TestImages/Formats/Bmp/neg_height.bmp.REMOVED.git-id
  8. BIN
      tests/ImageProcessorCore.Tests/TestImages/Formats/Jpg/Calliphora.jpg
  9. 1
      tests/ImageProcessorCore.Tests/TestImages/Formats/Jpg/Calliphora.jpg.REMOVED.git-id
  10. BIN
      tests/ImageProcessorCore.Tests/TestImages/Formats/Jpg/Floorplan.jpeg
  11. 1
      tests/ImageProcessorCore.Tests/TestImages/Formats/Jpg/Floorplan.jpeg.REMOVED.git-id
  12. BIN
      tests/ImageProcessorCore.Tests/TestImages/Formats/Jpg/cmyk.jpg
  13. 1
      tests/ImageProcessorCore.Tests/TestImages/Formats/Jpg/cmyk.jpg.REMOVED.git-id
  14. BIN
      tests/ImageProcessorCore.Tests/TestImages/Formats/Jpg/gamma_dalai_lama_gray.jpg
  15. 1
      tests/ImageProcessorCore.Tests/TestImages/Formats/Jpg/gamma_dalai_lama_gray.jpg.REMOVED.git-id
  16. BIN
      tests/ImageProcessorCore.Tests/TestImages/Formats/Png/blur.png
  17. 1
      tests/ImageProcessorCore.Tests/TestImages/Formats/Png/blur.png.REMOVED.git-id
  18. BIN
      tests/ImageProcessorCore.Tests/TestImages/Formats/Png/splash.png
  19. 1
      tests/ImageProcessorCore.Tests/TestImages/Formats/Png/splash.png.REMOVED.git-id

2100
src/ImageProcessorCore/Formats/Jpg/JpegDecoderCore.cs

File diff suppressed because it is too large

1
src/ImageProcessorCore/Formats/Jpg/JpegDecoderCore.cs.REMOVED.git-id

@ -1 +0,0 @@
cee4b682b4cfc0f0cef3cafb5b089c780d1cb4d1

28
src/ImageProcessorCore/Formats/Png/PngEncoderCore.cs

@ -346,7 +346,7 @@ namespace ImageProcessorCore.Formats
List<byte> result = new List<byte>();
foreach (var encodedScanline in filteredScanlines)
foreach (byte[] encodedScanline in filteredScanlines)
{
result.AddRange(encodedScanline);
}
@ -366,17 +366,25 @@ namespace ImageProcessorCore.Formats
{
List<Tuple<byte[], int>> candidates = new List<Tuple<byte[], int>>();
byte[] sub = SubFilter.Encode(rawScanline, byteCount);
candidates.Add(new Tuple<byte[], int>(sub, this.CalculateTotalVariation(sub)));
if (this.PngColorType == PngColorType.Palette)
{
byte[] none = NoneFilter.Encode(rawScanline);
candidates.Add(new Tuple<byte[], int>(none, this.CalculateTotalVariation(none)));
}
else
{
byte[] sub = SubFilter.Encode(rawScanline, byteCount);
candidates.Add(new Tuple<byte[], int>(sub, this.CalculateTotalVariation(sub)));
byte[] up = UpFilter.Encode(rawScanline, previousScanline);
candidates.Add(new Tuple<byte[], int>(up, this.CalculateTotalVariation(up)));
byte[] up = UpFilter.Encode(rawScanline, previousScanline);
candidates.Add(new Tuple<byte[], int>(up, this.CalculateTotalVariation(up)));
byte[] average = AverageFilter.Encode(rawScanline, previousScanline, byteCount);
candidates.Add(new Tuple<byte[], int>(average, this.CalculateTotalVariation(average)));
byte[] average = AverageFilter.Encode(rawScanline, previousScanline, byteCount);
candidates.Add(new Tuple<byte[], int>(average, this.CalculateTotalVariation(average)));
byte[] paeth = PaethFilter.Encode(rawScanline, previousScanline, byteCount);
candidates.Add(new Tuple<byte[], int>(paeth, this.CalculateTotalVariation(paeth)));
byte[] paeth = PaethFilter.Encode(rawScanline, previousScanline, byteCount);
candidates.Add(new Tuple<byte[], int>(paeth, this.CalculateTotalVariation(paeth)));
}
int lowestTotalVariation = int.MaxValue;
int lowestTotalVariationIndex = 0;
@ -603,7 +611,7 @@ namespace ImageProcessorCore.Formats
/// <param name="stream">The stream.</param>
private void WriteDataChunks(Stream stream)
{
byte[] data = this.EncodePixelData();
byte[] data = this.EncodePixelData();
byte[] buffer;
int bufferLength;

BIN
tests/ImageProcessorCore.Tests/TestImages/Formats/Bmp/Car.bmp

Binary file not shown.

After

Width:  |  Height:  |  Size: 791 KiB

1
tests/ImageProcessorCore.Tests/TestImages/Formats/Bmp/Car.bmp.REMOVED.git-id

@ -1 +0,0 @@
edd8ac1feb2c4649e6f5aa80af8d4cf33642a546

BIN
tests/ImageProcessorCore.Tests/TestImages/Formats/Bmp/neg_height.bmp

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 MiB

1
tests/ImageProcessorCore.Tests/TestImages/Formats/Bmp/neg_height.bmp.REMOVED.git-id

@ -1 +0,0 @@
8f864b82464c595d7a81087d018db9994506e221

BIN
tests/ImageProcessorCore.Tests/TestImages/Formats/Jpg/Calliphora.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 KiB

1
tests/ImageProcessorCore.Tests/TestImages/Formats/Jpg/Calliphora.jpg.REMOVED.git-id

@ -1 +0,0 @@
5d446f64d0636f6ad7e9f82625eeff89ef394fe2

BIN
tests/ImageProcessorCore.Tests/TestImages/Formats/Jpg/Floorplan.jpeg

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

1
tests/ImageProcessorCore.Tests/TestImages/Formats/Jpg/Floorplan.jpeg.REMOVED.git-id

@ -1 +0,0 @@
5a1eaf806b7f3793d3db41c85bac6366584bce83

BIN
tests/ImageProcessorCore.Tests/TestImages/Formats/Jpg/cmyk.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 KiB

1
tests/ImageProcessorCore.Tests/TestImages/Formats/Jpg/cmyk.jpg.REMOVED.git-id

@ -1 +0,0 @@
30e88773ededd890ad97f0a5cfac372e1af07aa5

BIN
tests/ImageProcessorCore.Tests/TestImages/Formats/Jpg/gamma_dalai_lama_gray.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

1
tests/ImageProcessorCore.Tests/TestImages/Formats/Jpg/gamma_dalai_lama_gray.jpg.REMOVED.git-id

@ -1 +0,0 @@
56cbc3371def2882d1ead5d4d2456550f2b8d72c

BIN
tests/ImageProcessorCore.Tests/TestImages/Formats/Png/blur.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

1
tests/ImageProcessorCore.Tests/TestImages/Formats/Png/blur.png.REMOVED.git-id

@ -1 +0,0 @@
f3c65955eae84d00c5a0343c7e2aa3610a7d9df7

BIN
tests/ImageProcessorCore.Tests/TestImages/Formats/Png/splash.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 KiB

1
tests/ImageProcessorCore.Tests/TestImages/Formats/Png/splash.png.REMOVED.git-id

@ -1 +0,0 @@
0964ae9744027325bd6a2a19b2247c39f8349ca1
Loading…
Cancel
Save