Browse Source

Revert unrequired async/await additions

pull/1574/head
James Jackson-South 6 years ago
parent
commit
d2a2709c71
  1. 4
      src/ImageSharp/Advanced/AdvancedImageExtensions.cs
  2. 4
      src/ImageSharp/Formats/Bmp/BmpEncoder.cs
  3. 4
      src/ImageSharp/Formats/Gif/GifEncoder.cs
  4. 4
      src/ImageSharp/Formats/Tga/TgaDecoder.cs
  5. 4
      src/ImageSharp/Formats/Tga/TgaEncoder.cs
  6. 37
      src/ImageSharp/Image.FromStream.cs

4
src/ImageSharp/Advanced/AdvancedImageExtensions.cs

@ -74,8 +74,8 @@ namespace SixLabors.ImageSharp.Advanced
/// <param name="source">The source image.</param>
/// <param name="visitor">The image visitor.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
public static async Task AcceptVisitorAsync(this Image source, IImageVisitorAsync visitor)
=> await source.AcceptAsync(visitor).ConfigureAwait(false);
public static Task AcceptVisitorAsync(this Image source, IImageVisitorAsync visitor)
=> source.AcceptAsync(visitor);
/// <summary>
/// Gets the configuration for the image.

4
src/ImageSharp/Formats/Bmp/BmpEncoder.cs

@ -42,11 +42,11 @@ namespace SixLabors.ImageSharp.Formats.Bmp
}
/// <inheritdoc/>
public async Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream)
public Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : unmanaged, IPixel<TPixel>
{
var encoder = new BmpEncoderCore(this, image.GetMemoryAllocator());
await encoder.EncodeAsync(image, stream).ConfigureAwait(false);
return encoder.EncodeAsync(image, stream);
}
}
}

4
src/ImageSharp/Formats/Gif/GifEncoder.cs

@ -41,11 +41,11 @@ namespace SixLabors.ImageSharp.Formats.Gif
}
/// <inheritdoc/>
public async Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream)
public Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : unmanaged, IPixel<TPixel>
{
var encoder = new GifEncoderCore(image.GetConfiguration(), this);
await encoder.EncodeAsync(image, stream).ConfigureAwait(false);
return encoder.EncodeAsync(image, stream);
}
}
}

4
src/ImageSharp/Formats/Tga/TgaDecoder.cs

@ -74,11 +74,11 @@ namespace SixLabors.ImageSharp.Formats.Tga
}
/// <inheritdoc/>
public async Task<IImageInfo> IdentifyAsync(Configuration configuration, Stream stream)
public Task<IImageInfo> IdentifyAsync(Configuration configuration, Stream stream)
{
Guard.NotNull(stream, nameof(stream));
return await new TgaDecoderCore(configuration, this).IdentifyAsync(stream).ConfigureAwait(false);
return new TgaDecoderCore(configuration, this).IdentifyAsync(stream);
}
}
}

4
src/ImageSharp/Formats/Tga/TgaEncoder.cs

@ -32,11 +32,11 @@ namespace SixLabors.ImageSharp.Formats.Tga
}
/// <inheritdoc/>
public async Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream)
public Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : unmanaged, IPixel<TPixel>
{
var encoder = new TgaEncoderCore(this, image.GetMemoryAllocator());
await encoder.EncodeAsync(image, stream).ConfigureAwait(false);
return encoder.EncodeAsync(image, stream);
}
}
}

37
src/ImageSharp/Image.FromStream.cs

@ -57,12 +57,11 @@ namespace SixLabors.ImageSharp
/// <exception cref="ArgumentNullException">The stream is null.</exception>
/// <exception cref="NotSupportedException">The stream is not readable.</exception>
/// <returns>The format type or null if none found.</returns>
public static async Task<IImageFormat> DetectFormatAsync(Configuration configuration, Stream stream)
=> await WithSeekableStreamAsync(
public static Task<IImageFormat> DetectFormatAsync(Configuration configuration, Stream stream)
=> WithSeekableStreamAsync(
configuration,
stream,
async s => await InternalDetectFormatAsync(s, configuration).ConfigureAwait(false))
.ConfigureAwait(false);
s => InternalDetectFormatAsync(s, configuration));
/// <summary>
/// Reads the raw image information from the specified stream without fully decoding it.
@ -184,12 +183,11 @@ namespace SixLabors.ImageSharp
/// <returns>
/// The <see cref="FormattedImageInfo"/> with <see cref="FormattedImageInfo.ImageInfo"/> set to null if suitable info detector is not found.
/// </returns>
public static async Task<FormattedImageInfo> IdentifyWithFormatAsync(Configuration configuration, Stream stream)
=> await WithSeekableStreamAsync(
public static Task<FormattedImageInfo> IdentifyWithFormatAsync(Configuration configuration, Stream stream)
=> WithSeekableStreamAsync(
configuration,
stream,
async s => await InternalIdentityAsync(s, configuration ?? Configuration.Default))
.ConfigureAwait(false);
s => InternalIdentityAsync(s, configuration ?? Configuration.Default));
/// <summary>
/// Decode a new instance of the <see cref="Image"/> class from the given stream.
@ -309,7 +307,10 @@ namespace SixLabors.ImageSharp
public static Task<Image> LoadAsync(Configuration configuration, Stream stream, IImageDecoder decoder)
{
Guard.NotNull(decoder, nameof(decoder));
return WithSeekableStreamAsync(configuration, stream, s => decoder.DecodeAsync(configuration, s));
return WithSeekableStreamAsync(
configuration,
stream,
s => decoder.DecodeAsync(configuration, s));
}
/// <summary>
@ -425,13 +426,12 @@ namespace SixLabors.ImageSharp
/// <exception cref="InvalidImageContentException">Image contains invalid content.</exception>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
public static async Task<Image<TPixel>> LoadAsync<TPixel>(Stream stream, IImageDecoder decoder)
public static Task<Image<TPixel>> LoadAsync<TPixel>(Stream stream, IImageDecoder decoder)
where TPixel : unmanaged, IPixel<TPixel>
=> await WithSeekableStreamAsync(
=> WithSeekableStreamAsync(
Configuration.Default,
stream,
async s => await decoder.DecodeAsync<TPixel>(Configuration.Default, s).ConfigureAwait(false))
.ConfigureAwait(false);
s => decoder.DecodeAsync<TPixel>(Configuration.Default, s));
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given stream.
@ -463,13 +463,12 @@ namespace SixLabors.ImageSharp
/// <exception cref="InvalidImageContentException">Image contains invalid content.</exception>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
public static async Task<Image<TPixel>> LoadAsync<TPixel>(Configuration configuration, Stream stream, IImageDecoder decoder)
public static Task<Image<TPixel>> LoadAsync<TPixel>(Configuration configuration, Stream stream, IImageDecoder decoder)
where TPixel : unmanaged, IPixel<TPixel>
=> await WithSeekableStreamAsync(
=> WithSeekableStreamAsync(
configuration,
stream,
async s => await decoder.DecodeAsync<TPixel>(configuration, s).ConfigureAwait(false))
.ConfigureAwait(false);
s => decoder.DecodeAsync<TPixel>(configuration, s));
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given stream.
@ -577,8 +576,8 @@ namespace SixLabors.ImageSharp
await WithSeekableStreamAsync(
configuration,
stream,
async s => await DecodeAsync<TPixel>(s, configuration).ConfigureAwait(false))
.ConfigureAwait(false);
async s => await DecodeAsync<TPixel>(s, configuration)
.ConfigureAwait(false));
if (data.img != null)
{

Loading…
Cancel
Save