Tag Archives: wic codecs

Enumerate WIC Components

In an older article, I presented a function that enumerates Windows Imaging Component codecs. Recently I had the idea to make a set of WIC Interfaces wrapper classes for easily enumerate and get info about all types of WIC components: bitmap decoders and encoders, metadata readers and writers, format converters, and supported pixel formats. Here are just few samples of code.

CComponentEnumT – a template class for enumerating WIC components

CComponentInfoBaseT – base class for all other component info classes

CPixelFormatInfoT – just one of classes getting WIC component info

Just note that, for further easier using, I’ve defined here CPixelFormatInfo, an alias for CPixelFormatInfoT<IWICPixelFormatInfo2>.

CComponentEnumT specializations and aliases

Finally, let’s see how to use these classes!

Enumerating WIC pixel formats

Quite easy, isn’t it?

Get the pixel format info

You can find the complete source code in the attached demo solution.

Demo solution

Download: Enumerate WIC Components - Demo Solution.zip (10)

Enumerate WIC Components - Demo

Enumerate WIC Components – Demo

The demo solution contains an MFC and a console project that use the classes described above in order to enumerate WIC components and get info about each one. The MFC one allows choosing the component type(s) as well as enum options (include the disabled components or enum only Windows built-in components). The console application is simpler and I wrote it just to demonstrate that my little library of wrapper classes can be used both in MFC and non-MFC applications.

Notes

  • I hope, this article can be useful.
  • If you have any observation or remarks, please do not hesitate to post a reply!

Resources and related articles

WIC File Open Dialog Using IFileOpenDialog Interface

A previoius article extends CFileDialog MFC class, in order to make a File Open or a File Save dialog that automatically filters files, according to available WIC (Windows Imaging Component) codecs. This article presents how to show a similar File Open dialog using IFileOpenDialog interface. This way, it can be used not only in an aplication that uses MFC, but also in an ATL one, even in a raw Win32 or console application that uses basic ATL stuff.
Let’s see an example.

Using IFileOpenDialog to show a WIC File Open Dialog

Enumerating the WIC decoders

Demo project

The demo project is a simple Win32 console application that uses the above functions.

Download: WIC_File_Open_Dialog_Win32_Demo.zip (606)

WIC File Open Dialog - Demo

WIC File Open Dialog – Demo

 

Notes

  • In a similar way, we can make a File Save dialog using IFileSaveDialog interface.
  • This article presents just proof of concepts. IFileOpenDialog offers much more methods to customize the dialog according to specific needs. And of course, a more elegant job can be done by writing some C++ wrapper class(es).
  • For the future, I intend to integrate WIC File Dialogs in WIC Wrapper Library also presented in this blog.
  • The built-in WIC decoders deal with the following image file formats: BMP, GIF, ICO, JPEG, PNG, TIFF and WMPhoto. However there are many other decoders that can befound over the internet. Just to mention two free ones: Microsoft Camera Codec Pack and Adobe DNG Codec for Windows.

Resources

Free WIC codecs download

See also

MFC-extension WIC File Dialogs

A previous article showed how to enumerate WIC (Windows Imaging Component) codecs, that are available in system.
Now, let’s use the codecs list in order to make File Open and File Save As dialogs which are dealing with WIC-compliant image files, i.e. having “File of type” filter list according to available WIC codecs (see the images, below).

WIC Open File Dialog

WIC Open File Dialog

 

WIC Save As File Dialog

WIC Save As File Dialog

CWICFileDialog class

CWICFileDialog is derived from CFileDialog MFC class. It basically overrides CFileDialog::DoModal and constructs the file types filter.

For implementation details, download the demo project attached here.

Demo project

The demo project is just a simple dialog-based MFC application that uses CWICFileDialog. It does nothing else but only shows the file dialogs.
Of course, in practice, you can use CWICFileDialog class in more complex applications like image file viewers, image file converters, and so on.

Resources

See also

Downloads

How to enumerate WIC codecs?

As shown in the previous article, Windows Imaging Component (WIC) comes with built-in codecs (for BMP, JPEG, GIF, PNG, TIFF, and HDPhoto image file formats). Additionally, WIC can deal with other image formats for which appropriate codecs are installed in the system.
Basically, to list available WIC codecs and eventually get info for each one, we can do the following:

  1. Call IWICImagingFactory::CreateComponentEnumerator in order to get a component enumerator either for WIC decoders or for WIC encoders.
  2. For each element of the enumerator, get IWICBitmapCodecInfo interface.
  3. Call IWICBitmapCodecInfo::GetFriendlyName, IWICBitmapCodecInfo::GetFileExtensions and other methods in order to get codec info.

Enumerate WIC codecs

Here is a sample function, implemented as described above. First argument is a pointer to a IWICImagingFactory instance, required for creating the component enumerator. Second argument can have either WICDecoder or WICEncoder value, to retrieve WIC decoders or encoders, respectively. Finally, last argument is an ATL list containing structures to be filled with codecs info.

 

Enumerate WIC decoders

CWICUtils::EnumDecoders simply calls CWICUtils::_EnumCodecs passing WICDecoder value.

 

Enumerate WIC encoders

CWICUtils::EnumEncoders calls CWICUtils::_EnumCodecs passing WICEncoder value.

 

Display WIC decoders info example

This example demonstrates how to use CWICUtils::EnumDecoders to display WIC decoders info in a simple console application.

Notes

      1. Include necessary ATL headers as well as WIC library headers.
      2. Add Windowscodecs.lib to linker additional dependencies or use pragma comment lib as follows:
      3. Here are the definitions of CCodecInfo and CWICUtils classes:

      4. The examples are intentionally made as simple as possible in order to just show how to do; you can modify and adapt them according to your particular needs.
      5. I’ve tested under Visual Studio 2008.
      6. The minimum operating system is Windows XP with SP3 or Windows XP with SP2 and redistributed WIC.

Resources