Replies: 5 comments 26 replies
-
In combination with #2090 it would be closer to 65 'removed' APIs |
Beta Was this translation helpful? Give feedback.
-
Maybe we should use struct/record class to ensure passed options are immutable from outside? IMO |
Beta Was this translation helpful? Give feedback.
-
Shouldn't we just implement the old methods on top of Edit: + class DecoderOptions {
+ // common options
+ }
+
+ class GifDecoderOptions : DecoderOptions {
+ public FrameDecodingMode DecodingMode { get; set; }
+ }
- interface IGifDecoderOptions { FrameDecodingMode DecodingMode { get; set; } }
+ interface IImageDecoder {
+ Image Decode(DecoderOptions options, Stream stream, CancellationToken cancellationToken)
+ }
class GifDecoder :
- IGifDecoderOptions,
IImageDecoder
{
- Image Decode(Configuration configuration, Stream stream, CancellationToken cancellationToken);
+ Image Decode(DecoderOptions options, Stream stream, CancellationToken cancellationToken);
} |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Completed in v3 |
Beta Was this translation helpful? Give feedback.
-
The proposal is to add a new
DecoderOptions
type that can be passed along to compatible decoders.The idea is that decoder options will provider generic high level options that can be utilised by all decoders and can have a reasonable fallback to support decoders that do not have native support for the target feature.
First 2 options should be fairly obvious they provide a way for explicitly defining the decoder and explicitly defining the
Configuration
without having overload explosion on the loading apis.The
TargetSize
size property allow for supporting decoders to use that to decode into the target size with us providing a check and applying a final mutate if the decoder returns an image on the wrong size (upscaled size provided or just not supported etc).. decoders will be able to use this more of a hint than a target requirement but Image.Load will force the size before returning to the user.SkipMetadata
: allow for supporting decoders to totally skip metadata blocks but if the decoder does not support metadata skipping then we will null out all relevant parts of the metadata object before returning the image to the user.MaxFrames
: hints to the decoder that it can stop decoding frames after this point... additonal returns frames will auto be removed in anycase.This will drastically reduce our api surface area (this removed 50 apis and add 26 new ones), and provides a class that can be used to add addition loading functionality without adding new API surface just a new field to
DecoderOptions
It might be worth trying to get this added for / before #2076 so it doesn't add lots of new Size APIs.
We can retain backwards compat by not actually deleting these APIs yet and instead appling
[Obsolete("Format accessible from Metadata.OriginalImageFormat"),EditorBrowsable(EditorBrowsableState.Never)]
and moving them to a new file for obsolete apis. WE can then remove them in a major or 2.Beta Was this translation helpful? Give feedback.
All reactions