Example #1
0
        internal static async Task <GifBlock> ReadAsync(Stream stream, IEnumerable <GifExtension> controlExtensions)
        {
            int blockId = await stream.ReadByteAsync().ConfigureAwait(false);

            if (blockId < 0)
            {
                throw new EndOfStreamException();
            }
            return(blockId switch
            {
                GifExtension.ExtensionIntroducer => await GifExtension.ReadAsync(stream, controlExtensions).ConfigureAwait(false),
                GifFrame.ImageSeparator => await GifFrame.ReadAsync(stream, controlExtensions).ConfigureAwait(false),
                GifTrailer.TrailerByte => await GifTrailer.ReadAsync().ConfigureAwait(false),
                _ => throw GifHelpers.UnknownBlockTypeException(blockId),
            });
Example #2
0
 internal static async Task<GifBlock> ReadAsync(Stream stream, IEnumerable<GifExtension> controlExtensions)
 {
     int blockId = await stream.ReadByteAsync().ConfigureAwait(false);
     if (blockId < 0)
         throw GifHelpers.UnexpectedEndOfStreamException();
     switch (blockId)
     {
         case GifExtension.ExtensionIntroducer:
             return await GifExtension.ReadAsync(stream, controlExtensions).ConfigureAwait(false);
         case GifFrame.ImageSeparator:
             return await GifFrame.ReadAsync(stream, controlExtensions).ConfigureAwait(false);
         case GifTrailer.TrailerByte:
             return await GifTrailer.ReadAsync().ConfigureAwait(false);
         default:
             throw GifHelpers.UnknownBlockTypeException(blockId);
     }
 }
Example #3
0
        internal static async Task <GifBlock> ReadAsync(Stream stream, IEnumerable <GifExtension> controlExtensions)
        {
            int blockId = await stream.ReadByteAsync(new CancellationToken()).ConfigureAwait(false);

            if (blockId < 0)
            {
                throw GifHelpers.UnexpectedEndOfStreamException();
            }
            switch (blockId)
            {
            case 33:
                return((GifBlock)await GifExtension.ReadAsync(stream, controlExtensions).ConfigureAwait(false));

            case 44:
                return((GifBlock)await GifFrame.ReadAsync(stream, controlExtensions).ConfigureAwait(false));

            case 59:
                return((GifBlock)await GifTrailer.ReadAsync().ConfigureAwait(false));

            default:
                throw GifHelpers.UnknownBlockTypeException(blockId);
            }
        }