Ejemplo n.º 1
0
        private void ReadFrames(Stream stream, bool metadataOnly)
        {
            List <GifFrame>     list = new List <GifFrame>();
            List <GifExtension> controlExtensions = new List <GifExtension>();
            List <GifExtension> list3             = new List <GifExtension>();

            while (true)
            {
                GifBlock block = GifBlock.ReadBlock(stream, controlExtensions, metadataOnly);
                if (block.Kind == GifBlockKind.GraphicRendering)
                {
                    controlExtensions = new List <GifExtension>();
                }
                if (block is GifFrame)
                {
                    list.Add((GifFrame)block);
                }
                else if (!(block is GifExtension))
                {
                    if (block is GifTrailer)
                    {
                        this.Frames     = list.AsReadOnly();
                        this.Extensions = list3.AsReadOnly();
                        return;
                    }
                }
                else
                {
                    GifExtension item = (GifExtension)block;
                    switch (item.Kind)
                    {
                    case GifBlockKind.Control:
                        controlExtensions.Add(item);
                        break;

                    case GifBlockKind.SpecialPurpose:
                        list3.Add(item);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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());
        }