Skip to content

Commit aa7c6d1

Browse files
Merge branch 'main' into js/fix-resize-pad-color
2 parents 74dfe7e + 8d7c271 commit aa7c6d1

36 files changed

+303
-804
lines changed

src/ImageSharp/Advanced/AotCompilerTools.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,7 @@ private static void AotCompileImageDecoder<TPixel, TDecoder>()
287287
where TPixel : unmanaged, IPixel<TPixel>
288288
where TDecoder : class, IImageDecoder
289289
{
290-
default(TDecoder).Decode<TPixel>(default, default);
291-
default(TDecoder).DecodeAsync<TPixel>(default, default, default);
290+
default(TDecoder).Decode<TPixel>(default, default, default);
292291
}
293292

294293
/// <summary>

src/ImageSharp/Formats/Bmp/BmpDecoder.cs

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33

44
using System.IO;
55
using System.Threading;
6-
using System.Threading.Tasks;
7-
using SixLabors.ImageSharp.IO;
8-
using SixLabors.ImageSharp.Memory;
96
using SixLabors.ImageSharp.PixelFormats;
107

118
namespace SixLabors.ImageSharp.Formats.Bmp
@@ -31,48 +28,25 @@ public sealed class BmpDecoder : IImageDecoder, IBmpDecoderOptions, IImageInfoDe
3128
public RleSkippedPixelHandling RleSkippedPixelHandling { get; set; } = RleSkippedPixelHandling.Black;
3229

3330
/// <inheritdoc/>
34-
public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream)
31+
public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream, CancellationToken cancellationToken)
3532
where TPixel : unmanaged, IPixel<TPixel>
3633
{
3734
Guard.NotNull(stream, nameof(stream));
3835

3936
var decoder = new BmpDecoderCore(configuration, this);
40-
return decoder.Decode<TPixel>(configuration, stream);
37+
return decoder.Decode<TPixel>(configuration, stream, cancellationToken);
4138
}
4239

4340
/// <inheritdoc />
44-
public Image Decode(Configuration configuration, Stream stream)
45-
=> this.Decode<Rgba32>(configuration, stream);
41+
public Image Decode(Configuration configuration, Stream stream, CancellationToken cancellationToken)
42+
=> this.Decode<Rgba32>(configuration, stream, cancellationToken);
4643

4744
/// <inheritdoc/>
48-
public Task<Image<TPixel>> DecodeAsync<TPixel>(Configuration configuration, Stream stream, CancellationToken cancellationToken)
49-
where TPixel : unmanaged, IPixel<TPixel>
45+
public IImageInfo Identify(Configuration configuration, Stream stream, CancellationToken cancellationToken)
5046
{
5147
Guard.NotNull(stream, nameof(stream));
5248

53-
var decoder = new BmpDecoderCore(configuration, this);
54-
return decoder.DecodeAsync<TPixel>(configuration, stream, cancellationToken);
55-
}
56-
57-
/// <inheritdoc />
58-
public async Task<Image> DecodeAsync(Configuration configuration, Stream stream, CancellationToken cancellationToken)
59-
=> await this.DecodeAsync<Rgba32>(configuration, stream, cancellationToken)
60-
.ConfigureAwait(false);
61-
62-
/// <inheritdoc/>
63-
public IImageInfo Identify(Configuration configuration, Stream stream)
64-
{
65-
Guard.NotNull(stream, nameof(stream));
66-
67-
return new BmpDecoderCore(configuration, this).Identify(configuration, stream);
68-
}
69-
70-
/// <inheritdoc/>
71-
public Task<IImageInfo> IdentifyAsync(Configuration configuration, Stream stream, CancellationToken cancellationToken)
72-
{
73-
Guard.NotNull(stream, nameof(stream));
74-
75-
return new BmpDecoderCore(configuration, this).IdentifyAsync(configuration, stream, cancellationToken);
49+
return new BmpDecoderCore(configuration, this).Identify(configuration, stream, cancellationToken);
7650
}
7751
}
7852
}

src/ImageSharp/Formats/Gif/GifDecoder.cs

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
using System.IO;
55
using System.Threading;
6-
using System.Threading.Tasks;
7-
using SixLabors.ImageSharp.IO;
86
using SixLabors.ImageSharp.Metadata;
97
using SixLabors.ImageSharp.PixelFormats;
108

@@ -26,48 +24,24 @@ public sealed class GifDecoder : IImageDecoder, IGifDecoderOptions, IImageInfoDe
2624
public FrameDecodingMode DecodingMode { get; set; } = FrameDecodingMode.All;
2725

2826
/// <inheritdoc/>
29-
public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream)
27+
public Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream, CancellationToken cancellationToken)
3028
where TPixel : unmanaged, IPixel<TPixel>
3129
{
3230
var decoder = new GifDecoderCore(configuration, this);
33-
return decoder.Decode<TPixel>(configuration, stream);
31+
return decoder.Decode<TPixel>(configuration, stream, cancellationToken);
3432
}
3533

3634
/// <inheritdoc />
37-
public Image Decode(Configuration configuration, Stream stream)
38-
=> this.Decode<Rgba32>(configuration, stream);
35+
public Image Decode(Configuration configuration, Stream stream, CancellationToken cancellationToken)
36+
=> this.Decode<Rgba32>(configuration, stream, cancellationToken);
3937

4038
/// <inheritdoc/>
41-
public Task<Image<TPixel>> DecodeAsync<TPixel>(Configuration configuration, Stream stream, CancellationToken cancellationToken)
42-
where TPixel : unmanaged, IPixel<TPixel>
43-
{
44-
var decoder = new GifDecoderCore(configuration, this);
45-
return decoder.DecodeAsync<TPixel>(configuration, stream, cancellationToken);
46-
}
47-
48-
/// <inheritdoc />
49-
public async Task<Image> DecodeAsync(Configuration configuration, Stream stream, CancellationToken cancellationToken)
50-
=> await this.DecodeAsync<Rgba32>(configuration, stream, cancellationToken)
51-
.ConfigureAwait(false);
52-
53-
/// <inheritdoc/>
54-
public IImageInfo Identify(Configuration configuration, Stream stream)
55-
{
56-
Guard.NotNull(stream, nameof(stream));
57-
58-
var decoder = new GifDecoderCore(configuration, this);
59-
60-
using var bufferedStream = new BufferedReadStream(configuration, stream);
61-
return decoder.Identify(bufferedStream, default);
62-
}
63-
64-
/// <inheritdoc/>
65-
public Task<IImageInfo> IdentifyAsync(Configuration configuration, Stream stream, CancellationToken cancellationToken)
39+
public IImageInfo Identify(Configuration configuration, Stream stream, CancellationToken cancellationToken)
6640
{
6741
Guard.NotNull(stream, nameof(stream));
6842

6943
var decoder = new GifDecoderCore(configuration, this);
70-
return decoder.IdentifyAsync(configuration, stream, cancellationToken);
44+
return decoder.Identify(configuration, stream, cancellationToken);
7145
}
7246
}
7347
}

src/ImageSharp/Formats/IImageDecoder.cs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System.IO;
55
using System.Threading;
6-
using System.Threading.Tasks;
76
using SixLabors.ImageSharp.PixelFormats;
87

98
namespace SixLabors.ImageSharp.Formats
@@ -13,26 +12,6 @@ namespace SixLabors.ImageSharp.Formats
1312
/// </summary>
1413
public interface IImageDecoder
1514
{
16-
/// <summary>
17-
/// Decodes the image from the specified stream to an <see cref="Image{TPixel}"/> of a specific pixel type.
18-
/// </summary>
19-
/// <typeparam name="TPixel">The pixel format.</typeparam>
20-
/// <param name="configuration">The configuration for the image.</param>
21-
/// <param name="stream">The <see cref="Stream"/> containing image data.</param>
22-
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
23-
// TODO: Document ImageFormatExceptions (https://github.com/SixLabors/ImageSharp/issues/1110)
24-
Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream)
25-
where TPixel : unmanaged, IPixel<TPixel>;
26-
27-
/// <summary>
28-
/// Decodes the image from the specified stream to an <see cref="Image"/>.
29-
/// </summary>
30-
/// <param name="configuration">The configuration for the image.</param>
31-
/// <param name="stream">The <see cref="Stream"/> containing image data.</param>
32-
/// <returns>The <see cref="Image"/>.</returns>
33-
// TODO: Document ImageFormatExceptions (https://github.com/SixLabors/ImageSharp/issues/1110)
34-
Image Decode(Configuration configuration, Stream stream);
35-
3615
/// <summary>
3716
/// Decodes the image from the specified stream to an <see cref="Image{TPixel}"/> of a specific pixel type.
3817
/// </summary>
@@ -42,7 +21,7 @@ Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream)
4221
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
4322
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
4423
// TODO: Document ImageFormatExceptions (https://github.com/SixLabors/ImageSharp/issues/1110)
45-
Task<Image<TPixel>> DecodeAsync<TPixel>(Configuration configuration, Stream stream, CancellationToken cancellationToken)
24+
Image<TPixel> Decode<TPixel>(Configuration configuration, Stream stream, CancellationToken cancellationToken)
4625
where TPixel : unmanaged, IPixel<TPixel>;
4726

4827
/// <summary>
@@ -53,6 +32,6 @@ Task<Image<TPixel>> DecodeAsync<TPixel>(Configuration configuration, Stream stre
5332
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
5433
/// <returns>The <see cref="Image"/>.</returns>
5534
// TODO: Document ImageFormatExceptions (https://github.com/SixLabors/ImageSharp/issues/1110)
56-
Task<Image> DecodeAsync(Configuration configuration, Stream stream, CancellationToken cancellationToken);
35+
Image Decode(Configuration configuration, Stream stream, CancellationToken cancellationToken);
5736
}
5837
}

src/ImageSharp/Formats/IImageInfoDetector.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System.IO;
55
using System.Threading;
6-
using System.Threading.Tasks;
76

87
namespace SixLabors.ImageSharp.Formats
98
{
@@ -12,21 +11,13 @@ namespace SixLabors.ImageSharp.Formats
1211
/// </summary>
1312
public interface IImageInfoDetector
1413
{
15-
/// <summary>
16-
/// Reads the raw image information from the specified stream.
17-
/// </summary>
18-
/// <param name="configuration">The configuration for the image.</param>
19-
/// <param name="stream">The <see cref="Stream"/> containing image data.</param>
20-
/// <returns>The <see cref="PixelTypeInfo"/> object</returns>
21-
IImageInfo Identify(Configuration configuration, Stream stream);
22-
2314
/// <summary>
2415
/// Reads the raw image information from the specified stream.
2516
/// </summary>
2617
/// <param name="configuration">The configuration for the image.</param>
2718
/// <param name="stream">The <see cref="Stream"/> containing image data.</param>
2819
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
2920
/// <returns>The <see cref="PixelTypeInfo"/> object</returns>
30-
Task<IImageInfo> IdentifyAsync(Configuration configuration, Stream stream, CancellationToken cancellationToken);
21+
IImageInfo Identify(Configuration configuration, Stream stream, CancellationToken cancellationToken);
3122
}
3223
}

0 commit comments

Comments
 (0)