[API Proposal]: Add API for enumerating installed codecs
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
### 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 the `OpenFileDialog`.
Therefore, we require an API that can retrieve information about all installed codecs.
### API Proposal
```diff
namespace System.Windows.Media.Imaging;
public abstract class BitmapCodecInfo {
// wrapper for IWICImagingFactory::CreateComponentEnumerator(WICDecoder)
+ public static IEnumerable GetInstalledDecoderInfos();
// wrapper for IWICImagingFactory::CreateComponentEnumerator(WICEncoder)
+ public static IEnumerable GetInstalledEncoderInfos();
}
```
### API Usage
```csharp
Console.WriteLine("You can decode the following formats");
foreach (BitmapCodecInfo codecInfo in BitmapCodecInfo.GetInstalledDecoderInfos())
{
Console.WriteLine(codecInfo.FileExtensions);
}
```
### Alternative Designs
Provide classes derived from `BitmapCodecInfo` for Encoder and Decoder.
```diff
namespace System.Windows.Media.Imaging;
+public class BitmapDecoderInfo : BitmapCodecInfo {
+ public static IEnumerable GetInstalledDecoders();
+ public BitmapDecoder CreateDecoder();
+}
+public class BitmapEncoderInfo : BitmapCodecInfo {
+ public static IEnumerable GetInstalledEncoders();
+ public BitmapEncoder CreateEncoder();
+}
```
### Risks
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.