Open udaken opened 1 year ago
While I recognize the need and very much support the ability to enumerate decoders and encoders, I think the API could be a bit better. First it is a non-trivial operation so perhaps it should not be a property but a method. This would also allow you to control the enumeration options in the future. Then it is a bit unfortunate that we are enumerating codec infos but on decoder/encoder classes. We could do BitmapCodecInfo.GetAllDecoderInfos()
and BitmapCodecInfo.GetAllEncoderInfos()
where "All" is not very helfpul word, perhaps "Installed" or "Enabled" or "Supported" would be better, or we just drop it.
Alternatively, we could introduce BitmapDecoderInfo
and BitmapEncoderInfo
classes and have the methods there.
We should also have menas to create BitmapDecoder/Encoder from the info.
While I recognize the need and very much support the ability to enumerate decoders and encoders, I think the API could be a bit better. First it is a non-trivial operation so perhaps it should not be a property but a method. This would also allow you to control the enumeration options in the future. Then it is a bit unfortunate that we are enumerating codec infos but on decoder/encoder classes. We could do
BitmapCodecInfo.GetAllDecoderInfos()
andBitmapCodecInfo.GetAllEncoderInfos()
where "All" is not very helfpul word, perhaps "Installed" or "Enabled" or "Supported" would be better, or we just drop it.
I fully agree with your point. "Installed" and "Available" are better descriptors of the procedure than "All".
The native IWICImagingFactory::CreateComponentEnumerator
method allows WICComponentEnumerateOptions to be specified, so a method that allows future overloading to be added would be better.
I change Suggestion to BitmapCodecInfo.GetInstalledDecoderInfos()
/BitmapCodecInfo.GetInstalledEncoderInfos()
.
The native IWICImagingFactory::CreateComponentEnumerator method allows WICComponentEnumerateOptions to be specified, so a method that allows future overloading to be added would be better.
This is an excellent suggestion that will be intuitive to use. I will add this to Alternative Designs.
We should also have menas to create BitmapDecoder/Encoder from the info.
Given the BitmapCodecInfo
, there is already a way to create Y using the ContainerFormat
property and
BitmapDecoder.Create(Guid containerFormat)
/BitmapEncoder.Create(Guid containerFormat)
, there is already a way to create BitmapDecoder
/BitmapEncoder
.
It would be more intuitive if there were an BitmapDecoderInfo.CreateDecoder()
/BitmapEncoderInfo.CreateEncoder()
.
Background and motivation
If an Out-Box type WIC codec such as WebP or AVIF is installed, the
System.Windows.Media.Imaging.BitmapDecoder.Create()
method can be used to process the image. However, it is not possible to retrieve information such as the extension of the installed codec from the WPF application. As a result, the application cannot indicate to the user that these codecs are available, for example, in theOpenFileDialog
.Therefore, we require an API that can retrieve information about all installed codecs.
API Proposal
API Usage
Alternative Designs
Provide classes derived from
BitmapCodecInfo
for Encoder and Decoder.Risks
No response