Introduce Shared General Decoder Options plus Specialization#2180
Merged
Conversation
Member
Author
|
I must have broken something with the last commit. I promise I had all tests passing! 😝 |
Contributor
|
Phenomenal, will try to review this week! |
gfoidl
reviewed
Jul 18, 2022
gfoidl
left a comment
Contributor
There was a problem hiding this comment.
Just scrolled through the changes, some nits.
Didn't read the xml-comments and tests though.
Co-authored-by: Günther Foidl <gue@korporal.at>
Co-authored-by: Günther Foidl <gue@korporal.at>
Co-authored-by: Günther Foidl <gue@korporal.at>
Co-authored-by: Günther Foidl <gue@korporal.at>
Member
Author
|
OK.... Added a bunch of extra tests. Had another look at the encoder story and stateless with options looks like a sensible pattern we can adopt also. It allows us to ensure only registered encoders are used (currently it's possible to allow passing unregistered). If I can get some eyes on this branch again please I'd be very grateful. I'm very keen to move on. |
Member
Author
|
I'm gonna push on with this. Lot's to do. |
4 tasks
This was referenced Sep 29, 2025
This was referenced Nov 17, 2025
This was referenced Mar 23, 2026
This was referenced Apr 26, 2026
This was referenced Jun 2, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Prerequisites
Description
Based on the discussion #2091 I've refactored our decoding API to do a few things.
ImageDecoder<T>class whereTisISpecializedDecoderOptionswhich allows external implementations to easily implement decoders using our new resize-on-decode strategy.Image.Load(...)as it was leading to too many user errors based on incorrect encoding assumptions.ReadonlySpan<T>conversionThe general decoder options look like this.
The options replace Configuration as the primary parameter in all our decoding APIs
I've deliberately chosen not to allow passing
ResizeOptionsto the decoder as I want to leave a clear path between general and specialist pipelines. Default resize-on-decode usesResizeMode.Maxwith theKnownResamplers.Box.An example
ISpecializedDecoderOptionsimplementation looks like the following.Usage is allowed only on decoder instances via individual
IImageDecoderSpecialized<T>implementationsAll but the
JpegDecoderutilize the same resizing strategy for specialized methods as the default loading behavior.JpegDecoderwill only downscale to the nearest size that is supported by the decoder allowing users to apply their own resize behavior in advanced scenarios. CC @br3aker