diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs
index ab6d09348..2980782a6 100644
--- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs
+++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs
@@ -35,6 +35,11 @@ namespace ImageSharp.Formats
///
private readonly byte[] chunkDataBuffer = new byte[16];
+ ///
+ /// Reusable crc for validating chunks.
+ ///
+ private readonly Crc32 crc = new Crc32();
+
///
/// Contains the raw pixel data from an indexed image.
///
@@ -717,15 +722,15 @@ namespace ImageSharp.Formats
stream.Write(data, offset, length);
}
- Crc32 crc32 = new Crc32();
- crc32.Update(this.chunkTypeBuffer);
+ this.crc.Reset();
+ this.crc.Update(this.chunkTypeBuffer);
if (data != null && length > 0)
{
- crc32.Update(data, offset, length);
+ this.crc.Update(data, offset, length);
}
- WriteInteger(stream, (uint)crc32.Value);
+ WriteInteger(stream, (uint)this.crc.Value);
}
}
}
\ No newline at end of file