Browse Source

Cleanup

pull/528/head
Jason Nelson 8 years ago
parent
commit
e509638313
  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> /// </summary>
internal readonly struct PngChunk 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.Length = length;
this.Type = type; this.Type = type;
@ -28,7 +28,7 @@ namespace SixLabors.ImageSharp.Formats.Png
/// <summary> /// <summary>
/// Gets the chunk type. /// 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> /// </summary>
public PngChunkType Type { get; } public PngChunkType Type { get; }

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

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