Skip to content

Commit effcf29

Browse files
committed
format
1 parent 33be868 commit effcf29

9 files changed

+82
-81
lines changed

src/ImageSharp/Formats/Ani/AniConstants.cs

+5-16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ namespace SixLabors.ImageSharp.Formats.Ani;
55

66
internal static class AniConstants
77
{
8+
/// <summary>
9+
/// Gets the header bytes identifying an ani.
10+
/// </summary>
11+
public const uint AniFourCc = 0x41_43_4F_4E;
12+
813
/// <summary>
914
/// The list of mime types that equate to an ani.
1015
/// </summary>
@@ -19,20 +24,4 @@ internal static class AniConstants
1924
/// Gets the header bytes identifying an ani.
2025
/// </summary>
2126
public static ReadOnlySpan<byte> AniFormTypeFourCc => "ACON"u8;
22-
23-
/// <summary>
24-
/// Gets the header bytes identifying an ani.
25-
/// </summary>
26-
public const uint AniFourCc = 0x41_43_4F_4E;
27-
28-
public static class ChunkFourCcs
29-
{
30-
public static ReadOnlySpan<byte> AniHeader => "anih"u8;
31-
32-
public static ReadOnlySpan<byte> Seq => "seq "u8;
33-
34-
public static ReadOnlySpan<byte> Rate => "rate"u8;
35-
36-
public static ReadOnlySpan<byte> Icon => "icon"u8;
37-
}
3827
}

src/ImageSharp/Formats/Ani/AniDecoderCore.cs

+7-8
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,11 @@
1515
using SixLabors.ImageSharp.Memory;
1616
using SixLabors.ImageSharp.Memory.Internals;
1717
using SixLabors.ImageSharp.Metadata;
18-
using SixLabors.ImageSharp.PixelFormats;
1918

2019
namespace SixLabors.ImageSharp.Formats.Ani;
2120

2221
internal class AniDecoderCore(DecoderOptions options) : ImageDecoderCore(options)
2322
{
24-
private enum ListIconChunkType : byte
25-
{
26-
Ico = 1,
27-
Cur = 2,
28-
Bmp = 3
29-
}
30-
3123
/// <summary>
3224
/// The general decoder options.
3325
/// </summary>
@@ -40,6 +32,13 @@ private enum ListIconChunkType : byte
4032

4133
private AniHeader header;
4234

35+
private enum ListIconChunkType : byte
36+
{
37+
Ico = 1,
38+
Cur,
39+
Bmp
40+
}
41+
4342
protected override Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken cancellationToken)
4443
{
4544
this.currentStream = stream;

src/ImageSharp/Formats/Ani/AniHeader.cs

-17
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,3 @@ internal readonly struct AniHeader
3030

3131
public void WriteTo(Stream stream) => stream.Write(MemoryMarshal.AsBytes(MemoryMarshal.CreateReadOnlySpan(in this, 1)));
3232
}
33-
34-
/// <summary>
35-
/// Flags for the ANI header.
36-
/// </summary>
37-
[Flags]
38-
public enum AniHeaderFlags : uint
39-
{
40-
/// <summary>
41-
/// If set, the ANI file's "icon" chunk contains an ICO or CUR file, otherwise it contains a BMP file.
42-
/// </summary>
43-
IsIcon = 1,
44-
45-
/// <summary>
46-
/// If set, the ANI file contains a "seq " chunk.
47-
/// </summary>
48-
ContainsSeq = 2
49-
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Six Labors Split License.
3+
4+
namespace SixLabors.ImageSharp.Formats.Ani;
5+
6+
/// <summary>
7+
/// Flags for the ANI header.
8+
/// </summary>
9+
[Flags]
10+
public enum AniHeaderFlags : uint
11+
{
12+
/// <summary>
13+
/// If set, the ANI file's "icon" chunk contains an ICO or CUR file, otherwise it contains a BMP file.
14+
/// </summary>
15+
IsIcon = 1,
16+
17+
/// <summary>
18+
/// If set, the ANI file contains a "seq " chunk.
19+
/// </summary>
20+
ContainsSeq = 2
21+
}

src/ImageSharp/Formats/Ani/AniMetadata.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ namespace SixLabors.ImageSharp.Formats.Ani;
1111
/// </summary>
1212
public class AniMetadata : IFormatMetadata<AniMetadata>
1313
{
14+
/// <summary>
15+
/// Initializes a new instance of the <see cref="AniMetadata"/> class.
16+
/// </summary>
17+
public AniMetadata()
18+
{
19+
}
20+
1421
/// <summary>
1522
/// Gets or sets the width of frames in the animation.
1623
/// </summary>
@@ -56,13 +63,6 @@ public class AniMetadata : IFormatMetadata<AniMetadata>
5663
/// </summary>
5764
public IList<ImageFrameMetadata> IconFrames { get; set; } = [];
5865

59-
/// <summary>
60-
/// Initializes a new instance of the <see cref="AniMetadata"/> class.
61-
/// </summary>
62-
public AniMetadata()
63-
{
64-
}
65-
6666
/// <inheritdoc/>
6767
public static AniMetadata FromFormatConnectingMetadata(FormatConnectingMetadata metadata) => throw new NotImplementedException();
6868

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Six Labors Split License.
3+
4+
using System.Runtime.CompilerServices;
5+
using System.Runtime.InteropServices;
6+
7+
namespace SixLabors.ImageSharp.Formats.Webp;
8+
9+
internal readonly struct RiffChunkHeader
10+
{
11+
public readonly uint FourCc;
12+
13+
public ReadOnlySpan<byte> FourCcBytes => MemoryMarshal.CreateReadOnlySpan(ref Unsafe.As<uint, byte>(ref Unsafe.AsRef(in this.FourCc)), sizeof(uint));
14+
15+
public readonly uint Size;
16+
}

src/ImageSharp/Formats/Webp/RiffHelper.cs

-28
Original file line numberDiff line numberDiff line change
@@ -93,31 +93,3 @@ public static void EndWriteVp8X(Stream stream, in WebpVp8X vp8X, bool updateVp8X
9393
}
9494
}
9595
}
96-
97-
internal readonly struct RiffChunkHeader
98-
{
99-
public readonly uint FourCc;
100-
101-
public ReadOnlySpan<byte> FourCcBytes => MemoryMarshal.CreateReadOnlySpan(ref Unsafe.As<uint, byte>(ref Unsafe.AsRef(in this.FourCc)), sizeof(uint));
102-
103-
public readonly uint Size;
104-
}
105-
106-
internal readonly struct RiffOrListChunkHeader
107-
{
108-
public const int HeaderSize = 12;
109-
110-
public readonly uint FourCc;
111-
112-
public readonly uint Size;
113-
114-
public readonly uint FormType;
115-
116-
public ReadOnlySpan<byte> FourCcBytes => MemoryMarshal.CreateReadOnlySpan(ref Unsafe.As<uint, byte>(ref Unsafe.AsRef(in this.FourCc)), sizeof(uint));
117-
118-
public bool IsRiff => this.FourCc is 0x52_49_46_46; // "RIFF"
119-
120-
public bool IsList => this.FourCc is 0x4C_49_53_54; // "LIST"
121-
122-
public static ref RiffOrListChunkHeader Parse(ReadOnlySpan<byte> data) => ref Unsafe.As<byte, RiffOrListChunkHeader>(ref MemoryMarshal.GetReference(data));
123-
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Six Labors Split License.
3+
4+
using System.Runtime.CompilerServices;
5+
using System.Runtime.InteropServices;
6+
7+
namespace SixLabors.ImageSharp.Formats.Webp;
8+
9+
internal readonly struct RiffOrListChunkHeader
10+
{
11+
public const int HeaderSize = 12;
12+
13+
public readonly uint FourCc;
14+
15+
public readonly uint Size;
16+
17+
public readonly uint FormType;
18+
19+
public ReadOnlySpan<byte> FourCcBytes => MemoryMarshal.CreateReadOnlySpan(ref Unsafe.As<uint, byte>(ref Unsafe.AsRef(in this.FourCc)), sizeof(uint));
20+
21+
public bool IsRiff => this.FourCc is 0x52_49_46_46; // "RIFF"
22+
23+
public bool IsList => this.FourCc is 0x4C_49_53_54; // "LIST"
24+
25+
public static ref RiffOrListChunkHeader Parse(ReadOnlySpan<byte> data) => ref Unsafe.As<byte, RiffOrListChunkHeader>(ref MemoryMarshal.GetReference(data));
26+
}

src/ImageSharp/IO/BufferedReadStream.cs

-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33

44
using System.Buffers;
55
using System.Runtime.CompilerServices;
6-
using SixLabors.ImageSharp.Formats.Ani;
7-
using static System.Runtime.InteropServices.JavaScript.JSType;
86
using System.Runtime.InteropServices;
9-
using System;
10-
using System.Diagnostics.CodeAnalysis;
11-
using SixLabors.ImageSharp.Memory;
127

138
namespace SixLabors.ImageSharp.IO;
149

0 commit comments

Comments
 (0)