示例#1
0
        /// <inheritdoc/>
        public Task <Image <TPixel> > DecodeAsync <TPixel>(Configuration configuration, Stream stream, CancellationToken cancellationToken)
            where TPixel : unmanaged, IPixel <TPixel>
        {
            var decoder = new GifDecoderCore(configuration, this);

            return(decoder.DecodeAsync <TPixel>(configuration, stream, cancellationToken));
        }
示例#2
0
        /// <inheritdoc/>
        public async Task <Image <TPixel> > DecodeAsync <TPixel>(Configuration configuration, Stream stream)
            where TPixel : unmanaged, IPixel <TPixel>
        {
            var decoder = new GifDecoderCore(configuration, this);

            try
            {
                return(await decoder.DecodeAsync <TPixel>(stream).ConfigureAwait(false));
            }
            catch (InvalidMemoryOperationException ex)
            {
                Size dims = decoder.Dimensions;

                GifThrowHelper.ThrowInvalidImageContentException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}.", ex);

                // Not reachable, as the previous statement will throw a exception.
                return(null);
            }
        }