Browse Source

Reuse Crc

af/merge-core
James Jackson-South 9 years ago
parent
commit
17bd270bee
  1. 13
      src/ImageSharp/Formats/Png/PngEncoderCore.cs

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

@ -35,6 +35,11 @@ namespace ImageSharp.Formats
/// </summary>
private readonly byte[] chunkDataBuffer = new byte[16];
/// <summary>
/// Reusable crc for validating chunks.
/// </summary>
private readonly Crc32 crc = new Crc32();
/// <summary>
/// Contains the raw pixel data from an indexed image.
/// </summary>
@ -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);
}
}
}
Loading…
Cancel
Save