mirror of https://github.com/SixLabors/ImageSharp
4 changed files with 127 additions and 0 deletions
@ -0,0 +1,35 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Ani; |
|||
|
|||
internal sealed class AniDecoder : ImageDecoder |
|||
{ |
|||
private AniDecoder() |
|||
{ |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the shared instance.
|
|||
/// </summary>
|
|||
public static AniDecoder Instance { get; } = new(); |
|||
|
|||
protected override Image<TPixel> Decode<TPixel>(DecoderOptions options, Stream stream, CancellationToken cancellationToken) |
|||
{ |
|||
Guard.NotNull(options, nameof(options)); |
|||
Guard.NotNull(stream, nameof(stream)); |
|||
Image<TPixel> image = new AniDecoderCore(options).Decode<TPixel>(options.Configuration, stream, cancellationToken); |
|||
ScaleToTargetSize(options, image); |
|||
return image; |
|||
} |
|||
|
|||
protected override Image Decode(DecoderOptions options, Stream stream, CancellationToken cancellationToken) => this.Decode<Rgba32>(options, stream, cancellationToken); |
|||
|
|||
protected override ImageInfo Identify(DecoderOptions options, Stream stream, CancellationToken cancellationToken) |
|||
{ |
|||
Guard.NotNull(options, nameof(options)); |
|||
Guard.NotNull(stream, nameof(stream)); |
|||
return new AniDecoderCore(options).Identify(options.Configuration, stream, cancellationToken); |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.Formats.Icon; |
|||
using SixLabors.ImageSharp.IO; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Ani; |
|||
|
|||
internal class AniDecoderCore : ImageDecoderCore |
|||
{ |
|||
public AniDecoderCore(DecoderOptions options) |
|||
: base(options) |
|||
{ |
|||
} |
|||
|
|||
protected override Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken cancellationToken) |
|||
{ |
|||
this.ReadHeader(stream); |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
protected override ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
private void ReadHeader(Stream stream) |
|||
{ |
|||
// Skip the identifier
|
|||
stream.Skip(12); |
|||
Span<byte> buffer = stackalloc byte[AniHeader.Size]; |
|||
_ = stream.Read(buffer); |
|||
AniHeader header = AniHeader.Parse(buffer); |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Runtime.InteropServices; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Ani; |
|||
|
|||
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = Size)] |
|||
internal readonly struct AniHeader |
|||
{ |
|||
public const int Size = 36; |
|||
|
|||
public ushort Frames { get; } |
|||
|
|||
public ushort Steps { get; } |
|||
|
|||
public ushort Width { get; } |
|||
|
|||
public ushort Height { get; } |
|||
|
|||
public ushort BitCount { get; } |
|||
|
|||
public ushort Planes { get; } |
|||
|
|||
public ushort DisplayRate { get; } |
|||
|
|||
public ushort Flags { get; } |
|||
|
|||
public static AniHeader Parse(in ReadOnlySpan<byte> data) |
|||
=> MemoryMarshal.Cast<byte, AniHeader>(data)[0]; |
|||
|
|||
public readonly unsafe void WriteTo(in Stream stream) |
|||
=> stream.Write(MemoryMarshal.Cast<AniHeader, byte>([this])); |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using SixLabors.ImageSharp.PixelFormats; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Ani; |
|||
|
|||
internal class AniMetadata : IFormatMetadata<AniMetadata> |
|||
{ |
|||
|
|||
public static AniMetadata FromFormatConnectingMetadata(FormatConnectingMetadata metadata) => throw new NotImplementedException(); |
|||
|
|||
public void AfterImageApply<TPixel>(Image<TPixel> destination) |
|||
where TPixel : unmanaged, IPixel<TPixel> => throw new NotImplementedException(); |
|||
|
|||
public IDeepCloneable DeepClone() => throw new NotImplementedException(); |
|||
|
|||
public PixelTypeInfo GetPixelTypeInfo() => throw new NotImplementedException(); |
|||
|
|||
public FormatConnectingMetadata ToFormatConnectingMetadata() => throw new NotImplementedException(); |
|||
|
|||
AniMetadata IDeepCloneable<AniMetadata>.DeepClone() => throw new NotImplementedException(); |
|||
} |
|||
Loading…
Reference in new issue