internal new static async Task <GifExtension> ReadAsync(Stream stream, IEnumerable <GifExtension> controlExtensions)
        {
            // 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(await GifGraphicControlExtension.ReadAsync(stream).ConfigureAwait(false));

            case GifCommentExtension.ExtensionLabel:
                return(await GifCommentExtension.ReadAsync(stream).ConfigureAwait(false));

            case GifPlainTextExtension.ExtensionLabel:
                return(await GifPlainTextExtension.ReadAsync(stream, controlExtensions).ConfigureAwait(false));

            case GifApplicationExtension.ExtensionLabel:
                return(await GifApplicationExtension.ReadAsync(stream).ConfigureAwait(false));

            default:
                throw GifHelpers.UnknownExtensionTypeException(label);
            }
        }
Beispiel #2
0
        internal static async Task <GifExtension> ReadAsync(Stream stream, IEnumerable <GifExtension> controlExtensions)
        {
            int label = stream.ReadByte();

            if (label < 0)
            {
                throw GifHelpers.UnexpectedEndOfStreamException();
            }
            switch (label)
            {
            case 254:
                return((GifExtension)await GifCommentExtension.ReadAsync(stream).ConfigureAwait(false));

            case (int)byte.MaxValue:
                return((GifExtension)await GifApplicationExtension.ReadAsync(stream).ConfigureAwait(false));

            case 1:
                return((GifExtension)await GifPlainTextExtension.ReadAsync(stream, controlExtensions).ConfigureAwait(false));

            case 249:
                return((GifExtension)await GifGraphicControlExtension.ReadAsync(stream).ConfigureAwait(false));

            default:
                throw GifHelpers.UnknownExtensionTypeException(label);
            }
        }
Beispiel #3
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);
     }
 }
Beispiel #4
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);
            }
        }