Implementing an Image Decoder Object (Windows Embedded CE 6.0)
1/6/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
Create an image source and provide it with image data to decode.
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.
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.
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.
- If your decoder supports property items, it should send those items to the sink, using the following process.
- Call IImageSink::GetPropertyBuffer with the correct size for holding all image properties and their data.
- Call IImageDecoder::GetAllPropertyItems to fill the property buffer.
- Call IImageSink::PushPropertyItems with the property buffer to send the property items to the sink.
- Allow the sink to automatically handle deallocating the buffer on its own.
- 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.
- 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.
- 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.
- When finished, your decoder must call IImageSink::EndSink.
- The decoder can now return from the call to IImageDecoder::Decode.
The following step takes place in the source.
- 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
Implementing an Image Encoder Object