diff --git a/src/ImageSharp/Formats/Png/Filters/SubFilter.cs b/src/ImageSharp/Formats/Png/Filters/SubFilter.cs index 79ebcf835..833790f0e 100644 --- a/src/ImageSharp/Formats/Png/Filters/SubFilter.cs +++ b/src/ImageSharp/Formats/Png/Filters/SubFilter.cs @@ -44,11 +44,9 @@ namespace ImageSharp.Formats /// The bytes per pixel. /// The number of bytes per scanline /// The - public static byte[] Encode(byte[] scanline, int bytesPerPixel, int bytesPerScanline) + public static byte[] Encode(byte[] scanline, byte[] result, int bytesPerPixel, int bytesPerScanline) { // Sub(x) = Raw(x) - Raw(x-bpp) - byte[] result = new byte[bytesPerScanline + 1]; - fixed (byte* scan = scanline) fixed (byte* res = result) { diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index 8e83d477e..098ad32bd 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -355,7 +355,7 @@ namespace ImageSharp.Formats Tuple[] candidates = new Tuple[4]; - byte[] sub = SubFilter.Encode(rawScanline, this.bytesPerPixel, bytesPerScanline); + byte[] sub = SubFilter.Encode(rawScanline, result, this.bytesPerPixel, bytesPerScanline); candidates[0] = new Tuple(sub, this.CalculateTotalVariation(sub)); byte[] up = UpFilter.Encode(rawScanline, previousScanline, result, bytesPerScanline);