Επεξεργασία

Κοινή χρήση μέσω


Implementing a WIC-Enabled Decoder

Implementing a Windows Imaging Component (WIC) decoder requires writing two classes. The interfaces on these classes correspond directly to the decoder responsibilities outlined in the Decoding section of How The Windows Imaging Component Works.

One of the classes provides container-level services and implements the IWICBitmapDecoder interface. If your image format supports container-level metadata, you must also implement the IWICMetadataBlockReader interface on this class. It is recommended that you support the IWICBitmapCodecProgressNotification interface on both the decoder and encoder to support a better user experience.

The other class you will implement provides frame-level services and does the actual decoding of the image bits for each frame in the container. This class implements the IWICBitmapFrameDecode interface and the IWICMetadataBlockReader interface. If you are writing a decoder for a raw format, you also implement the IWICDevelopRaw interface on this class. In addition to the required interfaces, it is highly recommended that you implement the IWICBitmapSourceTransform interface on this class to enable the best possible performance for your image format.

One of the objects provided by WIC is the ImagingFactory. You frequently use the IWICComponentFactory interface on this object to create various components. Because it is used frequently, you should keep a reference to it as a member property on both your decoder and encoder classes.

IWICImagingFactory* m_pImagingFactory = NULL;
IWICComponentFactory* m_pComponentFactory = NULL;
HRESULT hr;
      
hr = CoCreateInstance(CLSID_WICImagingFactory, NULL,
  CLSCTX_INPROC_SERVER, IID_IWICImagingFactory,
  (LPVOID*) m_pImagingFactory);

hr = m_pImagingFactory->QueryInterface(
  IID_IWICComponentFactory, (void**)&m_pComponentFactory);

Conceptual

How The Windows Imaging Component Works

Decoder Interfaces

How to Write a WIC-Enabled CODEC

Windows Imaging Component Overview

WIC Metadata Overview

Encoding Overview