Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Determining a Compressor's Output Format

The following example uses the ICCompressGetFormat size macro to determine the buffer size needed for the data specifying the compression format, allocates a buffer of the appropriate size using the GlobalAlloc function, and retrieves the compression format information using the ICCompressGetFormat macro.

// *lpbiIn must be initialized to the input format. 
dwFormatSize = ICCompressGetFormatSize(hIC, lpbiIn); 
h = GlobalAlloc(GHND, dwFormatSize); 
lpbiOut = (LPBITMAPINFOHEADER)GlobalLock(h); 
ICCompressGetFormat(hIC, lpbiIn, lpbiOut); 

The following example uses the ICCompressQuery macro to determine whether a compressor can handle the input and output formats.

// Both *lpbiIn and *lpbiOut must be initialized to the respective
// formats.

if (ICCompressQuery(hIC, lpbiIn, lpbiOut) == ICERR_OK)
    // Format is supported; use the compressor. 

The following example uses the ICCompressGetSize macro to determine the buffer size, and it allocates a buffer of that size using GlobalAlloc.

// Find the worst-case buffer size. 
dwCompressBufferSize = ICCompressGetSize(hIC, lpbiIn, lpbiOut); 
// Allocate a buffer and get lpOutput to point to it. 
h = GlobalAlloc(GHND, dwCompressBufferSize); 
lpOutput = (LPVOID)GlobalLock(h);



Community Additions

© 2015 Microsoft