Пример #1
0
 /// <summary>
 /// Create a new instance of the <see cref="Image{TPixel}"/> class from the given stream.
 /// </summary>
 /// <param name="stream">The stream containing image information.</param>
 /// <param name="decoder">The decoder.</param>
 /// <exception cref="ArgumentNullException">The stream is null.</exception>
 /// <exception cref="NotSupportedException">The stream is not readable.</exception>
 /// <exception cref="UnknownImageFormatException">Image format not recognised.</exception>
 /// <exception cref="InvalidImageContentException">Image contains invalid content.</exception>
 /// <typeparam name="TPixel">The pixel format.</typeparam>
 /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
 public static Task <Image <TPixel> > LoadAsync <TPixel>(Stream stream, IImageDecoder decoder)
     where TPixel : unmanaged, IPixel <TPixel>
 => WithSeekableStreamAsync(
     Configuration.Default,
     stream,
     s => decoder.DecodeAsync <TPixel>(Configuration.Default, s));