共用方式為


壓縮數據

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

下列範例會壓縮影像數據,以用於 AVI 檔案。 它假設壓縮機不支援VIDCF_CRUNCH或VIDCF_TEMPORAL旗標,但它確實支援VIDCF_QUALITY。 此範例使用 ICCompressBegin 巨集(macro)、ICCompress 函式,以及 ICCompressEnd 巨集(macro)。

DWORD dwCkID; 
DWORD dwCompFlags; 
DWORD dwQuality; 
LONG  lNumFrames, lFrameNum; 
// Assume dwNumFrames is initialized to the total number of frames. 
// Assume dwQuality holds the proper quality value (0-10000). 
// Assume lpbiOut, lpOut, lpbiIn, and lpIn are initialized properly. 
 
// If OK to start, compress each frame. 
if (ICCompressBegin(hIC, lpbiIn, lpbiOut) == ICERR_OK)
{ 
    for ( lFrameNum = 0; lFrameNum < lNumFrames; lFrameNum++)
    { 
        if (ICCompress(hIC, 0, lpbiOut, lpOut, lpbiIn, lpIn, 
            &dwCkID, &dwCompFlags, lFrameNum, 
            0, dwQuality, NULL, NULL) == ICERR_OK)
        { 
            // Write compressed data to the AVI file. 
             
            // Set lpIn to the next frame in the sequence. 
             
        } 
        else 
        { 
            // Handle compressor error. 
        } 
    } 
    ICCompressEnd(hIC);    // terminate compression 
} 
else 
{ 
    // Handle the error identifying the unsupported format. 
}