Specifying the Input Format and Determining the Decompression Format

Depending on how the client-application will use the decompressed data, it will send either ICM_DECOMPRESS_GET_FORMAT or ICM_DECOMPRESS_QUERY to specify the input format and determine the decompression format. The client-application sends ICM_DECOMPRESS_GET_FORMAT if it wants your driver to suggest the decompressed format. The client-application sends ICM_DECOMPRESS_QUERY to determine if your driver supports a format it is suggesting.

Both messages send a pointer to a BITMAPINFO data structure in dwParam1. This structure specifies the format of the incoming compressed data. The input format was obtained by the client-application from the 'strf' chunk in the AVI file. While the output format is specified by dwParam2, your driver must use the message to determine how the parameter is defined.

If your driver gets ICM_DECOMPRESS_GET_FORMAT, both dwParam1 and dwParam2 point to BITMAPINFO data structures. The input format data is contained in the dwParam1 structure. Your driver should fill in the dwParam2 BITMAPINFO with information about the format it will use to decompress the data. If your driver can handle the format, return the number of bytes used for the dwParam2 structure as the return value. If your driver cannot handle the input format, or the input format from the 'strf' chunk is incorrect, your driver should return ICERR_BADFORMAT to fail the message.

If you have format information in addition to that specified in the BITMAPINFOHEADER structure, you can add it immediately after this structure. If you do this, update the biSize member to specify the number of bytes used by the structure and your additional information. If a color table is part of the BITMAPINFO information, it follows immediately after your additional information. Return ICERR_OK when your driver has finished updating the data format.

If your driver gets ICM_DECOMPRESS_QUERY, dwParam1 points to a BITMAPINFO data structure containing the input format data. The dwParam2 parameter will either be NULL or contain a pointer to a BITMAPINFO structure describing the decompressed format the client-application wants to use.

If dwParam2 is NULL, your decompression driver can use any output format. In this case, the client-application wants to know if you can decompress the input format and it doesn't care about the output format. If dwParam2 points to a BITMAPINFO structure, the suggested format will be the native or best format for the decompressed data. For example, if playback is on an 8-bit device, the client-application will suggest an 8-bit DIB.

If your driver supports the specified input and output format (which might also include stretching the image), or it supports the specified input with NULL specified for dwParam2, return ICERR_OK to indicate the driver accepts the formats.

Your driver does not have to accept the formats suggested. If you fail the message by returning ICERR_BADFORMAT, the client-application will suggest alternate formats until your driver accepts one. If your driver exhausts the list of formats normally used, the client-application requests a format with ICM_DECOMPRESS_GET_FORMAT.

If you are decompressing to 8-bit data, your driver will also receive the ICM_DECOMPRESS_GET_PALETTE message. Your driver should add a color table to the BITMAPINFO data structure and specify the number of palette entries in the biClrUsed member. The space reserved for the color table will always be 256 colors.