From 44d1aae2b367150c5c895c4c9cec26f222ee4119 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Tue, 11 Apr 2017 10:42:14 +0100 Subject: [PATCH] return alpha array to array pool --- src/ImageSharp/Formats/Png/PngEncoderCore.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index e6ade1df03..469c459fb9 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -529,19 +529,20 @@ namespace ImageSharp.Formats } this.WriteChunk(stream, PngChunkTypes.Palette, colorTable, 0, colorTableLength); + + // Write the transparency data + if (anyAlpha) + { + this.WriteChunk(stream, PngChunkTypes.PaletteAlpha, alphaTable, 0, pixelCount); + } } finally { ArrayPool.Shared.Return(colorTable); + ArrayPool.Shared.Return(alphaTable); ArrayPool.Shared.Return(bytes); } - // Write the transparency data - if (anyAlpha) - { - this.WriteChunk(stream, PngChunkTypes.PaletteAlpha, alphaTable, 0, pixelCount); - } - return quantized; }