Decoding Overview

The topic introduces the bitmap decoder, a core Windows Imaging Component (WIC) codec component used to decode image files from a stream.

This topic contains the following sections.

Introduction

Bitmap decoders can be viewed as the outer container of a digital image and provides access to global properties and image frames. Some image formats support global thumbnails, previews, color contexts, or metadata, while others provide these properties only at the frame level. Note, however, many of the standard image formats do not support these global properties. As such, many of the native codec implementations provided by WIC do not support the majority of these global properties. See the table in the Native Bitmap Decoders section of this topic for information about global property support.

In WIC, bitmap decoders are represented by the IWICBitmapDecoder interface and provides access to these global properties of the bitmap and, more importantly, the frames it contains. The IWICBitmapFrameDecode interface represents an individual bitmap frame and is discussed in detail in the Bitmap Sources Overview.

Native Bitmap Decoders

WIC provides several native implementations of the IWICBitmapDecoder interface for the standard web image formats and the high dynamic range HD Photo format. The following table lists the available native decoders, class identifier name, and support for global properties. Though a feature may not support a property such as thumbnails at the global level, the image format may support such properties at the individual frame level.

Image Format CLSID Name Thumbnails Previews Color Contexts Metadata
BMP CLSID_WICBmpDecoder No No No No
GIF CLSID_WICGifDecoder No No No Yes
ICO CLSID_WICIcoDecoder No No No No
JPEG CLSID_WICJpegDecoder No No No No
PNG CLSID_WICPngDecoder No No No No
TIFF CLSID_WICTiffDecoder No No No No
HD Photo CLSID_WICWmpDecoder No Yes No No

 

Creating a Bitmap Decoder

To decode an image using WIC, you first need to create an instance of the IWICBitmapDecoder for the targeted image format. The decoder instance enables you to access the global properties and metadata, if supported, as well as the image frames. The WIC imaging factory, IWICImagingFactory, provides several methods for creating bitmap decoders. The following factory methods are provided to create bitmap decoders.

The following code demonstrates the how to create a bitmap decoder using an image filename and retrieve the first frame of the image.

   // Create a decoder
   IWICBitmapDecoder *pDecoder = NULL;

   hr = m_pIWICFactory->CreateDecoderFromFilename(
       szFileName,                      // Image to be decoded
       NULL,                            // Do not prefer a particular vendor
       GENERIC_READ,                    // Desired read access to the file
       WICDecodeMetadataCacheOnDemand,  // Cache metadata when needed
       &pDecoder                        // Pointer to the decoder
       );

   // Retrieve the first frame of the image from the decoder
   IWICBitmapFrameDecode *pFrame = NULL;

   if (SUCCEEDED(hr))
   {
       hr = pDecoder->GetFrame(0, &pFrame);
   }

Decoder Extensibility

One of the core features of WIC is an extensibility framework that enables codec developers to develop their own image codecs and get the same platform support as the native implementations of image codecs. A single, consistent set of interfaces is used for all image processing, regardless of image format. Any application using WIC gets automatic support for new image formats as soon as the codec is installed. For more information on codec development, see the topics in Component Development. For more information on decoder development, see Implementing a WIC-Enabled Decoder.

Conceptual

Windows Imaging Component Overview

Encoding Overview

Component Development