Partager via


Implementing an Image Decoder Object

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

The Imaging API is used to standardize and facilitate the communication between an image source and an image sink. The image source can encode or decode image data into a format used by the image sink.

An image decoder object takes in encoded image data and produces, as output, image data decoded to a raw graphic format. This data can then be pushed from the image source to the image sink.

An image sink is sometimes said to consume the decoded image data produced by the source.

Use the following instructions to implement an image decoder object for transferring image data from an image source object to an image sink.

To implement an image decoder object

  1. Create an image source and provide it with image data to decode.

  2. Be sure your source obtains a pointer to an IImageSink interface to receive the decoded image data.

    The sink can be designed to accept several pixel formats, but at a minimum it must accept the default format PixelFormat32bppARGB. For more information, see PixelFormat Values.

    All encoders and IBitmapImage interfaces can accept the format PixelFormat32bppARGB.

  3. Be sure your source calls its decoder's IImageDecoder::BeginDecode method.

    This allows the source to take a reference to the sink, but it does not yet allow the source to decode or transfer data. Internally, the source should also initialize all variables and prepare files required for the decode operation.

  4. Be sure your source calls its decoder's IImageDecoder::Decode method.

    This causes the source to send data to the sink as necessary.

The following steps take place within the call to IImageDecoder::Decode.

  1. If your decoder supports property items, it should send those items to the sink, using the following process.
    1. Call IImageSink::GetPropertyBuffer with the correct size for holding all image properties and their data.
    2. Call IImageDecoder::GetAllPropertyItems to fill the property buffer.
    3. Call IImageSink::PushPropertyItems with the property buffer to send the property items to the sink.
    4. Allow the sink to automatically handle deallocating the buffer on its own.
  2. Your decoder must prepare an ImageInfo (Imaging API) structure to describe its preferred parameters for the connection between the source and the sink; then it must call IImageSink::BeginSink to begin negotiating the connection parameters between source and sink.
  3. When the call to IImageSink::BeginSink returns to the decoder, the data in the ImageInfo structure is modified to describe the parameter settings the sink can use.
  4. Your decoder can begin decoding the image by calling IImageSink::GetPixelDataBuffer and IImageSink::ReleasePixelDataBuffer, or by calling IImageSink::PushPixelData. The decoder must use either the PixelFormat value returned by the sink from the call to IImageSink::BeginSink, or the value PixelFormat32bppARGB.
  5. When finished, your decoder must call IImageSink::EndSink.
  6. The decoder can now return from the call to IImageDecoder::Decode.

The following step takes place in the source.

  1. After returning from the decoding function, your source should call IImageDecoder::EndDecode to complete and clean up the decoding process.

See Also

Concepts

Imaging Application Development
Imaging Application Development
Implementing an Image Encoder Object