Muokkaa

Jaa


Implementing a WIC-Enabled Encoder

Introduction

Implementing a Windows Imaging Component (WIC) encoder requires writing two classes, as is also true for implementing a WIC decoder. The interfaces on these classes correspond directly to the encoder responsibilities outlined in the Encoding section of How The Windows Imaging Component Works.

One of the classes provides container-level services and manages the serialization of the individual image frames within the container. This class implements the IWICBitmapEncoder interface. If your image format supports container-level metadata, you must also implement the IWICMetadataBlockWriter interface on this class.

The other class provides frame-level services and does the actual encoding of the image bits for each frame in the container. It also iterates through the metadata blocks for each frame and requests the appropriate metadata writers to serialize the blocks. This class implements the IWICBitmapFrameEncode interface and the IWICMetadataBlockWriter interface. This class should have an IStream member that the container-level class initializes on instantiation, into which the Commit method will serialize the frame data.

In some cases, such as raw formats, the codec author may not want applications to be able to encode or re-encode to the raw format, because the purpose of a raw file is to contain the sensor data exactly as it came from the camera. In cases where the codec author doesn’t want to enable encoding, it is still necessary to implement a rudimentary encoder just to enable adding metadata. In that case, the encoder need only support those methods necessary for writing metadata, and can copy the image bits untouched from the decoder.

Reference

IWICBitmapEncoder

Conceptual

Implementing IWICDevelopRaw

Encoder Interfaces

How to Write a WIC-Enabled CODEC

Windows Imaging Component Overview