/// <inheritdoc/> public Task <Image <TPixel> > DecodeAsync <TPixel>(Configuration configuration, Stream stream, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel <TPixel> { Guard.NotNull(stream, nameof(stream)); var decoder = new BmpDecoderCore(configuration, this); return(decoder.DecodeAsync <TPixel>(configuration, stream, cancellationToken)); }
/// <inheritdoc/> public async Task <Image <TPixel> > DecodeAsync <TPixel>(Configuration configuration, Stream stream) where TPixel : unmanaged, IPixel <TPixel> { Guard.NotNull(stream, nameof(stream)); var decoder = new BmpDecoderCore(configuration, this); try { return(await decoder.DecodeAsync <TPixel>(stream).ConfigureAwait(false)); } catch (InvalidMemoryOperationException ex) { Size dims = decoder.Dimensions; throw new InvalidImageContentException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}. This error can happen for very large RLE bitmaps, which are not supported.", ex); } }