Ejemplo n.º 1
0
        internal static GifBlock ReadBlock(
            Stream stream,
            IEnumerable <GifExtension> controlExtensions,
            bool metadataOnly)
        {
            int blockId = stream.ReadByte();

            if (blockId < 0)
            {
                throw GifHelpers.UnexpectedEndOfStreamException();
            }
            if (blockId == 33)
            {
                return((GifBlock)GifExtension.ReadExtension(stream, controlExtensions, metadataOnly));
            }
            if (blockId == 44)
            {
                return((GifBlock)GifFrame.ReadFrame(stream, controlExtensions, metadataOnly));
            }
            if (blockId == 59)
            {
                return((GifBlock)GifTrailer.ReadTrailer());
            }
            throw GifHelpers.UnknownBlockTypeException(blockId);
        }
Ejemplo n.º 2
0
    public static GifBlock ReadBlock(Stream stream, IEnumerable <GifExtension> controlExtensions, bool metadataOnly)
    {
        var 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);
        }
    }