blob: fda8909ec5b09cdad09d5f77ec379e652daf33d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
using System.Collections.Generic;
using System.IO;
namespace Tango.AnimatedGif.Decoding
{
internal abstract class GifExtension : GifBlock
{
internal const int ExtensionIntroducer = 0x21;
internal static GifExtension ReadExtension(Stream stream, IEnumerable<GifExtension> controlExtensions, bool metadataOnly)
{
// Note: at this point, the Extension Introducer (0x21) has already been read
int label = stream.ReadByte();
if (label < 0)
throw GifHelpers.UnexpectedEndOfStreamException();
switch (label)
{
case GifGraphicControlExtension.ExtensionLabel:
return GifGraphicControlExtension.ReadGraphicsControl(stream);
case GifCommentExtension.ExtensionLabel:
return GifCommentExtension.ReadComment(stream);
case GifPlainTextExtension.ExtensionLabel:
return GifPlainTextExtension.ReadPlainText(stream, controlExtensions, metadataOnly);
case GifApplicationExtension.ExtensionLabel:
return GifApplicationExtension.ReadApplication(stream);
default:
throw GifHelpers.UnknownExtensionTypeException(label);
}
}
}
}
|