-
-
Notifications
You must be signed in to change notification settings - Fork 879
Improve Decoder/Encoder symmetry #2276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
19bdecc
Replace IImageDecoder
JimBobSquarePants 31def5c
Replace IImageEncoder
JimBobSquarePants 5726089
Make decoder options init only (except Configuration cos tests)
JimBobSquarePants 7d5c05b
Delete ImageTests.ImageLoadTestBase.Fakes.cs
JimBobSquarePants 93a1700
Use new not shared options.
JimBobSquarePants 391442b
Merge branch 'main' into js/decoder-attempt-2
JimBobSquarePants 5669626
Merge branch 'main' into js/decoder-attempt-2
JimBobSquarePants 1d99413
Re-introduce IImageDecoder and split decoding pipelines.
JimBobSquarePants c550af8
Re-introduce IImageEncoder and split encoding pipelines.
JimBobSquarePants b1db34d
Rename base encoder
JimBobSquarePants dd88269
Stub code to prevent unnecessary stream copying on decode.
JimBobSquarePants b98e1df
Update AotCompilerTools.cs
JimBobSquarePants 1dc7bbf
Update SpecializedImageDecoder{T}.cs
JimBobSquarePants afa204b
Use ScaleToTargetSize
JimBobSquarePants 2721ad5
Enable optimization.
JimBobSquarePants 0dc9949
Rename and move configuration module.
JimBobSquarePants b32755d
Merge branch 'main' into js/decoder-attempt-2
JimBobSquarePants 32965d3
Simplify position checks.
JimBobSquarePants 8fdd6b0
Use default cancellation token
JimBobSquarePants 6978235
Feedback
JimBobSquarePants 28243df
Better tests for stream synchronization
JimBobSquarePants 4891dc3
Use real cancellation handling.
JimBobSquarePants 47f1cda
Rename method
JimBobSquarePants 4a613b6
Update src/ImageSharp/IO/BufferedReadStream.cs
JimBobSquarePants d8c8244
Merge branch 'js/decoder-attempt-2' of https://github.com/SixLabors/I…
JimBobSquarePants 00ca204
re-create add original DecodeAsync_IsCancellable test
antonfirsov 3a7c4f4
fix Decode_Cancellation tests
antonfirsov 447cd85
enough to test this for one format in ImageTests
antonfirsov 937e78c
cover JpegDecoder's own cancellation support
antonfirsov 112b114
with BufferedReadStream decoder cancellation works for all decoders, …
antonfirsov d1c76e2
fix comments
antonfirsov f3a2aea
Merge pull request #2301 from SixLabors/af/decoder-tests
JimBobSquarePants 0018845
fix Identify cancellation tests
antonfirsov 6a07a51
one more fix
antonfirsov 6675333
Merge branch 'af/decoder-tests' into js/decoder-attempt-2
antonfirsov 1b1be0a
fix condition
antonfirsov ce7ef11
cancellation tests: larger images, don't go above 0.7
antonfirsov b9ba211
only test for pre-cancellation with IdentifyAsync
antonfirsov 834f686
increase timeout
antonfirsov 25e8d01
cancellation detection in png DecodePixelData
antonfirsov 0eadea2
skip PNG cancellation tests for Unix
antonfirsov a58e6ff
Add more cancellation checks
JimBobSquarePants e2c5748
Base the buffer size on the stream length
JimBobSquarePants 718bdc4
Experiment with a much shorter timeout.
JimBobSquarePants 5f488ee
Revert "Experiment with a much shorter timeout."
JimBobSquarePants 64b4045
disable gif cancellation tests
antonfirsov 475825d
Merge branch 'js/decoder-attempt-2' of https://github.com/SixLabors/I…
antonfirsov 9a55652
we should validate cancellation for each decoder separately
antonfirsov bb22d69
Disable cancellation tests on Unix entirely
antonfirsov 2145794
Fix test file
JimBobSquarePants bd6e58c
Merge branch 'js/decoder-attempt-2' of https://github.com/SixLabors/I…
JimBobSquarePants 1dd2d6e
Better error handling in action wrapper
JimBobSquarePants 85dc0f3
[Experiment] do not timeout LoadAsync_IsCancellable
antonfirsov 205e1b3
Make decoder cancellation token default.
JimBobSquarePants 64c7a8e
Merge branch 'js/decoder-attempt-2' of https://github.com/SixLabors/I…
JimBobSquarePants 4007a48
Use shared instances for all built-in decoders.
JimBobSquarePants File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
// Copyright (c) Six Labors. | ||
// Copyright (c) Six Labors. | ||
// Licensed under the Six Labors Split License. | ||
|
||
namespace SixLabors.ImageSharp.Formats.Bmp; | ||
|
||
/// <summary> | ||
/// Registers the image encoders, decoders and mime type detectors for the bmp format. | ||
/// </summary> | ||
public sealed class BmpConfigurationModule : IConfigurationModule | ||
public sealed class BmpConfigurationModule : IImageFormatConfigurationModule | ||
{ | ||
/// <inheritdoc/> | ||
public void Configure(Configuration configuration) | ||
{ | ||
configuration.ImageFormatsManager.SetEncoder(BmpFormat.Instance, new BmpEncoder()); | ||
configuration.ImageFormatsManager.SetDecoder(BmpFormat.Instance, new BmpDecoder()); | ||
configuration.ImageFormatsManager.SetDecoder(BmpFormat.Instance, BmpDecoder.Instance); | ||
configuration.ImageFormatsManager.AddImageFormatDetector(new BmpImageFormatDetector()); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
// Copyright (c) Six Labors. | ||
// Copyright (c) Six Labors. | ||
// Licensed under the Six Labors Split License. | ||
|
||
namespace SixLabors.ImageSharp.Formats.Gif; | ||
|
||
/// <summary> | ||
/// Registers the image encoders, decoders and mime type detectors for the gif format. | ||
/// </summary> | ||
public sealed class GifConfigurationModule : IConfigurationModule | ||
public sealed class GifConfigurationModule : IImageFormatConfigurationModule | ||
{ | ||
/// <inheritdoc/> | ||
public void Configure(Configuration configuration) | ||
{ | ||
configuration.ImageFormatsManager.SetEncoder(GifFormat.Instance, new GifEncoder()); | ||
configuration.ImageFormatsManager.SetDecoder(GifFormat.Instance, new GifDecoder()); | ||
configuration.ImageFormatsManager.SetDecoder(GifFormat.Instance, GifDecoder.Instance); | ||
configuration.ImageFormatsManager.AddImageFormatDetector(new GifImageFormatDetector()); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,35 +6,68 @@ | |
namespace SixLabors.ImageSharp.Formats; | ||
|
||
/// <summary> | ||
/// Encapsulates properties and methods required for decoding an image from a stream. | ||
/// Defines the contract for all image decoders. | ||
/// </summary> | ||
public interface IImageDecoder : IImageInfoDetector | ||
public interface IImageDecoder | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No reason for a separate interface here. |
||
{ | ||
/// <summary> | ||
/// Reads the raw image information from the specified stream. | ||
/// </summary> | ||
/// <param name="options">The general decoder options.</param> | ||
/// <param name="stream">The <see cref="Stream"/> containing image data.</param> | ||
/// <returns>The <see cref="IImageInfo"/> object.</returns> | ||
/// <exception cref="ImageFormatException">Thrown if the encoded image contains errors.</exception> | ||
public IImageInfo Identify(DecoderOptions options, Stream stream); | ||
|
||
/// <summary> | ||
/// Reads the raw image information from the specified stream. | ||
/// </summary> | ||
/// <param name="options">The general decoder options.</param> | ||
/// <param name="stream">The <see cref="Stream"/> containing image data.</param> | ||
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param> | ||
/// <returns>The <see cref="Task{IImageInfo}"/> object.</returns> | ||
/// <exception cref="ImageFormatException">Thrown if the encoded image contains errors.</exception> | ||
public Task<IImageInfo> IdentifyAsync(DecoderOptions options, Stream stream, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Decodes the image from the specified stream to an <see cref="Image{TPixel}"/> of a specific pixel type. | ||
/// </summary> | ||
/// <remarks> | ||
/// This method is designed to support the ImageSharp internal infrastructure and is not recommended for direct use. | ||
/// </remarks> | ||
/// <typeparam name="TPixel">The pixel format.</typeparam> | ||
/// <param name="options">The general decoder options.</param> | ||
/// <param name="stream">The <see cref="Stream"/> containing image data.</param> | ||
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param> | ||
/// <returns>The <see cref="Image{TPixel}"/>.</returns> | ||
/// <exception cref="ImageFormatException">Thrown if the encoded image contains errors.</exception> | ||
Image<TPixel> Decode<TPixel>(DecoderOptions options, Stream stream, CancellationToken cancellationToken) | ||
public Image<TPixel> Decode<TPixel>(DecoderOptions options, Stream stream) | ||
where TPixel : unmanaged, IPixel<TPixel>; | ||
|
||
/// <summary> | ||
/// Decodes the image from the specified stream to an <see cref="Image"/> of a specific pixel type. | ||
/// </summary> | ||
/// <param name="options">The general decoder options.</param> | ||
/// <param name="stream">The <see cref="Stream"/> containing image data.</param> | ||
/// <returns>The <see cref="Image{TPixel}"/>.</returns> | ||
/// <exception cref="ImageFormatException">Thrown if the encoded image contains errors.</exception> | ||
public Image Decode(DecoderOptions options, Stream stream); | ||
|
||
/// <summary> | ||
/// Decodes the image from the specified stream to an <see cref="Image{TPixel}"/> of a specific pixel type. | ||
/// </summary> | ||
/// <typeparam name="TPixel">The pixel format.</typeparam> | ||
/// <param name="options">The general decoder options.</param> | ||
/// <param name="stream">The <see cref="Stream"/> containing image data.</param> | ||
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param> | ||
/// <returns>A <see cref="Task{Image}"/> representing the asynchronous operation.</returns> | ||
/// <exception cref="ImageFormatException">Thrown if the encoded image contains errors.</exception> | ||
public Task<Image<TPixel>> DecodeAsync<TPixel>(DecoderOptions options, Stream stream, CancellationToken cancellationToken = default) | ||
where TPixel : unmanaged, IPixel<TPixel>; | ||
|
||
/// <summary> | ||
/// Decodes the image from the specified stream to an <see cref="Image"/>. | ||
/// Decodes the image from the specified stream to an <see cref="Image"/> of a specific pixel type. | ||
/// </summary> | ||
/// <remarks> | ||
/// This method is designed to support the ImageSharp internal infrastructure and is not recommended for direct use. | ||
/// </remarks> | ||
/// <param name="options">The general decoder options.</param> | ||
/// <param name="stream">The <see cref="Stream"/> containing image data.</param> | ||
/// <param name="cancellationToken">The token to monitor for cancellation requests.</param> | ||
/// <returns>The <see cref="Image"/>.</returns> | ||
/// <returns>A <see cref="Task{Image}"/> representing the asynchronous operation.</returns> | ||
/// <exception cref="ImageFormatException">Thrown if the encoded image contains errors.</exception> | ||
Image Decode(DecoderOptions options, Stream stream, CancellationToken cancellationToken); | ||
public Task<Image> DecodeAsync(DecoderOptions options, Stream stream, CancellationToken cancellationToken = default); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.