Пример #1
0
        internal static GifCommentExtension ReadComment(Stream stream)
        {
            var comment = new GifCommentExtension();

            comment.Read(stream);
            return(comment);
        }
Пример #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)
            });