mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 00:00:57 +08:00
29 lines
1014 B
C#
29 lines
1014 B
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
|
|
namespace WpfAnimatedGif.Decoding
|
|
{
|
|
internal abstract class GifBlock
|
|
{
|
|
internal static GifBlock ReadBlock(Stream stream, IEnumerable<GifExtension> controlExtensions, bool metadataOnly)
|
|
{
|
|
int blockId = stream.ReadByte();
|
|
if (blockId < 0)
|
|
throw GifHelpers.UnexpectedEndOfStreamException();
|
|
switch (blockId)
|
|
{
|
|
case GifExtension.ExtensionIntroducer:
|
|
return GifExtension.ReadExtension(stream, controlExtensions, metadataOnly);
|
|
case GifFrame.ImageSeparator:
|
|
return GifFrame.ReadFrame(stream, controlExtensions, metadataOnly);
|
|
case GifTrailer.TrailerByte:
|
|
return GifTrailer.ReadTrailer();
|
|
default:
|
|
throw GifHelpers.UnknownBlockTypeException(blockId);
|
|
}
|
|
}
|
|
|
|
internal abstract GifBlockKind Kind { get; }
|
|
}
|
|
}
|