Fastställa en kompressors utdataformat

[Funktionen som är associerad med den här sidan, Video Compression Manager, är en äldre funktion. Microsoft rekommenderar starkt att ny kod inte använder den här funktionen.]

I följande exempel används ICCompressGetFormat storleksmakro för att fastställa buffertstorleken som behövs för de data som anger komprimeringsformatet, allokerar en buffert av lämplig storlek med hjälp av funktionen GlobalAlloc och hämtar komprimeringsformatinformationen med hjälp av ICCompressGetFormat makro.

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

I följande exempel används ICCompressQuery makro för att avgöra om en kompressor kan hantera in- och utdataformaten.

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

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

I följande exempel används ICCompressGetSize makro för att fastställa buffertstorleken och allokerar en buffert av den storleken med hjälp av 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);