From 64024893a1cec4a0855cd96bd8f474d933dc3448 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 11 Nov 2016 02:09:53 +1100 Subject: [PATCH] Temp patch fix for png encoding I HAVE NO IDEA WHAT IS WRONG! --- src/ImageSharp/Formats/Png/PngEncoderCore.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index e88c09393..764d2f538 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -593,6 +593,11 @@ namespace ImageSharp.Formats int resultLength = bytesPerScanline + 1; byte[] result = ArrayPool.Shared.Rent(resultLength); + // TODO: Clearing this array makes the visual tests work again when encoding multiple images in a row. + // The png analyser tool I use still cannot decompress the image though my own decoder, chome and edge browsers, and paint can. Twitter also cannot read the file. + // It's 2am now so I'm going to check in what I have and cry. :'( + Array.Clear(result, 0, resultLength); + byte[] buffer; int bufferLength; MemoryStream memoryStream = null; @@ -613,16 +618,16 @@ namespace ImageSharp.Formats } deflateStream.Flush(); - bufferLength = (int)memoryStream.Length; buffer = memoryStream.ToArray(); + bufferLength = buffer.Length; } } finally { + memoryStream?.Dispose(); ArrayPool.Shared.Return(previousScanline); ArrayPool.Shared.Return(rawScanline); ArrayPool.Shared.Return(result); - memoryStream?.Dispose(); } // Store the chunks in repeated 64k blocks.