Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9bbd505
Add Async APIs to IImageEncoder and IImageDecoder
tocsoft May 3, 2020
4d95e2e
Save async tests
tocsoft May 3, 2020
dff8ab6
implement Load Async apis
tocsoft May 6, 2020
c69683e
IdentifyAsync
tocsoft May 6, 2020
2599275
Update src/ImageSharp/Formats/Jpeg/JpegDecoder.cs
JimBobSquarePants May 17, 2020
ef3b71f
Update src/ImageSharp/Formats/Png/PngEncoder.cs
JimBobSquarePants May 17, 2020
e643553
Update src/ImageSharp/Image.Decode.cs
JimBobSquarePants May 17, 2020
a27eb49
Update src/ImageSharp/Image.Decode.cs
JimBobSquarePants May 17, 2020
f7beaa1
Update src/ImageSharp/Image.cs
JimBobSquarePants May 17, 2020
2fc3058
Update src/ImageSharp/Image.FromStream.cs
JimBobSquarePants May 17, 2020
740d133
Update src/ImageSharp/Image.FromStream.cs
JimBobSquarePants May 17, 2020
6c18639
Update src/ImageSharp/Image.FromStream.cs
JimBobSquarePants May 17, 2020
b505771
Update src/ImageSharp/Image.FromStream.cs
JimBobSquarePants May 17, 2020
1969165
Update src/ImageSharp/Image.FromStream.cs
JimBobSquarePants May 17, 2020
43b0d5e
Update src/ImageSharp/Image.FromStream.cs
JimBobSquarePants May 17, 2020
84c7958
Merge branch 'master' into sw/fake-async-codecs
JimBobSquarePants May 17, 2020
9bbf05d
async await where required
JimBobSquarePants May 17, 2020
1f74e31
implement IEquatable<T>
JimBobSquarePants May 17, 2020
6361a22
Rename extension
JimBobSquarePants May 17, 2020
5a8f78a
Revert unrequired async/await additions
JimBobSquarePants May 17, 2020
b8232e4
Update Image.FromStream.cs
JimBobSquarePants May 17, 2020
c8c561b
Merge branch 'master' into sw/fake-async-codecs
JimBobSquarePants May 19, 2020
72257ba
Merge branch 'master' into sw/fake-async-codecs
JimBobSquarePants May 27, 2020
5d4a18f
Merge branch 'master' into sw/fake-async-codecs
JimBobSquarePants Jun 9, 2020
73cc796
Use named tuple
JimBobSquarePants Jun 9, 2020
73fed79
Use pooled stream for async decode/identify
JimBobSquarePants Jun 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ImageSharp/Advanced/AdvancedImageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public static void AcceptVisitor(this Image source, IImageVisitor visitor)
/// <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.
Expand Down
4 changes: 2 additions & 2 deletions src/ImageSharp/Formats/Bmp/BmpEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream)
}

/// <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 changes: 2 additions & 2 deletions src/ImageSharp/Formats/Gif/GifEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream)
}

/// <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 changes: 2 additions & 2 deletions src/ImageSharp/Formats/Tga/TgaDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ public IImageInfo Identify(Configuration configuration, Stream stream)
}

/// <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 changes: 2 additions & 2 deletions src/ImageSharp/Formats/Tga/TgaEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream)
}

/// <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 changes: 18 additions & 19 deletions src/ImageSharp/Image.FromStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ public static Task<IImageFormat> DetectFormatAsync(Stream stream)
/// <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.
Expand Down Expand Up @@ -184,12 +183,11 @@ public static Task<FormattedImageInfo> IdentifyWithFormatAsync(Stream stream)
/// <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.
Expand Down Expand Up @@ -309,7 +307,10 @@ public static Image Load(Configuration configuration, Stream stream, IImageDecod
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>
Expand Down Expand Up @@ -425,13 +426,12 @@ public static Image<TPixel> Load<TPixel>(Stream stream, IImageDecoder decoder)
/// <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.
Expand Down Expand Up @@ -463,13 +463,12 @@ public static Image<TPixel> Load<TPixel>(Configuration configuration, Stream str
/// <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.
Expand Down Expand Up @@ -577,8 +576,8 @@ public static async Task<FormattedImage<TPixel>> LoadWithFormatAsync<TPixel>(Con
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)
{
Expand Down