Beispiel #1
0
        internal static GifExtension ReadExtension(Stream stream, IEnumerable <GifExtension> controlExtensions, bool metadataOnly)
        {
            int extensionLabel = stream.ReadByte();

            if (extensionLabel < 0)
            {
                throw GifHelpers.UnexpectedEndOfStreamException();
            }
            int num2 = extensionLabel;

            if (num2 == 1)
            {
                return(GifPlainTextExtension.ReadPlainText(stream, controlExtensions, metadataOnly));
            }
            if (num2 == 0xf9)
            {
                return(GifGraphicControlExtension.ReadGraphicsControl(stream));
            }
            switch (num2)
            {
            case 0xfe:
                return(GifCommentExtension.ReadComment(stream));

            case 0xff:
                return(GifApplicationExtension.ReadApplication(stream));
            }
            throw GifHelpers.UnknownExtensionTypeException(extensionLabel);
        }
        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);
            }
        }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
        internal static GifBlock ReadBlock(Stream stream, IEnumerable <GifExtension> controlExtensions, bool metadataOnly)
        {
            int blockId = stream.ReadByte();

            if (blockId < 0)
            {
                throw GifHelpers.UnexpectedEndOfStreamException();
            }
            int num2 = blockId;

            if (num2 == 0x21)
            {
                return(GifExtension.ReadExtension(stream, controlExtensions, metadataOnly));
            }
            if (num2 == 0x2c)
            {
                return(GifFrame.ReadFrame(stream, controlExtensions, metadataOnly));
            }
            if (num2 != 0x3b)
            {
                throw GifHelpers.UnknownBlockTypeException(blockId);
            }
            return(GifTrailer.ReadTrailer());
        }