Tag Archives: WIC

Windows Imaging Component

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 (1339)

WIC File Open Dialog - Demo

WIC File Open Dialog – Demo



  • 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.


Free WIC codecs download

See also

WIC Wrapper Library – Version 1.1

WIC Wrapper Library v1.1 has the following:

  • new and completed methods for existing wrapper classes in the previous version;
  • new classes: wic::Bitmap and wic::Palette;
  • a new header containg enums, WicWrapEnums.h.

Download: WIC Wrapper Library [1.1].zip (1373)

Example 2: Using wic::ImagingFactory::CreateBitmapFromHICON and wic::Bitmap

The following example is close to the previous one, except that it uses wic::ImagingFactory::CreateBitmapFromHICON to display an icon resource.

Demo Application

The demo application displays an icon resource when no image file is loaded.

Download: WIC Wrapper Library Sample [1.1].zip (1282)

WIC Wrapper Library – Sample Application #2

WIC Wrapper Library – Sample Application #2


See also

WIC Wrapper Library – Version 1.0

I’ve begun writing a series of wrapper classes over WIC (Windows Imaging Component) interfaces, that can easily be used in MFC, ATL, or Win32 applications without worry about directly dealing with COM interfaces.
This first version contains basic operation for loading, scaling and converting source image formats that are supported by WIC.
Download: WIC Wrapper Library.zip (1111)
WIC Wrapper Library.zip archive contains the following:

    • Header files, located in \WicWrap\Include folder;
    • WicWrapDLL.dll, both Debug and Release builds, located in \WicWrap\Bin folder;
    • WicWrapDLL.lib, both Debug and Release builds, located in \WicWrap\Lib folder.

Adding WIC Wrapper Library to a project

As said before, WIC Wrapper Library can be used in MFC, ATL or Win32 projects. Here is an example shownig the steps for adding this library to an existing project:

        1. copy WicWrap folder, in the solution directory;
        2. in Solution Explorer window right-click on project name and choose the Properties menu item;
        3. choose All Configurations, go to Configuration Properties\C/C++ and add $(SolutionDir)WicWrap\Include in the Additional Include Directories field;
        4. go to Configuration Properties\Linker\Input and add WicWrapDLL.lib (also for all configurations);
        5. choose Debug configuration, go to Configuration Properties\Linker and add $(SolutionDir)WicWrap\Lib\Debug in the Additional Library Directories field;
        6. choose Release configuration, go to Configuration Properties\Linker and add $(SolutionDir)WicWrap\Lib\Release in the Additional Library Directories field
        7. copy the debug and release versions of WicWrapDLL.dll in solution Debug and Release output directories;
        8. in Solution Explorer window, right-click on project name, choose Add\Existing Item and add the WicWrap header files from \WicWrap\Include folder;
        9. include WicWrap.h in the project source code, e.g in stdafx.h .

Using WIC Wrapper Library

Next is a simple example, in an MFC program:

More details can be found in the demo application, attached below.

Demo Application

The demo application is a simple image viewer made in a simple SDI MFC project.
Download: WIC Wrapper Library Sample [1].zip (1437)

WIC Wrapper Library - Sample Application

WIC Wrapper Library – Sample Application

Note: the image shown in the sample application is taken from SoftIcons.com site.

WIC-related articles and resources

Codexpert – 2013 Articles Summary

C++ Language and STL

Microsoft Libraries (Windows API, MFC, ATL, WIC, WMI, etc.)



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.


See also


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.


      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.