<p>In WindowsForms world you can get a list of available image encoders/decoders with</p>

<pre><code>System.Drawing.ImageCodecInfo.GetImageDecoders() / GetImageEncoders()
</code></pre>

<p>My question is, is there a way to do something analogous for the WPF world that would allow me to get a list of available </p>

<pre><code>System.Windows.Media.Imaging.BitmapDecoder / BitmapEncoder
</code></pre>

[{'answer_id': 15388, 'author': 'Kevin Crumley', 'author_id': 1818, 'author_profile': 'https://Stackoverflow.com/users/1818', 'pm_score': 1, 'selected': False, 'text': '<p>Hopefully someone will correct me if I\'m wrong, but I don\'t think there\'s anything like that in WPF.  But hopefully this is one of the many cases where advances in the technology have rendered obsolete the way we\'re used to doing things.  Like "how do I wind my digital watch?"</p>\n\n<p>To my understanding, the reason why ImageCodecInfo.GetImageDecoders() is necessary in System.Drawing has to do with the kludgy nature of System.Drawing itself: System.Drawing is a managed wrapper around GDI+, which is an unmanaged wrapper around a portion of the Win32 API.  So there might be a reason why a new codec would be installed in Windows without .NET inherently knowing about it.  And what\'s returned from GetImageDecoders() is just a bunch of strings that are typically passed back into System.Drawing/GDI+, and used to find and configure the appropriate DLL for reading/saving your image.</p>\n\n<p>On the other hand, in WPF, the standard encoders and decoders are built into the framework, and, if I\'m not mistaken, don\'t depend on anything that that isn\'t guaranteed to be installed as part of the framework.  The following classes inherit from BitmapEncoder and are available out-of-the-box with WPF: BmpBitmapEncoder, GifBitmapEncoder, JpegBitmapEncoder, PngBitmapEncoder, TiffBitmapEncoder, WmpBitmapEncoder.  There are BitmapDecoders for all the same formats, plus IconBitmapDecoder and LateBoundBitmapDecoder.</p>\n\n<p>You may be dealing with a case I\'m not imagining, but it seems to me that if you\'re having to use a class that inherits from BitmapEncoder but wasn\'t included with WPF, it\'s probably your own custom class that you would install with your application.</p>\n\n<p>Hope this helps.  If I\'m missing a necessary part of the picture, please let me know.</p>\n'}, {'answer_id': 17448, 'author': 'Frank Krueger', 'author_id': 338, 'author_profile': 'https://Stackoverflow.com/users/338', 'pm_score': 2, 'selected': False, 'text': '<p>You\'ve got to love .NET reflection. I worked on the WPF team and can\'t quite think of anything better off the top of my head. The following code produces this list on my machine:</p>\n\n<pre><code>Bitmap Encoders:\nSystem.Windows.Media.Imaging.BmpBitmapEncoder\nSystem.Windows.Media.Imaging.GifBitmapEncoder\nSystem.Windows.Media.Imaging.JpegBitmapEncoder\nSystem.Windows.Media.Imaging.PngBitmapEncoder\nSystem.Windows.Media.Imaging.TiffBitmapEncoder\nSystem.Windows.Media.Imaging.WmpBitmapEncoder\n\nBitmap Decoders:\nSystem.Windows.Media.Imaging.BmpBitmapDecoder\nSystem.Windows.Media.Imaging.GifBitmapDecoder\nSystem.Windows.Media.Imaging.IconBitmapDecoder\nSystem.Windows.Media.Imaging.LateBoundBitmapDecoder\nSystem.Windows.Media.Imaging.JpegBitmapDecoder\nSystem.Windows.Media.Imaging.PngBitmapDecoder\nSystem.Windows.Media.Imaging.TiffBitmapDecoder\nSystem.Windows.Media.Imaging.WmpBitmapDecoder\n</code></pre>\n\n<p>There is a comment in the code where to add additional assemblies (if you support plugins for example). Also, you will want to filter the decoder list to remove:</p>\n\n<pre><code>System.Windows.Media.Imaging.LateBoundBitmapDecoder\n</code></pre>\n\n<p>More sophisticated filtering using constructor pattern matching is possible, but I don\'t feel like writing it. :-)</p>\n\n<p>All you need to do now is instantiate the encoders and decoders to use them. Also, you can get better names by retrieving the <code>CodecInfo</code> property of the encoder decoders. This class will give you human readable names among other factoids.</p>\n\n<pre><code>using System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing System.Reflection;\nusing System.Windows.Media.Imaging;\n\nnamespace Codecs {\n    class Program {\n        static void Main(string[] args) {\n            Console.WriteLine("Bitmap Encoders:");\n            AllEncoderTypes.ToList().ForEach(t =&gt; Console.WriteLine(t.FullName));\n            Console.WriteLine("\\nBitmap Decoders:");\n            AllDecoderTypes.ToList().ForEach(t =&gt; Console.WriteLine(t.FullName));\n            Console.ReadKey();\n        }\n\n        static IEnumerable&lt;Type&gt; AllEncoderTypes {\n            get {\n                return AllSubclassesOf(typeof(BitmapEncoder));\n            }\n        }\n\n        static IEnumerable&lt;Type&gt; AllDecoderTypes {\n            get {\n                return AllSubclassesOf(typeof(BitmapDecoder));\n            }\n        }\n\n        static IEnumerable&lt;Type&gt; AllSubclassesOf(Type type) {\n            var r = new Reflector();\n            // Add additional assemblies here\n            return r.AllSubclassesOf(type);\n        }\n    }\n\n    class Reflector {\n        List&lt;Assembly&gt; assemblies = new List&lt;Assembly&gt; { \n            typeof(BitmapDecoder).Assembly\n        };\n        public IEnumerable&lt;Type&gt; AllSubclassesOf(Type super) {\n            foreach (var a in assemblies) {\n                foreach (var t in a.GetExportedTypes()) {\n                    if (t.IsSubclassOf(super)) {\n                        yield return t;\n                    }\n                }\n            }\n        }\n    }\n}\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/15023', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']