Browse Source

Cleanup

af/merge-core
Jason Nelson 8 years ago
parent
commit
30d9b32287
  1. 4
      src/ImageSharp/Formats/Png/PngChunk.cs
  2. 3
      src/ImageSharp/Formats/Png/PngChunkType.cs
  3. 4
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  4. 4
      tests/ImageSharp.Tests/Formats/Png/PngChunkTests.cs

4
src/ImageSharp/Formats/Png/PngChunk.cs

@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// </summary>
internal readonly struct PngChunk
{
public PngChunk(int length, PngChunkType type, IManagedByteBuffer data = null, uint crc = default)
public PngChunk(int length, PngChunkType type, IManagedByteBuffer data = null, uint crc = 0)
{
this.Length = length;
this.Type = type;
@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <summary>
/// Gets the chunk type.
/// The chunk type value the UInt32BigEndian encoding of its 4 ASCII characters.
/// The value is the equal to the UInt32BigEndian encoding of its 4 ASCII characters.
/// </summary>
public PngChunkType Type { get; }

3
src/ImageSharp/Formats/Png/PngChunkType.cs

@ -3,6 +3,9 @@
namespace SixLabors.ImageSharp.Formats.Png
{
/// <summary>
/// Contains a list of possible chunk types.
/// </summary>
internal enum PngChunkType : uint
{
Header = 1229472850U, // IHDR

4
src/ImageSharp/Formats/Png/PngDecoderCore.cs

@ -1241,9 +1241,9 @@ namespace SixLabors.ImageSharp.Formats.Png
if (this.crc.Value != chunk.Crc)
{
string chunkName = Encoding.UTF8.GetString(this.chunkTypeBuffer, 0, 4);
string chunkTypeName = Encoding.UTF8.GetString(this.chunkTypeBuffer, 0, 4);
throw new ImageFormatException($"CRC Error. PNG {chunkName} chunk is corrupt!");
throw new ImageFormatException($"CRC Error. PNG {chunkTypeName} chunk is corrupt!");
}
}

4
tests/ImageSharp.Tests/Formats/Png/PngChunkTests.cs

@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
private static PngChunkType GetType(string text)
{
return (PngChunkType)BinaryPrimitives.ReadInt32BigEndian(Encoding.UTF8.GetBytes(text).AsSpan());
return (PngChunkType)BinaryPrimitives.ReadInt32BigEndian(Encoding.UTF8.GetBytes(text));
}
}
}
}
Loading…
Cancel
Save