Exemple #1
0
        internal static GifPlainTextExtension ReadPlainText(Stream stream, IEnumerable <GifExtension> controlExtensions, bool metadataOnly)
        {
            var plainText = new GifPlainTextExtension();

            plainText.Read(stream, controlExtensions, metadataOnly);
            return(plainText);
        }
Exemple #2
0
        internal static GifExtension ReadExtension(Stream stream, IEnumerable <GifExtension> controlExtensions, bool metadataOnly)
        {
            // Note: at this point, the Extension Introducer (0x21) has already been read

            var label = stream.ReadByte();

            if (label < 0)
            {
                throw GifHelpers.UnexpectedEndOfStreamException();
            }
            return(label switch
            {
                GifGraphicControlExtension.ExtensionLabel => (GifExtension)GifGraphicControlExtension.ReadGraphicsControl(stream),
                GifCommentExtension.ExtensionLabel => GifCommentExtension.ReadComment(stream),
                GifPlainTextExtension.ExtensionLabel => GifPlainTextExtension.ReadPlainText(stream, controlExtensions, metadataOnly),
                GifApplicationExtension.ExtensionLabel => GifApplicationExtension.ReadApplication(stream),
                _ => throw GifHelpers.UnknownExtensionTypeException(label)
            });