共用方式為


判斷壓縮機的輸出格式

[與此頁面相關聯的功能,影片壓縮管理員是舊版功能。 Microsoft強烈建議新程序代碼不使用此功能。]

下列範例會使用 ICCompressGetFormat size 巨集來判斷指定壓縮格式的數據所需的緩衝區大小、使用 GlobalAlloc 函式配置適當大小的緩衝區,並使用 ICCompressGetFormat 巨集 擷取壓縮格式資訊。

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); 
 

下列範例會使用 ICCompressQuery 巨集來判斷壓縮機是否可以處理輸入和輸出格式。

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. 
 
}
 
 

下列範例使用 ICCompressGetSize 巨集來判斷緩衝區大小,並使用 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);