Browse Source

Swap buffers. Fix #1211

pull/1212/head
James Jackson-South 6 years ago
parent
commit
8580772161
  1. 4
      src/ImageSharp/Formats/Png/PngEncoderCore.cs
  2. 47
      tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs

4
src/ImageSharp/Formats/Png/PngEncoderCore.cs

@ -1081,6 +1081,10 @@ namespace SixLabors.ImageSharp.Formats.Png
// encode data // encode data
IManagedByteBuffer r = this.EncodeAdam7IndexedPixelRow(destSpan); IManagedByteBuffer r = this.EncodeAdam7IndexedPixelRow(destSpan);
deflateStream.Write(r.Array, 0, resultLength); deflateStream.Write(r.Array, 0, resultLength);
IManagedByteBuffer temp = this.currentScanline;
this.currentScanline = this.previousScanline;
this.previousScanline = temp;
} }
} }
} }

47
tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs

@ -199,17 +199,20 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
return; return;
} }
foreach (PngInterlaceMode interlaceMode in InterlaceMode) foreach (var filterMethod in PngFilterMethods)
{ {
TestPngEncoderCore( foreach (PngInterlaceMode interlaceMode in InterlaceMode)
provider, {
pngColorType, TestPngEncoderCore(
PngFilterMethod.Adaptive, provider,
pngBitDepth, pngColorType,
interlaceMode, (PngFilterMethod)filterMethod[0],
appendPngColorType: true, pngBitDepth,
appendPixelType: true, interlaceMode,
appendPngBitDepth: true); appendPngColorType: true,
appendPixelType: true,
appendPngBitDepth: true);
}
} }
} }
@ -232,18 +235,22 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
public void WorksWithAllBitDepthsAndExcludeAllFilter<TPixel>(TestImageProvider<TPixel> provider, PngColorType pngColorType, PngBitDepth pngBitDepth) public void WorksWithAllBitDepthsAndExcludeAllFilter<TPixel>(TestImageProvider<TPixel> provider, PngColorType pngColorType, PngBitDepth pngBitDepth)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
foreach (PngInterlaceMode interlaceMode in InterlaceMode) foreach (var filterMethod in PngFilterMethods)
{ {
TestPngEncoderCore(
provider,
pngColorType, pngColorType,
PngFilterMethod.Adaptive, foreach (PngInterlaceMode interlaceMode in InterlaceMode)
pngBitDepth, {
interlaceMode, TestPngEncoderCore(
appendPngColorType: true, provider,
appendPixelType: true, pngColorType,
appendPngBitDepth: true, (PngFilterMethod)filterMethod[0],
optimizeMethod: PngChunkFilter.ExcludeAll); pngBitDepth,
interlaceMode,
appendPngColorType: true,
appendPixelType: true,
appendPngBitDepth: true,
optimizeMethod: PngChunkFilter.ExcludeAll);
}
} }
} }

Loading…
Cancel
Save